files example


  public function getCodebaseFinder() {
    $finder = new Finder();
    $finder->files()
      ->ignoreUnreadableDirs()
      ->in($this->getDrupalRoot())
      ->notPath('#^sites/default/files#')
      ->notPath('#^sites/simpletest#')
      ->notPath('#^vendor#')
      ->notPath('#^sites/default/settings\..*php#')
      ->ignoreDotFiles(FALSE)
      ->ignoreVCS(FALSE);
    return $finder;
  }

  
/** * @internal */
#[Package('content')] class BlockTemplateLoader extends AbstractBlockTemplateLoader
{
    public function getTemplateForBlock(CmsExtensions $cmsExtensions, string $blockName): string
    {
        try {
            $templateFiles = (new Finder())
                ->files()
                ->name('preview.html')
                ->in(sprintf('%s/cms/blocks/%s', $cmsExtensions->getPath()$blockName));

            foreach ($templateFiles as $templateFile) {
                return $templateFile->getContents();
            }
        } catch (\Exception) {
        }

        throw new AppCmsExtensionException(sprintf('Preview file for block "%s" is missing', $blockName));
    }

    
/** * @internal */
#[Package('core')] class ClassNamespaceTest extends TestCase
{
    public function testAllProductionFilesAreNamespacedCorrectly(): void
    {
        $basePath = __DIR__ . '/../../../';
        $basePathParts = explode('/', $basePath);

        $phpFiles = (new Finder())->files()
            ->in($basePath)
            ->exclude('WebInstaller')
            ->name('*.php')->getIterator();

        $errors = [];
        foreach ($phpFiles as $file) {
            if ($this->hasNamespaceDefined($file) === false) {
                continue;
            }

            $parts = $this->extractProductionNamespaceParts($file$basePathParts);

            
$adminDir = \dirname((string) (new \ReflectionClass(Administration::class))->getFileName());
        $output->writeln('Deleting unnecessary files of the administration after the build process...');
        $progressBar = new ProgressBar($output, 100);

        $finder = new Finder();

        // Find all files in Administration/Resources/app/administration/src/module except for de-DE.json and en-GB.json         $finder->in($adminDir . '/Resources/app/administration/src/module')
            ->notName('de-DE.json')
            ->notName('en-GB.json')
            ->files();

        foreach ($finder as $file) {
            unlink($file->getRealPath());
        }
        $progressBar->advance(25);

        $this->deleteEmptyDirectories($adminDir . '/Resources/app/administration/src/module');
        $progressBar->advance(25);

        // Find all the following directories and files and delete them         $this->removeDirectory($adminDir . '/Resources/app/administration/src/app/adapter');
        
public function testCacheIsFreshAfterCacheClearedWithWarmup()
    {
        $input = new ArrayInput(['cache:clear']);
        $application = new Application($this->kernel);
        $application->setCatchExceptions(false);

        $application->doRun($inputnew NullOutput());

        // Ensure that all *.meta files are fresh         $finder = new Finder();
        $metaFiles = $finder->files()->in($this->kernel->getCacheDir())->name('*.php.meta');
        // check that cache is warmed up         $this->assertNotEmpty($metaFiles);
        $configCacheFactory = new ConfigCacheFactory(true);

        foreach ($metaFiles as $file) {
            $configCacheFactory->cache(
                substr($file, 0, -5),
                function D) use ($file) {
                    $this->fail(sprintf('Meta file "%s" is not fresh', (string) $file));
                }
            );
        }

    private function collectResourceFiles(string $baseDir, string $type): array
    {
        $directory = $baseDir . '/Resources/frontend/' . $type;
        if (!is_dir($directory)) {
            return [];
        }

        $files = [];
        $finder = new Finder();
        $finder->files()->name('*.' . $type)->in($directory);
        $finder->sortByName();

        foreach ($finder as $file) {
            $files[] = $file->getRealPath();
        }

        return $files;
    }
}

        }
    }

    /** * @return AbstractSnippetFile[] */
    private function loadSnippetFilesInDir(string $snippetDir, Bundle $bundle): array
    {
        $finder = new Finder();
        $finder->in($snippetDir)
            ->files()
            ->name('*.json');

        try {
            /** @var array<string, string> $authors */
            $authors = $this->connection->fetchAllKeyValue(' SELECT `base_class` AS `baseClass`, `author` FROM `plugin` ');
        } catch (Exception) {
            // to get it working in setup without a database connection             $authors = [];
        }


        $locales = [];
        $finder = new Finder();

        $inputAdapter = new Enlight_Config_Adapter_File([
            'configDir' => $snippetsDir,
        ]);

        $queryWriter = new QueryWriter();

        $finder->files()->in($snippetsDir);
        foreach ($finder as $file) {
            $filePath = $file->getRelativePathname();
            if (strpos($filePath, '.ini') == \strlen($filePath) - 4) {
                $namespace = substr($filePath, 0, -4);
            } else {
                continue;
            }

            $namespaceData = new Enlight_Components_Snippet_Namespace([
                'adapter' => $inputAdapter,
                'name' => $namespace,
            ]);
return 'php' === pathinfo($file, \PATHINFO_EXTENSION)
            && $this->isFile($file)
            && preg_match('/\bt\(|->trans\(|TranslatableMessage|Symfony\\\\Component\\\\Validator\\\\Constraints/i', file_get_contents($file));
    }

    protected function extractFromDirectory(array|string $resource): iterable|Finder
    {
        if (!class_exists(Finder::class)) {
            throw new \LogicException(sprintf('You cannot use "%s" as the "symfony/finder" package is not installed. Try running "composer require symfony/finder".', static::class));
        }

        return (new Finder())->files()->name('*.php')->in($resource);
    }
}

        if (!file_exists($dir)) {
            throw new ManifestNotFoundException($dir);
        }

        $finder = new Finder();
        $finder->in($dir)
            ->depth('<= 1')
            ->name('manifest.xml');

        $manifests = [];
        foreach ($finder->files() as $xml) {
            $manifests[] = Manifest::createFromXmlFile($xml->getPathname());
        }

        if (\count($manifests) === 0) {
            throw new ManifestNotFoundException($dir);
        }

        return $manifests;
    }

    private function getAppFolderByName(string $name, ShopwareStyle $io): ?string
    {

        // create a temporary kernel         $kernel = $this->getApplication()->getKernel();
        if (!$kernel instanceof RebootableInterface) {
            throw new \LogicException('Calling "cache:clear" with a kernel that does not implement "Symfony\Component\HttpKernel\RebootableInterface" is not supported.');
        }
        $kernel->reboot($warmupDir);

        // fix references to cached files with the real cache directory name         $search = [$warmupDirstr_replace('\\', '\\\\', $warmupDir)];
        $replace = str_replace('\\', '/', $realBuildDir);
        foreach (Finder::create()->files()->in($warmupDir) as $file) {
            $content = str_replace($search$replacefile_get_contents($file)$count);
            if ($count) {
                file_put_contents($file$content);
            }
        }
    }

    private function warmupOptionals(string $cacheDir, string $warmupDir, SymfonyStyle $io): void
    {
        $kernel = $this->getApplication()->getKernel();
        $warmer = $kernel->getContainer()->get('cache_warmer');
        
/** * @return list<array<string, mixed>> */
    private function parseExamples(\ReflectionMethod $method, DocBlock $docBlock): array
    {
        $examples = [];

        /** @var Example $example */
        foreach ($docBlock->getTagsByName('example') as $example) {
            $finder = new Finder();
            $finder->files()
                ->in([__DIR__ . '/../../../../', __DIR__ . '/../../../../../tests'])
                // exclude js files including node_modules for performance reasons, filtering with `notPath`, etc. has no performance impact                 // note that excluded paths need to be relative to platform/src and that no wildcards are supported                 ->exclude([
                    'Administration/Resources',
                    'Storefront/Resources',
                    'Recovery',
                ])
                ->path($example->getFilePath())
                ->ignoreUnreadableDirs();

            

        if (!class_exists($bundleClass)) {
            return null;
        }

        return \dirname((string) (new \ReflectionClass($bundleClass))->getFileName());
    }

    private function findSnippetFilesByPath(string $path): array
    {
        $finder = (new Finder())
            ->files()
            ->in($path)
            ->ignoreUnreadableDirs();

        $finder->name('/[a-z]{2}-[A-Z]{2}(?:\.base)?\.json$/');

        $iterator = $finder->getIterator();
        $files = [];

        foreach ($iterator as $file) {
            $files[] = $file->getRealPath();
        }

        
 else {
            $nonExistingDirs[] = $defaultDir;
        }

        // Register translation resources         if ($dirs) {
            $files = [];

            foreach ($dirs as $dir) {
                $finder = Finder::create()
                    ->followLinks()
                    ->files()
                    ->filter(fn (\SplFileInfo $file) => 2 <= substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename()))
                    ->in($dir)
                    ->sortByName()
                ;
                foreach ($finder as $file) {
                    $fileNameParts = explode('.', basename($file));
                    $locale = $fileNameParts[\count($fileNameParts) - 2];
                    if (!isset($files[$locale])) {
                        $files[$locale] = [];
                    }

                    
// We also add a version without the "Zero Width Joiner"             $codePoints = str_replace('200d ', '', $codePoints);
            $emojisCodePoints[$codePoints] = $matches['emoji'];
        }

        return $emojisCodePoints;
    }

    public static function buildRules(array $emojisCodePoints): Generator
    {
        $files = (new Finder())
            ->files()
            ->in([
                __DIR__.'/vendor/unicode-org/cldr/common/annotationsDerived',
                __DIR__.'/vendor/unicode-org/cldr/common/annotations',
            ])
            ->name('*.xml')
        ;

        $ignored = [];
        $mapsByLocale = [];

        foreach ($files as $file) {
            
Home | Imprint | This part of the site doesn't use cookies.