You are here

public function DemoContentManager::createInstance in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 modules/custom/social_demo/src/DemoContentManager.php \Drupal\social_demo\DemoContentManager::createInstance()
  2. 8 modules/custom/social_demo/src/DemoContentManager.php \Drupal\social_demo\DemoContentManager::createInstance()
  3. 8.2 modules/custom/social_demo/src/DemoContentManager.php \Drupal\social_demo\DemoContentManager::createInstance()
  4. 8.3 modules/custom/social_demo/src/DemoContentManager.php \Drupal\social_demo\DemoContentManager::createInstance()
  5. 8.4 modules/custom/social_demo/src/DemoContentManager.php \Drupal\social_demo\DemoContentManager::createInstance()
  6. 8.5 modules/custom/social_demo/src/DemoContentManager.php \Drupal\social_demo\DemoContentManager::createInstance()
  7. 8.6 modules/custom/social_demo/src/DemoContentManager.php \Drupal\social_demo\DemoContentManager::createInstance()
  8. 8.7 modules/custom/social_demo/src/DemoContentManager.php \Drupal\social_demo\DemoContentManager::createInstance()
  9. 8.8 modules/custom/social_demo/src/DemoContentManager.php \Drupal\social_demo\DemoContentManager::createInstance()
  10. 10.3.x modules/custom/social_demo/src/DemoContentManager.php \Drupal\social_demo\DemoContentManager::createInstance()
  11. 10.0.x modules/custom/social_demo/src/DemoContentManager.php \Drupal\social_demo\DemoContentManager::createInstance()
  12. 10.2.x modules/custom/social_demo/src/DemoContentManager.php \Drupal\social_demo\DemoContentManager::createInstance()

Creates a pre-configured instance of a plugin.

Parameters

string $plugin_id: The ID of the plugin being instantiated.

array $configuration: An array of configuration relevant to the plugin instance.

Return value

object A fully configured plugin instance.

Throws

\Drupal\Component\Plugin\Exception\PluginException If the instance cannot be created, such as if the ID is invalid.

Overrides PluginManagerBase::createInstance

1 call to DemoContentManager::createInstance()
DemoContentManager::createInstances in modules/custom/social_demo/src/DemoContentManager.php
Create multiple instances.

File

modules/custom/social_demo/src/DemoContentManager.php, line 34

Class

DemoContentManager
Class DemoContentManager.

Namespace

Drupal\social_demo

Code

public function createInstance($plugin_id, array $configuration = []) {

  /** @var \Drupal\social_demo\DemoContentInterface $plugin */
  $plugin = parent::createInstance($plugin_id, $configuration);
  $definition = $plugin
    ->getPluginDefinition();
  $storage = \Drupal::entityTypeManager()
    ->getStorage($definition['entity_type']);
  $plugin
    ->setEntityStorage($storage);
  return $plugin;
}