locatePath example

public function __construct(private readonly AbstractAppLoader $appLoader)
    {
    }

    /** * Returns the list of script paths the given app contains * * @return array<string> */
    public function getScriptPathsForApp(string $appPath): array
    {
        $scriptDirectory = $this->appLoader->locatePath($appPath, self::SCRIPT_DIR);

        if ($scriptDirectory === null || !is_dir($scriptDirectory)) {
            return [];
        }

        $finder = new Finder();
        $finder->files()
            ->in($scriptDirectory)
            ->exclude('rule-conditions')
            ->name(self::ALLOWED_FILE_EXTENSIONS)
            ->ignoreUnreadableDirs();

        
/** * @decrecated tag:v6.6.0 - Will be removed without replacement */
    public function copyRecoveryAssets(): void
    {
        Feature::triggerDeprecationOrThrow('v6.6.0.0', Feature::deprecatedMethodMessage(self::class, __METHOD__, 'v6.6.0.0'));
    }

    public function copyAssetsFromApp(string $appName, string $appPath, bool $force = false): void
    {
        $publicDirectory = $this->appLoader->locatePath($appPath, 'Resources/public');

        if ($publicDirectory === null) {
            return;
        }

        $this->copyAssetsFromBundleOrApp(
            $publicDirectory,
            $appName,
            $force
        );
    }

    
'%s/%s/src/Resources/',
                $this->projectDir,
                $pluginPath,
            ),
            PluginEntity::class,
            $pluginId
        );
    }

    public function updateApp(string $appId, string $appPath): ?CustomEntityXmlSchema
    {
        $resourcePath = $this->appLoader->locatePath($appPath, 'Resources');

        if ($resourcePath === null) {
            return null;
        }

        return $this->update(
            $resourcePath,
            AppEntity::class,
            $appId
        );
    }

    
/** * @return Manifest[] */
    abstract public function load(): array;

    /** * @return array<mixed>|null */
    public function getConfiguration(AppEntity $app): ?array
    {
        $configPath = $this->locatePath($app->getPath(), 'Resources/config/config.xml');

        if ($configPath === null) {
            return null;
        }

        return $this->configReader->read($configPath);
    }

    abstract public function deleteApp(string $technicalName): void;

    public function getCmsExtensions(AppEntity $app): ?CmsManifest
    {
private readonly AbstractTemplateLoader $inner,
        private readonly AbstractStorefrontPluginConfigurationFactory $storefrontPluginConfigurationFactory,
        private readonly AbstractAppLoader $appLoader,
        private readonly string $projectDir
    ) {
    }

    public function getTemplatePathsForApp(Manifest $app): array
    {
        $viewPaths = $this->inner->getTemplatePathsForApp($app);

        $resourceDirectory = $this->appLoader->locatePath($app->getPath(), 'Resources');

        if ($resourceDirectory === null) {
            return $viewPaths;
        }

        $relativeAppPath = str_replace($this->projectDir . '/', '', $app->getPath());
        $storefrontConfig = $this->storefrontPluginConfigurationFactory->createFromApp($app->getMetadata()->getName()$relativeAppPath);

        if (!is_dir($resourceDirectory) || !$storefrontConfig->getIconSets()) {
            return $viewPaths;
        }

        
private const ALLOWED_FILE_EXTENSIONS = '*.twig';

    public function __construct(private readonly AbstractAppLoader $appLoader)
    {
    }

    /** * {@inheritdoc} */
    public function getTemplatePathsForApp(Manifest $app): array
    {
        $viewDirectory = $this->appLoader->locatePath($app->getPath(), self::TEMPLATE_DIR);

        if ($viewDirectory === null) {
            return [];
        }

        $finder = new Finder();
        $finder->files()
            ->in($viewDirectory)
            ->name(self::ALLOWED_FILE_EXTENSIONS)
            ->path(self::ALLOWED_TEMPLATE_DIRS)
            ->ignoreUnreadableDirs();

        
Home | Imprint | This part of the site doesn't use cookies.