class DefaultPattern in Panels 8.3
Same name and namespace in other branches
- 8.4 src/Plugin/PanelsPattern/DefaultPattern.php \Drupal\panels\Plugin\PanelsPattern\DefaultPattern
Plugin annotation
@PanelsPattern("default");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\panels\Plugin\PanelsPattern\DefaultPattern implements ContainerFactoryPluginInterface, PanelsPatternInterface uses CachedValuesGetterTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of DefaultPattern
File
- src/
Plugin/ PanelsPattern/ DefaultPattern.php, line 20
Namespace
Drupal\panels\Plugin\PanelsPatternView source
class DefaultPattern extends PluginBase implements PanelsPatternInterface, ContainerFactoryPluginInterface {
use CachedValuesGetterTrait;
/**
* The context mapper.
*
* @var \Drupal\ctools\ContextMapperInterface
*/
protected $contextMapper;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('ctools.context_mapper'));
}
/**
* DefaultPattern constructor.
*
* @param array $configuration
* The plugin's configuration.
* @param string $plugin_id
* The plugin id.
* @param mixed $plugin_definition
* The plugin definition.
* @param \Drupal\ctools\ContextMapperInterface $context_mapper
* The context mapper.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, ContextMapperInterface $context_mapper) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->contextMapper = $context_mapper;
}
/**
* {@inheritdoc}
*/
public function getMachineName($cached_values) {
// PageManager needs special handling, so lets see if we're dealing with a PM page.
if (isset($cached_values['page_variant'])) {
return implode('--', [
$cached_values['id'],
$cached_values['page_variant']
->id(),
]);
}
return $cached_values['id'];
}
/**
* {@inheritdoc}
*/
public function getDefaultContexts(SharedTempStoreFactory $tempstore, $tempstore_id, $machine_name) {
$cached_values = $this
->getCachedValues($tempstore, $tempstore_id, $machine_name);
// PageManager specific context loading.
if (!empty($cached_values['page_variant'])) {
/** @var \Drupal\page_manager\PageVariantInterface $page_variant */
$page_variant = $cached_values['page_variant'];
return $page_variant
->getContexts();
}
// General handling for contexts.
return !empty($cached_values['contexts']) ? $this->contextMapper
->getContextValues($cached_values['contexts']) : [];
}
/**
* {@inheritdoc}
*/
public function getBlockListUrl($tempstore_id, $machine_name, $region = NULL, $destination = NULL) {
return Url::fromRoute('panels.select_block', [
'tempstore_id' => $tempstore_id,
'machine_name' => $machine_name,
'region' => $region,
'destination' => $destination,
]);
}
/**
* {@inheritdoc}
*/
public function getBlockAddUrl($tempstore_id, $machine_name, $block_id, $region = NULL, $destination = NULL) {
return Url::fromRoute('panels.add_block', [
'tempstore_id' => $tempstore_id,
'machine_name' => $machine_name,
'block_id' => $block_id,
'region' => $region,
'destination' => $destination,
]);
}
/**
* {@inheritdoc}
*/
public function getBlockEditUrl($tempstore_id, $machine_name, $block_id, $destination = NULL) {
return Url::fromRoute('panels.edit_block', [
'tempstore_id' => $tempstore_id,
'machine_name' => $machine_name,
'block_id' => $block_id,
'destination' => $destination,
]);
}
/**
* {@inheritdoc}
*/
public function getBlockDeleteUrl($tempstore_id, $machine_name, $block_id, $destination = NULL) {
return Url::fromRoute('panels.delete_block', [
'tempstore_id' => $tempstore_id,
'machine_name' => $machine_name,
'block_id' => $block_id,
'destination' => $destination,
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CachedValuesGetterTrait:: |
protected | function | Gets cached values for non-wizard classes that interact with a wizard. | |
DefaultPattern:: |
protected | property | The context mapper. | |
DefaultPattern:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
DefaultPattern:: |
public | function |
Gets the block add url. Overrides PanelsPatternInterface:: |
|
DefaultPattern:: |
public | function |
Gets the block delete url. Overrides PanelsPatternInterface:: |
|
DefaultPattern:: |
public | function |
Gets the block edit url. Overrides PanelsPatternInterface:: |
|
DefaultPattern:: |
public | function |
Gets the block list url. Overrides PanelsPatternInterface:: |
|
DefaultPattern:: |
public | function |
Gets the array of default contexts for this panels pattern. Overrides PanelsPatternInterface:: |
|
DefaultPattern:: |
public | function |
Gets the tempstore key identifier. Overrides PanelsPatternInterface:: |
|
DefaultPattern:: |
public | function |
DefaultPattern constructor. Overrides PluginBase:: |
|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |