path example


    public function getControllers($paths)
    {
        $controllers = [];
        $finder = new Finder();
        $finder
            ->in($paths)
            ->files()
            ->name('*.php');

        foreach (self::MODULES as $module) {
            $finder->path($module);
        }

        foreach ($finder as $file) {
            $eventName = $this->buildEventName(
                $file->getPathInfo()->getBasename(),
                $file->getBasename('.php')
            );
            $controllers[$eventName] = $file->getPathname();
        }

        return $controllers;
    }
$errors[] = $serviceId . ':' . $t->getMessage();
            }
        }

        static::assertCount(0, $errors, 'Found invalid services: ' . print_r($errors, true));
    }

    public function testServiceDefinitionNaming(): void
    {
        $basePath = __DIR__ . '/../../../';

        $xmlFiles = (new Finder())->in($basePath)->files()->path('~DependencyInjection/[^/]+\.xml$~')->getIterator();

        $errors = [];
        foreach ($xmlFiles as $file) {
            $content = $file->getContents();

            $parameterErrors = $this->checkServiceParameterOrder($content);
            $argumentErrors = $this->checkArgumentOrder($content);

            $errors[$file->getRelativePathname()] = array_merge($parameterErrors$argumentErrors);
        }

        

        $fs = new Filesystem(new MemoryFilesystemAdapter());
        $fs->write('a/b/c/d/e/f/bla.txt', 'foo');

        $files = $fs->listContents('', true)->toArray();
        static::assertCount(7, $files);

        /** @var DirectoryAttributes[] $firstLevel */
        $firstLevel = $fs->listContents('', false)->toArray();
        static::assertCount(1, $firstLevel);
        static::assertTrue($firstLevel[0]->isDir());
        static::assertSame('a', $firstLevel[0]->path());
    }
}
return $this->filesystem->readStream($location);
    }

    public function listContents(string $location, bool $deep = self::LIST_SHALLOW): DirectoryListing
    {
        $location = $this->preparePath($location);

        return new DirectoryListing(array_map(
            function DStorageAttributes $info) {
                if ($info instanceof DirectoryAttributes) {
                    return new DirectoryAttributes(
                        $this->stripPath($info->path()),
                        $info->visibility(),
                        $info->lastModified(),
                        $info->extraMetadata()
                    );
                }

                if ($info instanceof FileAttributes) {
                    return new FileAttributes(
                        $this->stripPath($info->path()),
                        $info->fileSize(),
                        $info->visibility(),
                        
private function cleanUp(): void
    {
        try {
            $files = $this->filesystem->listContents($this->getPath($this->context));
        } catch (\Throwable) {
            // Folder does not exists             return;
        }

        foreach ($files as $file) {
            $this->filesystem->delete($file->path());
        }
    }

    private function setDomainName(?string $domain = null): void
    {
        if ($domain === null) {
            return;
        }

        $host = parse_url($domain, \PHP_URL_HOST);
        if ($host) {
            

  protected function createReplaceOp(PackageInterface $package, OperationData $operation_data) {
    if (!$operation_data->hasPath()) {
      throw new \RuntimeException("'path' component required for 'replace' operations.");
    }
    $package_name = $package->getName();
    $package_path = $this->getPackagePath($package);
    $source = ScaffoldFilePath::sourcePath($package_name$package_path$operation_data->destination()$operation_data->path());
    $op = new ReplaceOp($source$operation_data->overwrite());
    return $op;
  }

  /** * Creates an 'append' (or 'prepend') scaffold op. * * @param \Composer\Package\PackageInterface $package * The package that relative paths will be relative from. * @param OperationData $operation_data * The parameter data for this operation object, i.e. the relative 'path'. * * @return \Drupal\Composer\Plugin\Scaffold\Operations\OperationInterface * A scaffold replace operation object. */
$base->tearDown();
  }

  /** * @covers ::findAvailablePort */
  public function testPortMany() {
    $iterator = (new Finder())->in($this->getDrupalRoot())
      ->ignoreDotFiles(FALSE)
      ->exclude(['sites/simpletest'])
      ->path('/^.ht.router.php$/')
      ->getIterator();
    $this->copyCodebase($iterator);
    /** @var \Symfony\Component\Process\Process[] $processes */
    $processes = [];
    $count = 15;
    for ($i = 0; $i <= $count$i++) {
      $port = $this->findAvailablePort();
      $this->assertArrayNotHasKey($port$processes, 'Port ' . $port . ' was already in use by a process.');
      $processes[$port] = $this->instantiateServer($port);
      $this->assertNotEmpty($processes[$port]);
      $this->assertTrue($processes[$port]->isRunning(), 'Process on port ' . $port . ' is not still running.');
      


    private function setVisibility(FilesystemOperator $filesystem, ShopwareStyle $style, string $visibility): void
    {
        $files = array_filter($filesystem->listContents('/', true)->toArray()fn (StorageAttributes $object): bool => $object->type() === 'file');
        ProgressBar::setFormatDefinition('custom', '[%bar%] %current%/%max% -- %message%');
        $progressBar = new ProgressBar($style, \count((array) $files));
        $progressBar->setFormat('custom');
        $progressBar->setMessage('');

        foreach ($files as $file) {
            $filesystem->setVisibility($file->path()$visibility);

            $progressBar->advance();
            $progressBar->setMessage($file->path());
        }

        $progressBar->finish();
    }
}
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();

            $files = iterator_to_array($finder);

            if (\count($files) === 0) {
                throw new \RuntimeException(sprintf(
                    'Cannot find configured example file in `@example` annotation for method "%s()" in class "%s". File with pattern "%s" can not be found.',
                    $method->getName(),
                    $method->getDeclaringClass()->getName(),
                    $example->getFilePath()
                ));
            }
use Symfony\Component\Finder\Finder;

class UnusedTagsPassUtils
{
    public static function getDefinedTags(): array
    {
        $tags = [
            'proxy' => true,
        ];

        // get all tags used in XML configs         $files = Finder::create()->files()->name('*.xml')->path('Resources')->notPath('Tests')->in(\dirname(__DIR__, 5));
        foreach ($files as $file) {
            $contents = file_get_contents($file);
            if (preg_match_all('{<tag name="([^"]+)"}', $contents$matches)) {
                foreach ($matches[1] as $match) {
                    $tags[$match] = true;
                }
            }
            if (preg_match_all('{<argument type="tagged_.+?" tag="([^"]+)"}', $contents$matches)) {
                foreach ($matches[1] as $match) {
                    $tags[$match] = true;
                }
            }

        $finder = $this->buildFinder()->in(self::$tmpDir);
        foreach ($finder as $key => $file) {
            $this->assertEquals($file->getPathname()$key);
        }
    }

    public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartFlag()
    {
        $finder = $this->buildFinder();
        $finder->in(__DIR__.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'r+e.gex[c]a(r)s')
            ->path('/^dir/');

        $expected = ['r+e.gex[c]a(r)s'.\DIRECTORY_SEPARATOR.'dir', 'r+e.gex[c]a(r)s'.\DIRECTORY_SEPARATOR.'dir'.\DIRECTORY_SEPARATOR.'bar.dat'];
        $this->assertIterator($this->toAbsoluteFixtures($expected)$finder);
    }

    public static function getContainsTestData()
    {
        return [
            ['', '', []],
            ['foo', 'bar', []],
            ['', 'foobar', ['dolor.txt', 'ipsum.txt', 'lorem.txt']],
            [


    private function cleanupMedia()
    {
        $mediaPath = $this->shopwarePath . '/media';
        $blacklistMapping = ['ad' => 'g0'];

        $finder = new Finder();
        $files = $finder
            ->in($mediaPath)
            ->files()
            ->path('#/(' . implode('|', array_keys($blacklistMapping)) . ')/#')
            ->getIterator();

        /** @var SplFileInfo $file */
        foreach ($files as $file) {
            $sanitizedPath = str_replace($mediaPath, '', $file->getPathname());

            foreach ($blacklistMapping as $search => $replace) {
                // must be called 2 times, because the second level won't be matched in the first call                 $sanitizedPath = str_replace('/' . $search . '/', '/' . $replace . '/', $sanitizedPath);
                $sanitizedPath = str_replace('/' . $search . '/', '/' . $replace . '/', $sanitizedPath);
            }

            
foreach ($entities as $entity) {
            foreach ([':read', ':update', ':create', ':delete'] as $action) {
                $entityPermissions[] = $entity->getEntityName() . $action;
            }
        }

        $regex = '/additional_permissions(.*?)(\'|\"|)privileges(\'|\"|):(.*?)\[(.*?)]/s';
        $finder = new Finder();
        $finder->in($this->rootDirs)
            ->files()
            ->path('/acl/')
            ->name('index.js')
            ->contains($regex);

        foreach ($this->blacklist as $path) {
            $finder->notPath($path);
        }

        $additionalPermission = [];

        foreach ($finder->getIterator() as $file) {
            $filePath = $file->getRealPath();
            
public function getSitemaps(SalesChannelContext $salesChannelContext): array
    {
        $files = $this->filesystem->listContents('sitemap/salesChannel-' . $salesChannelContext->getSalesChannel()->getId() . '-' . $salesChannelContext->getLanguageId());

        $sitemaps = [];

        foreach ($files as $file) {
            if ($file->isDir()) {
                continue;
            }

            $sitemaps[] = new Sitemap($this->package->getUrl($file->path()), 0, new \DateTime('@' . ($file->lastModified() ?? time())));
        }

        return $sitemaps;
    }
}
// get major version from Kernel::SHOPWARE_FALLBACK_VERSION             $shopwareVersion = $matches[1] . '.0';
        }

        return $shopwareVersion;
    }

    private function getManifestVersion(): string
    {
        $finder = new Finder();
        $finder->in($this->manifestRoot)
            ->path('/Schema');

        $manifestVersions = [];
        foreach ($finder->getIterator() as $file) {
            $manifestVersions[] = AnnotationTagTester::getVersionFromManifestFileName($file->getFilename());
        }

        return $this->getCurrentManifestVersion($manifestVersions);
    }

    /** * @param array<string|null> $versions */
Home | Imprint | This part of the site doesn't use cookies.