DocPath example


    protected function getTinyMceLang($identity)
    {
        if (!$identity || !$identity->locale) {
            return 'en';
        }

        $attemptedLanguage = substr($identity->locale->getLocale(), 0, 2);

        if (file_exists(Shopware()->DocPath() . 'engine/Library/TinyMce/langs/' . $attemptedLanguage . '.js')) {
            return $attemptedLanguage;
        }

        return 'en';
    }

    private function enableBrowserCache(): void
    {
        if ($this->container->getParameter('shopware.template.forceCompile')) {
            return;
        }

        
$reflectionClass = new ReflectionClass($className);

        $docPath = $docPath === null ? Shopware()->Container()->getParameter('shopware.app.rootDir') : $docPath;

        if (!\is_string($docPath)) {
            throw new RuntimeException('Parameter shopware.app.rootDir has to be an string');
        }

        /** @var string[] $folders */
        $folders = Shopware()->Container()->getParameter('shopware.plugin_directories');

        $folders[] = Shopware()->DocPath('engine_Shopware');
        $folders[] = Shopware()->DocPath('vendor_shopware_shopware');

        foreach ($folders as $folder) {
            $directories[] = substr($folder, \strlen($docPath));
        }

        if ($secure) {
            $this->verifyClass(
                $reflectionClass,
                $docPath,
                $directories
            );
$this->extends = $extends;
    }

    /** * @param string|null $themeDir * * @return string[] */
    protected function getConfigDirs($themeDir)
    {
        $configDir = [];
        if (file_exists(Shopware()->DocPath('snippets'))) {
            $configDir[] = Shopware()->DocPath('snippets');
        }

        // Default theme directories         return array_merge($configDir$this->getPluginDirs()$this->getThemeDirs($themeDir));
    }

    /** * @return array<string> */
    private function getPluginDirs(): array
    {


    /** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $target = $input->getOption('target');
        if ($target !== null && !\is_string($target)) {
            $target = null;
        }
        $dir = $this->container->get('application')->DocPath($target);
        if (!file_exists($dir) || !is_writable($dir)) {
            $old = umask(0);
            if (!mkdir($dir, 0777, true) && !is_dir($dir)) {
                throw new RuntimeException(sprintf('Directory "%s" was not created', $dir));
            }
            chmod($dir, 0777);
            umask($old);
        }
        if (!is_writable($dir)) {
            $output->writeln('<error>Output dir ' . $input->getOption('file') . ' is not writable, aborting</error>');

            
use Shopware\Components\Api\Exception\BatchInterfaceNotImplementedException;
use Shopware\Components\Api\Exception\CustomValidationException;
use Shopware\Components\Api\Exception\NonUniqueIdentifierUsedException;
use Shopware\Components\Api\Exception\NotFoundException;
use Shopware\Components\Api\Exception\OrmException;
use Shopware\Components\Api\Exception\ParameterMissingException;
use Shopware\Components\Api\Exception\PrivilegeException;
use Shopware\Components\Api\Exception\ValidationException;
use Shopware\Components\Logger;

if (file_exists($this->DocPath() . 'config_' . $this->Environment() . '.php')) {
    $customConfig = $this->loadConfig($this->DocPath() . 'config_' . $this->Environment() . '.php');
} elseif (file_exists($this->DocPath() . 'config.php')) {
    $customConfig = $this->loadConfig($this->DocPath() . 'config.php');
} else {
    $customConfig = [];
}

if (!\is_array($customConfig)) {
    throw new Enlight_Exception('The custom configuration file must return an array.');
}


    public function check($requirement)
    {
        if (!\is_array($requirement['value'])) {
            throw new InvalidArgumentException(__CLASS__ . ' needs an array as value for the requirement check');
        }

        $results = [];
        foreach ($requirement['value']['directories'] as $dir) {
            $result = $this->scanDirectoryForRegex(
                Shopware()->DocPath($dir),
                $requirement['value']['expression'],
                $requirement['value']['fileRegex']
            );

            $results = array_merge($results$result);
        }

        $message = $this->extractLocalizedMessage($requirement['value']['message']);

        if (empty($results)) {
            return null;
        }
$extension = pathinfo($fileName, PATHINFO_EXTENSION);

        if (!\in_array($extension['csv', 'txt'])) {
            echo json_encode([
                'success' => false,
                'message' => 'Unknown Extension',
            ]);

            return;
        }

        $destPath = Shopware()->DocPath('media_temp');
        if (!is_dir($destPath)) {
            // Try to create directory with write permissions             mkdir($destPath, 0777, true);
        }

        $destPath = realpath($destPath);
        if ($destPath === false || !file_exists($destPath)) {
            echo json_encode([
                'success' => false,
                'message' => sprintf("Destination directory '%s' does not exist.", $destPath),
            ]);

            
$directories = [];
        $checkedDirectories = [];

        $successMessage = $this->namespace->get('controller/check_writable_success', 'The following directories are writeable <br/>%s');
        $failMessage = $this->namespace->get('controller/check_writable_failure', 'The following directories are not writable: <br> %s');

        if (!\is_array($requirement['value'])) {
            throw new InvalidArgumentException(__CLASS__ . ' needs an array as value for the requirement check');
        }

        foreach ($requirement['value'] as $path) {
            $fullPath = rtrim(Shopware()->DocPath($path), '/');
            $checkedDirectories[] = $fullPath;

            $fixPermissions = true;
            $directories = array_merge(
                $directories,
                $this->fileSystem->checkSingleDirectoryPermissions($fullPath$fixPermissions)
            );
        }

        if (empty($directories)) {
            return [
                


            $projectDir = $this->container->getParameter('shopware.app.rootDir');

            if (!\is_string($projectDir)) {
                throw new RuntimeException('Parameter shopware.app.rootDir has to be an string');
            }

            $thumbnailDir = $projectDir . 'media' . DIRECTORY_SEPARATOR . strtolower($media['type']) . DIRECTORY_SEPARATOR . 'thumbnail' . DIRECTORY_SEPARATOR;
            $path = $thumbnailDir . $this->removeSpecialCharacters($media['name']) . '_' . $size . '.' . $media['extension'];

            $path = str_replace(Shopware()->DocPath(), '', $path);
            if (DIRECTORY_SEPARATOR !== '/') {
                $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
            }
            $thumbnails[(string) $size] = $path;
        }

        return $thumbnails;
    }

    /** * Removes special characters from a filename */
'data' => $result,
        ]);
    }

    /** * @return void */
    public function isUpdateAllowedAction()
    {
        $fs = new SwagUpdateFileSystem();

        $result = $fs->checkDirectoryPermissions(Shopware()->DocPath(), true);

        if (!empty($result)) {
            $wrongPermissionCount = \count($result);

            $this->container->get('corelogger')->error(
                sprintf('SwagUpdate: There are %d files without write permission. FTP credentials are needed.', $wrongPermissionCount),
                $result
            );

            $this->View()->assign([
                'success' => true,
                


        // Name changed? Then rename the file and set the new path         if ($isNameChanged) {
            $mediaService = Shopware()->Container()->get(MediaServiceInterface::class);
            $newName = $this->getFileName();
            $newPath = $this->getUploadDir() . $newName;

            // Rename the file             $mediaService->rename($this->path, $newPath);

            $newPath = str_replace(Shopware()->DocPath(), '', $newPath);

            // Set the new path to save it.             $this->path = $newPath;
        }
    }

    /** * Model event function, which called when the model is loaded. * * @ORM\PostLoad() */
    
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class SettingsLabelsFindMissingCommand extends ShopwareCommand implements CompletionAwareInterface
{
    /** * {@inheritdoc} */
    public function completeOptionValues($optionName, CompletionContext $context)
    {
        if ($optionName === 'target') {
            return $this->completeDirectoriesInDirectory($this->container->get('application')->DocPath());
        }

        return [];
    }

    /** * {@inheritdoc} */
    public function completeArgumentValues($argumentName, CompletionContext $context)
    {
        if ($argumentName === 'locale') {
            
if (!$esd) {
                $esd = new Esd();
                $esd->setArticleDetail($variant);
            }

            if (isset($data['esd']['file'])) {
                $file = $this->getMediaResource()->load($data['esd']['file']);
                $fileName = pathinfo($data['esd']['file'], PATHINFO_FILENAME);
                $fileExt = pathinfo($data['esd']['file'], PATHINFO_EXTENSION);

                $esdDir = Shopware()->DocPath('files_' . Shopware()->Config()->get('sESDKEY'));

                // File already exists?                 if (file_exists($esdDir . '/' . $fileName . '.' . $fileExt) && !$data['esd']['reuse']) {
                    $saveFileName = uniqid($fileName) . '.' . $fileExt;
                } else {
                    $saveFileName = $fileName . '.' . $fileExt;
                }
                $saveFile = $esdDir . '/' . $saveFileName;

                if (!is_writable($esdDir)) {
                    throw new RuntimeException(sprintf('Unable to save ESD-file, as the directory "%s" is not writable.', $esdDir));
                }


    /** * @param string $path * * @return string */
    public function OldPath($path = null)
    {
        trigger_error('Shopware()->OldPath() is deprecated since version 5.2 and will be removed in 5.8. Use Shopware()->DocPath() instead.', E_USER_DEPRECATED);

        return $this->DocPath($path);
    }

    /** * Returns document path: <project root>/ * * @param string|null $path * * @return string */
    public function DocPath($path = null)
    {
        
Home | Imprint | This part of the site doesn't use cookies.