DemoContentManager.php in Open Social 8.7
Same filename and directory in other branches
- 8.9 modules/custom/social_demo/src/DemoContentManager.php
- 8 modules/custom/social_demo/src/DemoContentManager.php
- 8.2 modules/custom/social_demo/src/DemoContentManager.php
- 8.3 modules/custom/social_demo/src/DemoContentManager.php
- 8.4 modules/custom/social_demo/src/DemoContentManager.php
- 8.5 modules/custom/social_demo/src/DemoContentManager.php
- 8.6 modules/custom/social_demo/src/DemoContentManager.php
- 8.8 modules/custom/social_demo/src/DemoContentManager.php
- 10.3.x modules/custom/social_demo/src/DemoContentManager.php
- 10.0.x modules/custom/social_demo/src/DemoContentManager.php
- 10.1.x modules/custom/social_demo/src/DemoContentManager.php
- 10.2.x modules/custom/social_demo/src/DemoContentManager.php
Namespace
Drupal\social_demoFile
modules/custom/social_demo/src/DemoContentManager.phpView source
<?php
namespace Drupal\social_demo;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
/**
* Class DemoContentManager.
*
* @package Drupal\social_demo
*/
class DemoContentManager extends DefaultPluginManager {
/**
* {@inheritdoc}
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/DemoContent', $namespaces, $module_handler, 'Drupal\\social_demo\\DemoContentInterface', 'Drupal\\social_demo\\Annotation\\DemoContent');
}
/**
* {@inheritdoc}
*/
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;
}
/**
* Create multiple instances.
*
* @param array $plugin_ids
* Identifiers of plugins.
* @param array $configurations
* Array with configuration for all plugins.
*
* @return array
* Array with instances of the plugins.
*/
public function createInstances(array $plugin_ids, array $configurations = []) {
$instances = [];
foreach ($plugin_ids as $plugin_id) {
$configuration = isset($configurations[$plugin_id]) ? $configurations[$plugin_id] : [];
$instances[$plugin_id] = static::createInstance($plugin_id, $configuration);
}
return $instances;
}
}
Classes
Name | Description |
---|---|
DemoContentManager | Class DemoContentManager. |