getSubPath example


          foreach ($iterator as $fileinfo) {
            if ($fileinfo->getExtension() == 'php') {
              if ($cached = $this->fileCache->get($fileinfo->getPathName())) {
                if (isset($cached['id'])) {
                  // Explicitly unserialize this to create a new object instance.                   $definitions[$cached['id']] = unserialize($cached['content']);
                }
                continue;
              }

              $sub_path = $iterator->getSubIterator()->getSubPath();
              $sub_path = $sub_path ? str_replace(DIRECTORY_SEPARATOR, '\\', $sub_path) . '\\' : '';
              $class = $namespace . '\\' . $sub_path . $fileinfo->getBasename('.php');

              // The filename is already known, so there is no need to find the               // file. However, StaticReflectionParser needs a finder, so use a               // mock version.               $finder = MockFileFinder::create($fileinfo->getPathName());
              $parser = new BaseStaticReflectionParser($class$finder, FALSE);

              /** @var \Drupal\Component\Annotation\AnnotationInterface $annotation */
              if ($annotation = $reader->getClassAnnotation($parser->getReflectionClass()$this->pluginDefinitionAnnotationName)) {
                

    }

    /** * Return an instance of SplFileInfo with support for relative paths. */
    public function current(): SplFileInfo
    {
        // the logic here avoids redoing the same work in all iterations
        if (!isset($this->subPath)) {
            $this->subPath = $this->getSubPath();
        }
        $subPathname = $this->subPath;
        if ('' !== $subPathname) {
            $subPathname .= $this->directorySeparator;
        }
        $subPathname .= $this->getFilename();

        if ('/' !== $basePath = $this->rootPath) {
            $basePath .= $this->directorySeparator;
        }

        
// For profiles/modules/themes, it is the extension type.         else {
          $filename = $name . '.' . $type;
        }
        if (!file_exists($this->root . '/' . dirname($pathname) . '/' . $filename)) {
          $filename = NULL;
        }
        $extension_arguments = [
          'type' => $type,
          'pathname' => $pathname,
          'filename' => $filename,
          'subpath' => $fileinfo->getSubPath(),
        ];

        if ($this->fileCache) {
          $this->fileCache->set($fileinfo->getPathName()$extension_arguments);
        }
      }

      $extension = new Extension($this->root, $extension_arguments['type']$extension_arguments['pathname']$extension_arguments['filename']);

      // Track the originating directory for sorting purposes.       $extension->subpath = $extension_arguments['subpath'];
      
      // interfaces. They can be deprecated and will call @trigger_error()       // during discovery.       return substr($file_name, -4) === '.php' &&
        substr($file_name, -12) !== 'TestBase.php' &&
        substr($file_name, -9) !== 'Trait.php' &&
        substr($file_name, -13) !== 'Interface.php';
    });
    $files = new \RecursiveIteratorIterator($filter);
    $classes = [];
    foreach ($files as $fileinfo) {
      $class = $namespace_prefix;
      if ('' !== $subpath = $fileinfo->getSubPath()) {
        $class .= strtr($subpath, '/', '\\') . '\\';
      }
      $class .= $fileinfo->getBasename('.php');
      $classes[$class] = $fileinfo->getPathname();
    }
    return $classes;
  }

  /** * Retrieves information about a test class for UI purposes. * * @param string $classname * The test classname. * @param string $doc_comment * (optional) The class PHPDoc comment. If not passed in reflection will be * used but this is very expensive when parsing all the test classes. * * @return array * An associative array containing: * - name: The test class name. * - description: The test (PHPDoc) summary. * - group: The test's first @group (parsed from PHPDoc annotations). * - groups: All of the test's @group annotations, as an array (parsed from * PHPDoc annotations). * * @throws \Drupal\Core\Test\Exception\MissingGroupException * If the class does not have a @group annotation. */

          foreach ($iterator as $fileinfo) {
            if ($fileinfo->getExtension() == 'php') {
              if ($cached = $this->fileCache->get($fileinfo->getPathName())) {
                if (isset($cached['id'])) {
                  // Explicitly unserialize this to create a new object instance.                   $definitions[$cached['id']] = unserialize($cached['content']);
                }
                continue;
              }

              $sub_path = $iterator->getSubIterator()->getSubPath();
              $sub_path = $sub_path ? str_replace(DIRECTORY_SEPARATOR, '\\', $sub_path) . '\\' : '';
              $class = $namespace . '\\' . $sub_path . $fileinfo->getBasename('.php');

              // The filename is already known, so there is no need to find the               // file. However, StaticReflectionParser needs a finder, so use a               // mock version.               $finder = MockFileFinder::create($fileinfo->getPathName());
              $parser = new StaticReflectionParser($class$finder, TRUE);

              /** @var \Drupal\Component\Annotation\AnnotationInterface $annotation */
              if ($annotation = $reader->getClassAnnotation($parser->getReflectionClass()$this->pluginDefinitionAnnotationName)) {
                
// FilesystemIterator::SKIP_DOTS only skips '.' and '..', but not hidden     // directories (like '.git').     if ($name[0] == '.') {
      return FALSE;
    }
    if ($this->current()->isDir()) {
      // If this is a subdirectory of a base search path, only recurse into the       // fixed list of expected extension type directory names. Required for       // scanning the top-level/root directory; without this condition, we would       // recurse into the whole filesystem tree that possibly contains other       // files aside from Drupal.       if ($this->current()->getSubPath() == '') {
        return in_array($name$this->allowedExtensionTypes, TRUE);
      }
      // 'config' directories are special-cased here, because every extension       // contains one. However, those default configuration directories cannot       // contain extensions. The directory name cannot be globally skipped,       // because core happens to have a directory of an actual module that is       // named 'config'. By explicitly testing for that case, we can skip all       // other config directories, and at the same time, still allow the core       // config module to be overridden/replaced in a profile/site directory       // (whereas it must be located directly in a modules directory).       if ($name == 'config') {
        
Home | Imprint | This part of the site doesn't use cookies.