/** * {@inheritdoc} */ public function getDefinitions() { if (is_null($this->pluginDefinitions) || !$this->useCaches) { $this->pluginDefinitions = $this->processDecoratedDefinitions($this->decoratedDiscovery->getDefinitions()); } return $this->pluginDefinitions; }
/** * {@inheritdoc} */ public function getDefinitions() { if (isset($this->registerDefinitions)) { call_user_func($this->registerDefinitions); } $this->definitions += $this->decorated->getDefinitions(); return parent::getDefinitions(); }
/** * {@inheritdoc} */ public function getDefinitions() { /** @var \Drupal\Component\Plugin\PluginManagerInterface $source_plugin_manager */ $source_plugin_manager = \Drupal::service('plugin.manager.migrate.source'); return array_filter($this->decorated->getDefinitions(), function (array $definition) use($source_plugin_manager) { return $source_plugin_manager->hasDefinition($definition['source']['plugin']); }); }
/** * Implements Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinitions(). */ public function getDefinitions() { $definitions = $this->decorated->getDefinitions(); foreach (\Drupal::moduleHandler()->getImplementations($this->hook) as $module) { $function = $module . '_' . $this->hook; $function($definitions); } return $definitions; }
/** * Sets up the entity manager to be tested. * * @param \Drupal\Core\Entity\EntityTypeInterface[]|\Prophecy\Prophecy\ProphecyInterface[] $definitions * (optional) An array of entity type definitions. */ protected function setUpEntityManager($definitions = array()) { $class = $this->getMockClass(EntityInterface::class); foreach ($definitions as $key => $entity_type) { // \Drupal\Core\Entity\EntityTypeInterface::getLinkTemplates() is called // by \Drupal\Core\Entity\EntityManager::processDefinition() so it must // always be mocked. $entity_type->getLinkTemplates()->willReturn([]); // Give the entity type a legitimate class to return. $entity_type->getClass()->willReturn($class); $definitions[$key] = $entity_type->reveal(); } $this->discovery->getDefinition(Argument::cetera())->will(function ($args) use($definitions) { $entity_type_id = $args[0]; $exception_on_invalid = $args[1]; if (isset($definitions[$entity_type_id])) { return $definitions[$entity_type_id]; } elseif (!$exception_on_invalid) { return NULL; } else { throw new PluginNotFoundException($entity_type_id); } }); $this->discovery->getDefinitions()->willReturn($definitions); }
/** * Tests getDefinitions() and getDefinition(). */ function testDiscoveryInterface() { // Ensure that getDefinitions() returns the expected definitions. // For the arrays to be identical (instead of only equal), they must be // sorted equally, which seems unnecessary here. // The discovered definitions may contain circular references; use a custom // assertion message to prevent var_export() from getting called. $this->assertEqual($this->discovery->getDefinitions(), $this->expectedDefinitions, 'Expected definitions found.'); // Ensure that getDefinition() returns the expected definition. foreach ($this->expectedDefinitions as $id => $definition) { $this->assertDefinitionIdentical($this->discovery->getDefinition($id), $definition); } // Ensure that an empty array is returned if no plugin definitions are found. $this->assertIdentical($this->emptyDiscovery->getDefinitions(), array(), 'array() returned if no plugin definitions are found.'); // Ensure that NULL is returned as the definition of a non-existing plugin. $this->assertIdentical($this->emptyDiscovery->getDefinition('non_existing', FALSE), NULL, 'NULL returned as the definition of a non-existing plugin.'); }
/** * {@inheritdoc} * * @throws \Drupal\Component\Plugin\Exception\InvalidDeriverException * Thrown if the 'deriver' class specified in the plugin definition * does not implement \Drupal\Component\Plugin\Derivative\DeriverInterface. */ public function getDefinitions() { $plugin_definitions = $this->decorated->getDefinitions(); return $this->getDerivatives($plugin_definitions); }
/** * {@inheritdoc} */ public function getDefinitions() { return parent::getDefinitions() + $this->decorated->getDefinitions(); }
/** * {@inheritdoc} */ public function getDefinitions() { return $this->discovery->getDefinitions(); }
/** * {@inheritdoc} */ public function getDefinitions() { return static::filterDefinitions($this->decorated->getDefinitions(), $this->providerExists); }