Commit c2a65d51 authored by paulocs's avatar paulocs Committed by paulocs

Issue #3163061 by paulocs: Fix drupal code standard errors in context/src/Plugin

parent 48649419
......@@ -22,18 +22,36 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class ViewInclusion extends ConditionPluginBase implements ContainerFactoryPluginInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
private $entityTypeManager;
/**
* The current route match.
*
* @var \Drupal\Core\Routing\CurrentRouteMatch
*/
private $currentRouteMatch;
/**
* View constructor.
*
* @param array $configuration
* @param $plugin_id
* @param $plugin_definition
* The plugin configuration, i.e. an array with configuration values keyed
* by configuration option name. The special key 'context' may be used to
* initialize the defined contexts by setting it to an array of context
* values keyed by context names.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* @param \Drupal\Core\Routing\CurrentRouteMatch
* The entity type manager.
* @param \Drupal\Core\Routing\CurrentRouteMatch $currentRouteMatch
* The current route match service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entityTypeManager, CurrentRouteMatch $currentRouteMatch) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
......@@ -42,12 +60,7 @@ class ViewInclusion extends ConditionPluginBase implements ContainerFactoryPlugi
}
/**
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* @param array $configuration
* @param string $plugin_id
* @param mixed $plugin_definition
*
* @return static
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
......@@ -60,10 +73,7 @@ class ViewInclusion extends ConditionPluginBase implements ContainerFactoryPlugi
}
/**
* @param array $form
* @param \Drupal\Core\Form\FormStateInterface $form_state
*
* @return array
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
......@@ -92,8 +102,7 @@ class ViewInclusion extends ConditionPluginBase implements ContainerFactoryPlugi
}
/**
* @param array $form
* @param \Drupal\Core\Form\FormStateInterface $form_state
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['view_inclusion'] = array_filter($form_state->getValue('views_pages'));
......@@ -101,18 +110,14 @@ class ViewInclusion extends ConditionPluginBase implements ContainerFactoryPlugi
}
/**
* @return \Drupal\Core\StringTranslation\TranslatableMarkup
* {@inheritdoc}
*/
public function summary() {
return t('Select views pages');
}
/**
* Evaluate the view inclusion condition.
*
* @return bool
* Return true if condition are empty, so access check passes or return the
* condition.
* {@inheritdoc}
*/
public function evaluate() {
$route = str_replace('.', '-', $this->currentRouteMatch->getRouteName());
......
......@@ -31,8 +31,9 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Security\TrustedCallbackInterface;
/**
* Provides a content reaction that will let you place blocks in the current
* themes regions.
* Provides a content reaction.
*
* It will let you place blocks in the current themes regions.
*
* @ContextReaction(
* id = "blocks",
......@@ -69,36 +70,50 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
protected $uuid;
/**
* The theme manager.
*
* @var \Drupal\Core\Theme\ThemeManagerInterface
*/
protected $themeManager;
/**
* The handler of the available themes.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected $themeHandler;
/**
* The Drupal context repository.
*
* @var \Drupal\Core\Plugin\Context\ContextRepositoryInterface
*/
protected $contextRepository;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The plugin context handler.
*
* @var \Drupal\Core\Plugin\Context\ContextHandlerInterface
*/
protected $contextHandler;
/**
* The current account.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $account;
/**
* The block manager.
*
* @var \Drupal\Core\Block\BlockManager
*/
protected $blockManager;
......@@ -155,14 +170,13 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
*
* @param array $build
* The current build of the page.
*
* @param string|null $title
* The page title.
*
* @param string|null $main_content
* The main page content.
*
* @return array
* Blocks that will be built.
*/
public function execute(array $build = [], $title = NULL, $main_content = NULL) {
......@@ -300,10 +314,12 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
* Renders the content using the provided block plugin.
*
* @param array $build
* The block to be rendered.
*
* @return array
* The block already rendered.
*/
public function preRenderBlock($build) {
public function preRenderBlock(array $build) {
$content = $build['#block_plugin']->build();
......@@ -378,6 +394,7 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
* Get all blocks as a collection.
*
* @return \Drupal\Core\Block\BlockPluginInterface[]|BlockCollection
* The collection of blocks.
*/
public function getBlocks() {
if (!$this->blocksCollection) {
......@@ -394,6 +411,7 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
* The ID of the block to get.
*
* @return \Drupal\Core\Block\BlockPluginInterface
* The specified block plugin.
*/
public function getBlock($blockId) {
return $this->getBlocks()->get($blockId);
......@@ -403,6 +421,10 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
* Add a new block.
*
* @param array $configuration
* The configuration from the block.
*
* @return string
* The uuid from the block.
*/
public function addBlock(array $configuration) {
$configuration['uuid'] = $this->uuid->generate();
......@@ -417,11 +439,11 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
*
* @param string $blockId
* The ID of the block to update.
*
* @param $configuration
* @param array $configuration
* The updated configuration for the block.
*
* @return $this
* @return Drupal\context\Plugin\ContextReaction
* This object.
*/
public function updateBlock($blockId, array $configuration) {
$existingConfiguration = $this->getBlock($blockId)->getConfiguration();
......@@ -432,8 +454,13 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
}
/**
* @param $blockId
* @return $this
* Remove block.
*
* @param string $blockId
* Block id to removed.
*
* @return Drupal\context\Plugin\ContextReaction
* This object.
*/
public function removeBlock($blockId) {
$this->getBlocks()->removeInstanceId($blockId);
......@@ -572,7 +599,11 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
$form['blocks']['blocks']['region-' . $region . '-message'] = [
'#attributes' => [
'class' => ['region-message', 'region-' . $region . '-message', $regionEmptyClass],
'class' => [
'region-message',
'region-' . $region . '-message',
$regionEmptyClass,
],
],
'message' => [
'#markup' => '<em>' . $this->t('No blocks in this region') . '</em>',
......@@ -660,8 +691,10 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
* Check to see if the block should be uniquely placed.
*
* @param \Drupal\Core\Block\BlockPluginInterface $block
* The block plugin.
*
* @return bool
* TRUE if block should be placed uniquely, FALSE if not.
*/
private function blockShouldBePlacedUniquely(BlockPluginInterface $block) {
$configuration = $block->getConfiguration();
......@@ -701,6 +734,7 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
* Should reaction include default blocks from Block layout.
*
* @return bool
* TRUE if default blocks will be included, FALSE if not.
*/
public function includeDefaultBlocks() {
$config = $this->getConfiguration();
......@@ -712,11 +746,11 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
*
* @param string $theme
* The theme to get a list of regions for.
*
* @param string $show
* What type of regions that should be returned, defaults to all regions.
*
* @return array
* An array of available regions from a specified theme.
*
* @todo This could be moved to a service since we use it in a couple of places.
*/
......
......@@ -19,6 +19,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class Menu extends ContextReactionPluginBase implements ContainerFactoryPluginInterface {
/**
* The menu parent form selector service.
*
* @var \Drupal\Core\Menu\MenuParentFormSelector
*/
protected $menuParentFormSelector;
......
......@@ -28,11 +28,15 @@ class Regions extends ContextReactionPluginBase implements ContainerFactoryPlugi
protected $regions = [];
/**
* The theme manager.
*
* @var \Drupal\Core\Theme\ThemeManagerInterface
*/
protected $themeManager;
/**
* The handler of the available themes.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected $themeHandler;
......@@ -149,11 +153,11 @@ class Regions extends ContextReactionPluginBase implements ContainerFactoryPlugi
*
* @param string $theme
* The theme to get a list of regions for.
*
* @param string $show
* What type of regions that should be returned, defaults to all regions.
*
* @return array
* The list of available regions from a specified theme.
*
* @todo This could be moved to a service since we use it in a couple of places.
*/
......
......@@ -20,11 +20,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class Theme extends ContextReactionPluginBase implements ContainerFactoryPluginInterface {
/**
* The theme manager.
*
* @var \Drupal\Core\Theme\ThemeManagerInterface
*/
protected $themeManager;
/**
* The handler of the available themes.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected $themeHandler;
......
......@@ -5,14 +5,12 @@ namespace Drupal\context\Plugin;
use Drupal\Core\Plugin\DefaultLazyPluginCollection;
/**
*
* Provide a class to get a plugin instance.
*/
class ContextReactionPluginCollection extends DefaultLazyPluginCollection {
/**
* {@inheritdoc}
*
* @return \Drupal\context\ContextReactionInterface
*/
public function &get($instance_id) {
return parent::get($instance_id);
......
......@@ -24,6 +24,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class ContextBlockPageVariant extends VariantBase implements PageVariantInterface, ContainerFactoryPluginInterface {
/**
* The Context module context manager.
*
* @var \Drupal\context\ContextManager
*/
protected $contextManager;
......@@ -43,6 +45,8 @@ class ContextBlockPageVariant extends VariantBase implements PageVariantInterfac
protected $title = '';
/**
* The display variant plugin manager.
*
* @var \Drupal\Core\Display\VariantManager
*/
protected $displayVariant;
......@@ -52,16 +56,12 @@ class ContextBlockPageVariant extends VariantBase implements PageVariantInterfac
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
*
* @param string $plugin_id
* The plugin ID for the plugin instance.
*
* @param mixed $plugin_definition
* The plugin implementation definition.
*
* @param \Drupal\context\ContextManager $contextManager
* The context module manager.
*
* @param \Drupal\Core\Display\VariantManager $displayVariant
* The variant manager.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment