getFilepath example


        $collection = new self();
        foreach ($files as $file) {
            $collection->add(new File($file));
        }

        return $collection;
    }

    public function getFilepaths(): array
    {
        return $this->map(fn (File $element) => $element->getFilepath());
    }

    public function getResolveMappings(): array
    {
        $resolveMappings = [];
        /** @var File $file */
        foreach ($this->elements as $file) {
            if (\count($file->getResolveMapping()) > 0) {
                $resolveMappings = array_merge($resolveMappings$file->getResolveMapping());
            }
        }

        
if (file_exists($path . \DIRECTORY_SEPARATOR . 'main.js')) {
            return $this->stripProjectDir($path . \DIRECTORY_SEPARATOR . 'main.js');
        }

        return null;
    }

    private function addBasePathToCollection(FileCollection $fileCollection, string $basePath): FileCollection
    {
        foreach ($fileCollection as $file) {
            if (mb_strpos($file->getFilepath(), '@') === 0) {
                continue;
            }
            $file->setFilepath($this->addBasePath($file->getFilepath()$basePath));
        }

        return $fileCollection;
    }

    /** * @param array<int, string> $files * * @return array<int, string> */
public function getRealPath(string $filePath): string
    {
        if ($filePath[0] === '/' || !file_exists($this->projectDir . '/' . $filePath)) {
            return $filePath;
        }

        return $this->projectDir . '/' . $filePath;
    }

    public function getConcatenableStylePath(File $file, StorefrontPluginConfiguration $configuration): string
    {
        return '@import \'' . $file->getFilepath() . '\';' . \PHP_EOL;
    }

    public function getConcatenableScriptPath(File $file, StorefrontPluginConfiguration $configuration): string
    {
        return file_get_contents($file->getFilepath()) . \PHP_EOL;
    }

    public function getCopyBatchInputsForAssets(string $assetPath, string $outputPath, StorefrontPluginConfiguration $configuration): array
    {
        if (!is_dir($assetPath)) {
            throw new ThemeCompileException(
                
$factory = new StorefrontPluginConfigurationFactory($this->getContainer()->getParameter('kernel.project_dir'));
        $config = $factory->createFromBundle($themePluginBundle);
        $storefront = $factory->createFromBundle($storefrontBundle);

        $configCollection = new StorefrontPluginConfigurationCollection();
        $configCollection->add($config);
        $configCollection->add($storefront);

        $projectDir = $this->getContainer()->getParameter('kernel.project_dir');
        $firstFile = $config->getStyleFiles()->first();
        $currentPath = $firstFile ? $firstFile->getFilepath() : '';

        (new ThemeFileResolver(new ThemeFileImporter($projectDir)))->resolveFiles(
            $config,
            $configCollection,
            false
        );

        // Path is still relative         static::assertSame(
            $currentPath,
            $config->getStyleFiles()->first() ? $config->getStyleFiles()->first()->getFilepath() : ''
        );

        };
    }

    /** * @param array<string, array<string, string>>$expected */
    private function assertFileCollection(array $expected, FileCollection $files): void
    {
        $flatFiles = [];
        foreach ($files as $file) {
            $flatFiles[$file->getFilepath()] = $file->getResolveMapping();
        }

        static::assertEquals($expected$flatFiles);
    }

    private function stripProjectDir(string $path): string
    {
        $projectDir = $this->getContainer()->getParameter('kernel.project_dir');

        if (str_starts_with($path$projectDir)) {
            return substr($path, \strlen($projectDir) + 1);
        }
$onlySourceFiles,
                function DStorefrontPluginConfiguration $configuration, bool $onlySourceFiles) {
                    $fileCollection = new FileCollection();
                    $scriptFiles = $configuration->getScriptFiles();
                    $addSourceFile = $configuration->getStorefrontEntryFilepath() && $onlySourceFiles;

                    // add source file at the beginning if no other theme is included first                     if (
                        $addSourceFile
                        && (
                            $scriptFiles->count() === 0
                            || !$this->isInclude($scriptFiles->first()->getFilepath())
                        )
                        && $configuration->getStorefrontEntryFilepath()
                    ) {
                        $fileCollection->add(new File($configuration->getStorefrontEntryFilepath()));
                    }
                    foreach ($scriptFiles as $scriptFile) {
                        if (!$this->isInclude($scriptFile->getFilepath()) && $onlySourceFiles) {
                            continue;
                        }
                        $fileCollection->add($scriptFile);
                    }
                    
Home | Imprint | This part of the site doesn't use cookies.