ignoreUnreadableDirs example

/** * @return array<int, string> */
    private function getSnippetsFromDir(string $directory): array
    {
        $finder = new Finder();
        $finder->files()
            ->in($directory)
            ->name('*.html.twig')
            ->sortByName()
            ->notName('render.html.twig')
            ->ignoreUnreadableDirs();

        $snippets = array_values(array_map(static fn (\SplFileInfo $file): string => ltrim(mb_substr(str_replace('.html.twig', '', $file->getPathname())mb_strlen($directory)), '/')iterator_to_array($finder)));

        return $snippets;
    }
}

  protected function getComponentPathsFinder(string $drupal_root): Finder {
    $finder = new Finder();
    $finder->name('composer.json')
      ->in($drupal_root . static::$componentsPath)
      ->ignoreUnreadableDirs()
      ->depth(1);

    return $finder;
  }

}

  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;
  }

  /** * Get the root path of this Drupal codebase. * * @return string * The full path to the root of this Drupal codebase. */


    /** * @return array<int, string> */
    private function findSnippetFiles(?string $locale = null, bool $withPlugins = true): array
    {
        $finder = (new Finder())
            ->files()
            ->in(__DIR__ . '/../../*/Resources/app/administration/src/')
            ->exclude('node_modules')
            ->ignoreUnreadableDirs();

        if ($locale) {
            $finder->name(sprintf('%s.json', $locale));
        } else {
            $finder->name('/[a-z]{2}-[A-Z]{2}\.json/');
        }

        if ($withPlugins) {
            $finder->in($this->getPluginPaths());
        }

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

        return array_values(array_map(static fn (\SplFileInfo $file): string => ltrim(mb_substr($file->getPathname()mb_strlen($scriptDirectory)), '/')iterator_to_array($finder)));
    }

    /** * Returns the content of the script */
    public function getScriptContent(string $name, string $appPath): string
    {
        $content = $this->appLoader->loadFile($appPath, self::SCRIPT_DIR . '/' . $name);

        
$this->markTestSkipped('could read test files while test requires unreadable');
        }
    }

    public function testIgnoredAccessDeniedException()
    {
        if ('\\' === \DIRECTORY_SEPARATOR) {
            $this->markTestSkipped('chmod is not supported on Windows');
        }

        $finder = $this->buildFinder();
        $finder->files()->ignoreUnreadableDirs()->in(self::$tmpDir);

        // make 'foo' directory non-readable         $testDir = self::$tmpDir.\DIRECTORY_SEPARATOR.'foo';
        chmod($testDir, 0333);

        if (false === ($couldRead = is_readable($testDir))) {
            $this->assertIterator($this->toAbsolute([
                'foo bar',
                'test.php',
                'test.py',
                'qux/baz_100_1.py',
                
$storefrontConfig = $this->storefrontPluginConfigurationFactory->createFromApp($app->getMetadata()->getName()$relativeAppPath);

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

        $finder = new Finder();
        $finder->files()
            ->in($resourceDirectory)
            ->name(['*.html.twig', '*.svg'])
            ->path(array_values($storefrontConfig->getIconSets()))
            ->ignoreUnreadableDirs();

        // return file paths relative to Resources/views directory         $iconPaths = array_values(array_map(static function D\SplFileInfo $file) use ($resourceDirectory): string {
            // remove resource + any leading slashes from pathname             $resourcePath = ltrim(mb_substr($file->getPathname()mb_strlen($resourceDirectory)), '/');

            return $resourcePath;
        }iterator_to_array($finder)));

        return [
            ...array_values($viewPaths),
            
$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();

        return array_values(array_map(static fn (\SplFileInfo $file): string => ltrim(mb_substr($file->getPathname()mb_strlen($viewDirectory)), '/')iterator_to_array($finder)));
    }

    /** * {@inheritdoc} */
    public function getTemplateContent(string $path, Manifest $app): string
    {
        $content = $this->appLoader->loadFile($app->getPath(), self::TEMPLATE_DIR . '/' . $path);

        

  public function getComposerJsonFinder($drupal_root) {
    $composer_json_finder = new Finder();
    $composer_json_finder->name('composer.json')
      ->in([
        // Only find composer.json files within composer/ and core/ directories         // so we don't inadvertently test contrib in local dev environments.         $drupal_root . '/composer',
        $drupal_root . '/core',
      ])
      ->ignoreUnreadableDirs()
      ->notPath('#^vendor#')
      ->notPath('#/fixture#');
    return $composer_json_finder;
  }

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

        return $files;
    }
$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()
                ));
            }

            
// Grab the 'replace' section of the core composer.json file.     $json = json_decode(file_get_contents($this->root . '/core/composer.json'), FALSE);
    $composer_replace_packages = (array) $json->replace;

    // Get a list of all the composer.json files in the components path.     $components_composer_json_files = [];

    $composer_json_finder = new Finder();
    $composer_json_finder->name('composer.json')
      ->in($components_path)
      ->ignoreUnreadableDirs();

    foreach ($composer_json_finder->getIterator() as $composer_json) {
      $components_composer_json_files[$composer_json->getPathname()] = [$composer_json->getPathname()];
    }

    $this->assertNotEmpty($components_composer_json_files);
    $this->assertCount(count($composer_replace_packages)$components_composer_json_files);

    // Assert that each core components has a corresponding 'replace' in     // composer.json.     foreach ($components_composer_json_files as $components_composer_json_file) {
      
static::assertEquals($expectedEn$actualEn);
    }

    /** * @return array<string> */
    private function getSnippetFilePathsOfFixtures(string $folder, string $namePattern): array
    {
        $finder = (new Finder())
            ->files()
            ->in(__DIR__ . '/fixtures/' . $folder . '/')
            ->ignoreUnreadableDirs()
            ->name($namePattern);

        $iterator = $finder->getIterator();

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

        return $files;
    }

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