getAllAvailableInfo example

/** * Returns an array of info files information of installed extensions. * * This function returns the processed contents (with added defaults) of the * .info.yml files. * * @return array[] * An associative array of extension information arrays, keyed by extension * name. */
  public function getAllInstalledInfo() {
    return array_intersect_key($this->getAllAvailableInfo()array_flip($this->getInstalledExtensionNames()));
  }

  /** * Generates the information from .info.yml files for extensions of this type. * * @return array[] * An array of arrays of .info.yml entries keyed by the machine name. */
  protected function recalculateInfo() {
    return array_map(function DExtension $extension) {
      return $extension->info;
    },

  protected function listDirectories($type) {
    $directories = [];

    // Find the extensions of this type, even if they are not installed, but     // excluding test ones.     $lister = \Drupal::service('extension.list.' . $type);
    foreach ($lister->getAllAvailableInfo() as $name => $info) {
      // Skip obsolete and deprecated modules.       if ($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::OBSOLETE || $info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::DEPRECATED) {
        continue;
      }
      $path = $lister->getPath($name);
      // You can tell test modules because they are in package 'Testing', but       // test themes are only known by being found in test directories. So...       // exclude things in test directories.       if (!str_contains($path, '/tests') && !str_contains($path, '/testing')) {
        $directories[$name] = $path . '/help_topics';
      }
    }
'name' => 'test name',
      'mtime' => 123456789,
    ]$info);
  }

  /** * @covers ::getAllAvailableInfo */
  public function testGetAllAvailableInfo() {
    $test_extension_list = $this->setupTestExtensionList();

    $infos = $test_extension_list->getAllAvailableInfo();
    $this->assertEquals([
      'test_name' => [
        'type' => 'test_extension',
        'core' => '8.x',
        'name' => 'test name',
        'mtime' => 123456789,
      ],
    ]$infos);
  }

  /** * @covers ::getAllInstalledInfo */
Home | Imprint | This part of the site doesn't use cookies.