Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function createInstance($plugin_id, array $configuration = array())
 {
     // If this PluginManager has fallback capabilities catch
     // PluginNotFoundExceptions.
     if ($this instanceof FallbackPluginManagerInterface) {
         try {
             return $this->factory->createInstance($plugin_id, $configuration);
         } catch (PluginNotFoundException $e) {
             $fallback_id = $this->getFallbackPluginId($plugin_id, $configuration);
             return $this->factory->createInstance($fallback_id, $configuration);
         }
     } else {
         return $this->factory->createInstance($plugin_id, $configuration);
     }
 }
Exemplo n.º 2
0
 /**
  * @param string $id
  * @param array $definition
  *
  * @return \Drupal\libraries\ExternalLibrary\Type\LibraryTypeInterface
  */
 protected function getLibraryType($id, $definition)
 {
     // @todo Validate that the type is a string.
     if (!isset($definition['type'])) {
         throw new LibraryTypeNotFoundException($id);
     }
     return $this->libraryTypeFactory->createInstance($definition['type']);
 }
Exemplo n.º 3
0
 /**
  * Returns the library type that is being tested.
  *
  * @return \Drupal\libraries\ExternalLibrary\Type\LibraryTypeInterface
  *   The test library type.
  */
 protected function getLibraryType()
 {
     try {
         $library_type = $this->libraryTypeFactory->createInstance($this->getLibraryTypeId());
     } catch (PluginException $exception) {
         $library_type = $this->prophesize(LibraryTypeInterface::class)->reveal();
     } finally {
         return $library_type;
     }
 }
Exemplo n.º 4
0
 /**
  * Returns a pre-configured menu link plugin instance.
  *
  * @param string $plugin_id
  *   The ID of the plugin being instantiated.
  * @param array $configuration
  *   An array of configuration relevant to the plugin instance.
  *
  * @return \Drupal\Core\Menu\MenuLinkInterface
  *   A menu link instance.
  *
  * @throws \Drupal\Component\Plugin\Exception\PluginException
  *   If the instance cannot be created, such as if the ID is invalid.
  */
 public function createInstance($plugin_id, array $configuration = array())
 {
     return $this->factory->createInstance($plugin_id, $configuration);
 }
Exemplo n.º 5
0
 /**
  * Gets the locator of this library using the locator factory.
  *
  * @param \Drupal\Component\Plugin\Factory\FactoryInterface $locator_factory
  *
  * @return \Drupal\libraries\ExternalLibrary\Local\LocatorInterface
  *
  * @see \Drupal\libraries\ExternalLibrary\Local\LocalLibraryInterface::getLocator()
  */
 public function getLocator(FactoryInterface $locator_factory)
 {
     return $locator_factory->createInstance('stream', ['scheme' => 'asset']);
 }
Exemplo n.º 6
0
 /**
  * Constructs a \Drupal\cas\Form\CasSettings object.
  *
  * @param ConfigFactoryInterface $config_factory
  *   The factory for configuration objects.
  * @param FactoryInterface $plugin_factory
  *   The condition plugin factory.
  */
 public function __construct(ConfigFactoryInterface $config_factory, FactoryInterface $plugin_factory)
 {
     parent::__construct($config_factory);
     $this->gatewayPaths = $plugin_factory->createInstance('request_path');
     $this->forcedLoginPaths = $plugin_factory->createInstance('request_path');
 }
Exemplo n.º 7
0
 /**
  * Gets the version detector of this library using the detector factory.
  *
  * Because determining the installation version of a library is not specific
  * to any library or even any library type, this logic is offloaded to
  * separate detector objects.
  *
  * @param \Drupal\Component\Plugin\Factory\FactoryInterface $detector_factory
  *
  * @return \Drupal\libraries\ExternalLibrary\Version\VersionDetectorInterface
  *
  * @see \Drupal\libraries\ExternalLibrary\Version\VersionDetectorInterface
  */
 public function getVersionDetector(FactoryInterface $detector_factory)
 {
     return $detector_factory->createInstance($this->versionDetector['id'], $this->versionDetector['configuration']);
 }