You are here

class MultipleAssetLibraryType in Libraries API 8.3

Plugin annotation

@LibraryType("asset_multiple");

Hierarchy

Expanded class hierarchy of MultipleAssetLibraryType

File

src/Plugin/libraries/Type/MultipleAssetLibraryType.php, line 15

Namespace

Drupal\libraries\Plugin\libraries\Type
View source
class MultipleAssetLibraryType extends LibraryTypeBase implements AttachableAssetLibraryRegistrationInterface {

  /**
   * {@inheritdoc}
   */
  public function getLibraryClass() {
    return MultipleAssetLibrary::class;
  }

  /**
   * {@inheritdoc}
   */
  public function getAttachableAssetLibraries(LibraryInterface $external_library, LibraryManagerInterface $library_manager) {
    assert($external_library instanceof \Drupal\libraries\ExternalLibrary\Asset\MultipleAssetLibraryInterface);

    /** @var \Drupal\libraries\ExternalLibrary\Asset\MultipleAssetLibraryInterface $external_library */
    $attachable_libraries = [];
    foreach ($external_library
      ->getAttachableAssetLibraries($library_manager) as $component_name => $attachable_library) {
      $attachable_library_id = $this
        ->getAttachableLibraryId($external_library, $component_name);
      $attachable_libraries[$attachable_library_id] = $attachable_library;
    }
    return $attachable_libraries;
  }

  /**
   * @param \Drupal\libraries\ExternalLibrary\LibraryInterface $external_library
   * @param string $component_name
   *
   * @return string
   */
  protected function getAttachableLibraryId(LibraryInterface $external_library, $component_name) {
    return $external_library
      ->getId() . MultipleAssetLibraryInterface::SEPARATOR . $component_name;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
IdAccessorTrait::$id protected property The ID.
IdAccessorTrait::getId public function Returns the ID.
LibraryTypeBase::$detectorFactory protected property The version detector factory.
LibraryTypeBase::$locatorFactory protected property The locator factory.
LibraryTypeBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create 1
LibraryTypeBase::onLibraryCreate public function Reacts to the instantiation of a library. Overrides LibraryCreationListenerInterface::onLibraryCreate
LibraryTypeBase::__construct public function Constructs the asset library type. 1
MultipleAssetLibraryType::getAttachableAssetLibraries public function Reacts to the instantiation of a library. Overrides AttachableAssetLibraryRegistrationInterface::getAttachableAssetLibraries
MultipleAssetLibraryType::getAttachableLibraryId protected function
MultipleAssetLibraryType::getLibraryClass public function Returns the class used for libraries of this type. Overrides LibraryTypeInterface::getLibraryClass