本文整理汇总了PHP中Drupal\Core\Plugin\DefaultPluginManager::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP DefaultPluginManager::__construct方法的具体用法?PHP DefaultPluginManager::__construct怎么用?PHP DefaultPluginManager::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Plugin\DefaultPluginManager
的用法示例。
在下文中一共展示了DefaultPluginManager::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructs the ImageToolkitManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\ImageToolkit\ImageToolkitOperationManagerInterface $operation_manager
* The toolkit operation manager.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, ImageToolkitOperationManagerInterface $operation_manager)
{
parent::__construct('Plugin/ImageToolkit', $namespaces, $module_handler, 'Drupal\\Core\\ImageToolkit\\Annotation\\ImageToolkit');
$this->setCacheBackend($cache_backend, 'image_toolkit_plugins');
$this->configFactory = $config_factory;
$this->operationManager = $operation_manager;
}
示例2: __construct
/**
* Constructs a new instance.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
* @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver
* The class_resolver.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ClassResolverInterface $class_resolver)
{
parent::__construct('Plugin/Payment/Method', $namespaces, $module_handler, PaymentMethodInterface::class, PaymentMethod::class);
$this->alterInfo('payment_method');
$this->setCacheBackend($cache_backend, 'payment_method', ['payment_method']);
$this->classResolver = $class_resolver;
}
示例3: __construct
/**
* Constructs a MigratePluginManager object.
*
* @param string $type
* The type of the plugin: row, source, process, destination, entity_field,
* id_map.
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
* @param string $annotation
* The annotation class name.
*/
public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, $annotation = 'Drupal\\Component\\Annotation\\PluginID')
{
$plugin_interface = isset($plugin_interface_map[$type]) ? $plugin_interface_map[$type] : NULL;
parent::__construct("Plugin/migrate/{$type}", $namespaces, $module_handler, $plugin_interface, $annotation);
$this->alterInfo('migrate_' . $type . '_info');
$this->setCacheBackend($cache_backend, 'migrate_plugins_' . $type);
}
示例4: __construct
/**
* Constructs a ProcessorPluginManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\StringTranslation\TranslationInterface $translation
* The string translation manager.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, TranslationInterface $translation)
{
parent::__construct('Plugin/search_api/processor', $namespaces, $module_handler, 'Drupal\\search_api\\Processor\\ProcessorInterface', 'Drupal\\search_api\\Annotation\\SearchApiProcessor');
$this->setCacheBackend($cache_backend, 'search_api_processors');
$this->alterInfo('search_api_processor_info');
$this->setStringTranslation($translation);
}
示例5: __construct
/**
* Constructs a new instance.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory)
{
parent::__construct('Plugin/Currency/AmountFormatter', $namespaces, $module_handler, AmountFormatterInterface::class, CurrencyAmountFormatter::class);
$this->alterInfo('currency_amount_formatter');
$this->setCacheBackend($cache_backend, 'currency_amount_formatter');
$this->configFactory = $config_factory;
}
示例6: __construct
/**
* Constructs the FieldTypePluginManager object
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler.
* @param \Drupal\Core\TypedData\TypedDataManagerInterface $typed_data_manager
* The typed data manager.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, TypedDataManagerInterface $typed_data_manager)
{
parent::__construct('Plugin/Field/FieldType', $namespaces, $module_handler, 'Drupal\\Core\\Field\\FieldItemInterface', 'Drupal\\Core\\Field\\Annotation\\FieldType');
$this->alterInfo('field_info');
$this->setCacheBackend($cache_backend, 'field_types_plugins');
$this->typedDataManager = $typed_data_manager;
}
示例7: __construct
/**
* Constructs ResourcePluginManager.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \DrupalCacheInterface $cache_backend
* Cache backend instance to use.
* @param RequestInterface $request
* The request object.
*/
public function __construct(\Traversable $namespaces, \DrupalCacheInterface $cache_backend, RequestInterface $request)
{
parent::__construct('Plugin/resource', $namespaces, 'Drupal\\restful\\Plugin\\resource\\ResourceInterface', '\\Drupal\\restful\\Annotation\\Resource');
$this->setCacheBackend($cache_backend, 'resource_plugins');
$this->alterInfo('resource_plugin');
$this->request = $request;
}
示例8: __construct
/**
* Constructs a new \Drupal\block\BlockManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The translation manager.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, TranslationInterface $string_translation)
{
parent::__construct('Plugin/Block', $namespaces, $module_handler, 'Drupal\\block\\Annotation\\Block');
$this->alterInfo('block');
$this->setCacheBackend($cache_backend, 'block_plugins');
$this->stringTranslation = $string_translation;
}
示例9: __construct
/**
* Creates the discovery object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler)
{
// We replace the $subdir parameter with our own value.
// This tells the plugin system to look for plugins in the 'Plugin/Sandwich'
// subfolder inside modules' 'src' folder.
$subdir = 'Plugin/Sandwich';
// The name of the interface that plugins should adhere to. Drupal will
// enforce this as a requirement. If a plugin does not implement this
// interface, than Drupal will throw an error.
$plugin_interface = 'Drupal\\plugin_type_example\\SandwichInterface';
// The name of the annotation class that contains the plugin definition.
$plugin_definition_annotation_name = 'Drupal\\Component\\Annotation\\Plugin';
parent::__construct($subdir, $namespaces, $module_handler, $plugin_interface, $plugin_definition_annotation_name);
// This allows the plugin definitions to be altered by an alter hook. The
// parameter defines the name of the hook, thus: hook_sandwich_info_alter().
// In this example, we implement this hook to change the plugin definitions:
// see plugin_type_example_sandwich_info_alter().
$this->alterInfo('sandwich_info');
// This sets the caching method for our plugin definitions. Plugin
// definitions are cached using the provided cache backend. For our
// Sandwich plugin type, we've specified the @cache.default service be used
// in the plugin_type_example.services.yml file. The second argument is a
// cache key prefix. Out of the box Drupal with the default cache backend
// setup will store our plugin definition in the cache_default table using
// the sandwich_info key. All that is implementation details however,
// all we care about it that caching for our plugin definition is taken
// care of by this call.
$this->setCacheBackend($cache_backend, 'sandwich_info');
}
示例10: __construct
/**
* Overrides \Drupal\Component\Plugin\PluginManagerBase::__construct().
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler)
{
parent::__construct('Plugin/Validation/Constraint', $namespaces, $module_handler);
$this->discovery = new StaticDiscoveryDecorator($this->discovery, array($this, 'registerDefinitions'));
$this->alterInfo('validation_constraint');
$this->setCacheBackend($cache_backend, 'validation_constraint_plugins');
}
示例11: __construct
/**
* Constructs a CheckoutPaneManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations,
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler)
{
parent::__construct('Plugin/Ubercart/CheckoutPane', $namespaces, $module_handler, CheckoutPanePluginInterface::class, CheckoutPane::class);
$this->alterInfo('payment_method');
$this->setCacheBackend($cache_backend, 'uc_checkout_panes');
$this->paneConfig = \Drupal::config('uc_cart.settings')->get('panes');
}
示例12: __construct
/**
* Constructs the MailManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory)
{
parent::__construct('Plugin/Mail', $namespaces, $module_handler, 'Drupal\\Core\\Annotation\\Mail');
$this->alterInfo('mail_backend_info');
$this->setCacheBackend($cache_backend, 'mail_backend_plugins');
$this->mailConfig = $config_factory->get('system.mail');
}
示例13: __construct
/**
* Constructs a AggregatorPluginManager object.
*
* @param string $type
* The plugin type, for example fetcher.
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
*/
public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler)
{
$type_annotations = array('fetcher' => 'Drupal\\aggregator\\Annotation\\AggregatorFetcher', 'parser' => 'Drupal\\aggregator\\Annotation\\AggregatorParser', 'processor' => 'Drupal\\aggregator\\Annotation\\AggregatorProcessor');
$plugin_interfaces = array('fetcher' => 'Drupal\\aggregator\\Plugin\\FetcherInterface', 'parser' => 'Drupal\\aggregator\\Plugin\\ParserInterface', 'processor' => 'Drupal\\aggregator\\Plugin\\ProcessorInterface');
parent::__construct("Plugin/aggregator/{$type}", $namespaces, $module_handler, $plugin_interfaces[$type], $type_annotations[$type]);
$this->setCacheBackend($cache_backend, 'aggregator_' . $type . '_plugins');
}
示例14: __construct
/**
* Constructs the ImageToolkitOperationManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LoggerInterface $logger)
{
parent::__construct('Plugin/ImageToolkit/Operation', $namespaces, $module_handler, 'Drupal\\Core\\ImageToolkit\\ImageToolkitOperationInterface', 'Drupal\\Core\\ImageToolkit\\Annotation\\ImageToolkitOperation');
$this->alterInfo('image_toolkit_operation');
$this->setCacheBackend($cache_backend, 'image_toolkit_operation_plugins');
$this->logger = $logger;
}
示例15: __construct
/**
* Constructs a PanelsStorageManager.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
* @param \Drupal\Core\Session\AccountProxyInterface $current_user
* The current user service.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, AccountProxyInterface $current_user)
{
parent::__construct('Plugin/PanelsStorage', $namespaces, $module_handler, PanelsStorageInterface::class, PanelsStorage::class);
$this->currentUser = $current_user;
$this->alterInfo('panels_storage_info');
$this->setCacheBackend($cache_backend, 'panels_storage');
}