DefaultSingleLazyPluginCollection example

$definitions = $this->getPluginDefinitions();
    $this->pluginInstances['apple'] = new ConfigurablePlugin(['id' => 'apple', 'key' => 'value'], 'apple', $definitions['apple']);
    $this->pluginInstances['banana'] = new ConfigurablePlugin(['id' => 'banana', 'key' => 'other_value'], 'banana', $definitions['banana']);

    $create_count = $create_count ?: $this->never();
    $this->pluginManager->expects($create_count)
      ->method('createInstance')
      ->willReturnCallback(function D$id) {
        return $this->pluginInstances[$id];
      });

    $this->defaultPluginCollection = new DefaultSingleLazyPluginCollection($this->pluginManager, 'apple', ['id' => 'apple', 'key' => 'value']);
  }

  /** * Tests the get() method. */
  public function testGet() {
    $this->setupPluginCollection($this->once());
    $apple = $this->pluginInstances['apple'];

    $this->assertSame($apple$this->defaultPluginCollection->get('apple'));
  }

  
return ['type_settings' => $this->getPluginCollection()];
  }

  /** * Encapsulates the creation of the workflow's plugin collection. * * @return \Drupal\Core\Plugin\DefaultSingleLazyPluginCollection * The workflow's plugin collection. */
  protected function getPluginCollection() {
    if (!$this->pluginCollection && $this->type) {
      $this->pluginCollection = new DefaultSingleLazyPluginCollection(\Drupal::service('plugin.manager.workflows.type')$this->type, $this->type_settings);
    }
    return $this->pluginCollection;
  }

  /** * Loads all workflows of the provided type. * * @param string $type * The workflow type to load all workflows for. * * @return static[] * An array of workflow objects of the provided workflow type, indexed by * their IDs. * * @see \Drupal\workflows\Annotation\WorkflowType */
if (in_array($method$this->getMethods()) && isset($this->configuration[$method]['supported_formats'])) {
      return $this->configuration[$method]['supported_formats'];
    }
    return [];
  }

  /** * {@inheritdoc} */
  public function getPluginCollections() {
    return [
      'resource' => new DefaultSingleLazyPluginCollection($this->getResourcePluginManager()$this->plugin_id, []),
    ];
  }

  /** * {@inheritdoc} */
  public function calculateDependencies() {
    parent::calculateDependencies();

    foreach ($this->getRestResourceDependencies()->calculateDependencies($this) as $type => $dependencies) {
      foreach ($dependencies as $dependency) {
        
return $this->sourcePluginCollection()->get($this->source);
  }

  /** * Returns media source lazy plugin collection. * * @return \Drupal\Core\Plugin\DefaultSingleLazyPluginCollection|null * The tag plugin collection or NULL if the plugin ID was not set yet. */
  protected function sourcePluginCollection() {
    if (!$this->sourcePluginCollection && $this->source) {
      $this->sourcePluginCollection = new DefaultSingleLazyPluginCollection(\Drupal::service('plugin.manager.media.source')$this->source, $this->source_configuration);
    }
    return $this->sourcePluginCollection;
  }

  /** * {@inheritdoc} */
  public function getStatus() {
    return $this->status;
  }

  
Home | Imprint | This part of the site doesn't use cookies.