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

Issue #3164062 by paulocs: Fix all drupal code standard errors from specific files

parent 3df4fc00
......@@ -8,7 +8,9 @@
use Drupal\context\Plugin\ContextReaction\Blocks;
/**
* Update all blocks reaction configuration with additional "context_id" property.
* Update all blocks reactions.
*
* Add in the reaction configuration an additional "context_id" property.
*/
function context_update_8001() {
foreach (Drupal::service('context.manager')->getContexts() as $context) {
......@@ -28,7 +30,9 @@ function context_update_8001() {
}
/**
* Update all blocks reaction configuration with additional "css_class" property.
* Update all blocks reactions.
*
* Add in the reaction configuration an additional "css_class" property.
*/
function context_update_8002() {
$context_manager = \Drupal::service('context.manager');
......
......@@ -2,6 +2,7 @@
/**
* @file
* Defines Drupal hooks for context module.
*/
use Drupal\Core\Render\Markup;
......@@ -32,10 +33,10 @@ function context_help($route_name, RouteMatchInterface $route_match) {
}
/**
* Implements hook_preprocess_HOOK().
*
* Run the body class context reactions if there are any and let them add
* classes to the page body.
*
* Implements hook_preprocess_HOOK().
*/
function context_preprocess_html(&$variables) {
/** @var \Drupal\context\ContextManager $context_manager */
......
......@@ -6,7 +6,7 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Entity\EntityWithPluginCollectionInterface;
/**
*
* Provides an interface for Context.
*/
interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollectionInterface {
......@@ -19,6 +19,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Get the ID of the context.
*
* @return string
* The the ID of the context.
*/
public function id();
......@@ -26,6 +27,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Get the machine name of the context.
*
* @return string
* The machine name of the context.
*/
public function getName();
......@@ -33,8 +35,10 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Set the machine name of the context.
*
* @param string $name
* The new name to set.
*
* @return $this
* This Context object.
*/
public function setName($name);
......@@ -42,6 +46,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Get the context label.
*
* @return string
* The context label.
*/
public function getLabel();
......@@ -49,8 +54,10 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Set the context label.
*
* @param string $label
* The new context label to set.
*
* @return $this
* This Context object.
*/
public function setLabel($label);
......@@ -58,6 +65,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Get the context description.
*
* @return string
* The context description.
*/
public function getDescription();
......@@ -65,8 +73,10 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Set the context description.
*
* @param string $description
* The new description to set.
*
* @return $this
* This Context object.
*/
public function setDescription($description);
......@@ -74,6 +84,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Get the group this context belongs to.
*
* @return null|string
* The name of the group.
*/
public function getGroup();
......@@ -81,8 +92,10 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Set the group this context should belong to.
*
* @param null|string $group
* The name of the group to set.
*
* @return $this
* This Context object.
*/
public function setGroup($group);
......@@ -90,6 +103,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Get the weight for this context.
*
* @return int
* The weight.
*/
public function getWeight();
......@@ -100,6 +114,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* The weight to set for this context.
*
* @return $this
* This Context object.
*/
public function setWeight($weight);
......@@ -107,6 +122,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* If the context requires all conditions to validate.
*
* @return bool
* TRUE if all conditions are required, FALSE if not.
*/
public function requiresAllConditions();
......@@ -117,6 +133,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* If a condition is required or not.
*
* @return $this
* This Context object.
*/
public function setRequireAllConditions($require);
......@@ -124,6 +141,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Get a list of all conditions.
*
* @return \Drupal\Core\Condition\ConditionInterface[]|ConditionPluginCollection
* The plugin collection.
*/
public function getConditions();
......@@ -134,6 +152,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* The condition to get.
*
* @return \Drupal\Core\Condition\ConditionInterface
* The specific Condition.
*/
public function getCondition($condition_id);
......@@ -144,6 +163,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* The configuration for the condition plugin.
*
* @return string
* The inserted condition ID.
*/
public function addCondition(array $configuration);
......@@ -154,6 +174,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* The id of the condition to remove.
*
* @return $this
* This Context object.
*/
public function removeCondition($condition_id);
......@@ -164,6 +185,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* The ID of the condition to check for.
*
* @return bool
* TRUE if the context has the specified condition, FALSE if not.
*/
public function hasCondition($condition_id);
......@@ -171,6 +193,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Get a list of all the reactions.
*
* @return ContextReactionInterface[]|ContextReactionPluginCollection
* A reaction list.
*/
public function getReactions();
......@@ -181,6 +204,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* The ID of the reaction to get.
*
* @return ContextReactionInterface
* A specific reaction.
*/
public function getReaction($reaction_id);
......@@ -188,8 +212,10 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* Add a context reaction.
*
* @param array $configuration
* The reaction configuration array.
*
* @return string
* The inserted reaction ID.
*/
public function addReaction(array $configuration);
......@@ -200,6 +226,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* The id of the reaction to remove.
*
* @return $this
* This context object.
*/
public function removeReaction($reaction_id);
......@@ -210,6 +237,7 @@ interface ContextInterface extends ConfigEntityInterface, EntityWithPluginCollec
* The ID of the reaction to check for.
*
* @return bool
* TRUE if the context has the specified reaction, FALSE if not.
*/
public function hasReaction($reaction_id);
......
......@@ -16,8 +16,9 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Theme\ThemeManagerInterface;
/**
* This is the manager service for the context module and should not be
* confused with the built in contexts in Drupal.
* This is the manager service for the context module.
*
* It should not be confused with the built in contexts in Drupal.
*/
class ContextManager {
......@@ -25,21 +26,29 @@ class ContextManager {
use StringTranslationTrait;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The context repository service.
*
* @var \Drupal\Core\Plugin\Context\ContextRepositoryInterface
*/
protected $contextRepository;
/**
* Wraps the context handler.
*
* @var \Drupal\Core\Plugin\Context\ContextHandlerInterface
*/
protected $contextHandler;
/**
* The context conditions evaluate.
*
* If the context conditions has been evaluated then this is set to TRUE
* otherwise FALSE.
*
......@@ -53,12 +62,17 @@ class ContextManager {
* @var array
*/
protected $activeContexts = [];
/**
* The entity form builder.
*
* @var \Drupal\Core\Entity\EntityFormBuilderInterface
*/
private $entityFormBuilder;
/**
* The theme manager.
*
* @var \Drupal\Core\Theme\ThemeManagerInterface
*/
protected $themeManager;
......@@ -72,10 +86,10 @@ class ContextManager {
* The drupal context repository service.
* @param \Drupal\context\Entity\ContextHandlerInterface $contextHandler
* The Drupal context handler service.
* @param \Drupal\Core\Theme\ThemeManagerInterface $themeManager
* The Drupal theme manager service.
* @param \Drupal\Core\Entity\EntityFormBuilderInterface $entityFormBuilder
* The Drupal EntityFormBuilder service.
* @param \Drupal\Core\Theme\ThemeManagerInterface $themeManager
* The Drupal theme manager service.
*/
public function __construct(
EntityTypeManagerInterface $entityTypeManager,
......@@ -95,6 +109,7 @@ class ContextManager {
* Get all contexts.
*
* @return \Drupal\context\Entity\Context[]
* An array with the context entity.
*/
public function getContexts() {
......@@ -107,10 +122,12 @@ class ContextManager {
}
/**
* Get all contexts sorted by their group and sorted by their weight inside
* of each group.
* Get all contexts sorted by their group.
*
* It also sort the contexts by their weight inside of each group.
*
* @return array
* An array with all contexts by group.
*/
public function getContextsByGroup() {
$contexts = $this->getContexts();
......@@ -138,6 +155,7 @@ class ContextManager {
* The machine name of the context to validate.
*
* @return bool
* TRUE on context name already exist, FALSE on context name not exist.
*/
public function contextExists($name) {
$entity = $this->entityTypeManager->getStorage('context')->loadByProperties(['name' => $name]);
......@@ -149,6 +167,7 @@ class ContextManager {
* Check to see if context conditions has been evaluated.
*
* @return bool
* TRUE if context was already evaluated, FALSE if context was not.
*/
public function conditionsHasBeenEvaluated() {
return $this->contextConditionsEvaluated;
......@@ -158,6 +177,7 @@ class ContextManager {
* Get the evaluated and active contexts.
*
* @return \Drupal\context\ContextInterface[]
* An array with the evaluated and active contexts.
*/
public function getActiveContexts() {
if ($this->conditionsHasBeenEvaluated()) {
......@@ -191,6 +211,7 @@ class ContextManager {
* Either the reaction class name or the id of the reaction type to get.
*
* @return \Drupal\context\Entity\ContextReactionInterface[]
* An array with all active reactions or reactions of a certain type.
*/
public function getActiveReactions($reactionType = NULL) {
$reactions = [];
......@@ -201,7 +222,8 @@ class ContextManager {
// continue to the next context.
if (is_null($reactionType)) {
foreach ($context->getReactions() as $reaction) {
// Only return block reaction if there is a block applied to the current theme.
// Only return block reaction if there is a block applied to
// the current theme.
if ($reaction instanceof Blocks) {
$blocks = $reaction->getBlocks();
$current_theme = $this->getCurrentTheme();
......@@ -246,6 +268,7 @@ class ContextManager {
* The context to evaluate conditions for.
*
* @return bool
* Whether these conditions grant or deny access.
*/
public function evaluateContextConditions(ContextInterface $context) {
$conditions = $context->getConditions();
......@@ -278,6 +301,8 @@ class ContextManager {
* A collection of conditions to apply context to.
*
* @return bool
* TRUE if context was applied and FALSE if context
* is provided but has no value.
*/
protected function applyContexts(ConditionPluginCollection &$conditions) {
......@@ -300,10 +325,14 @@ class ContextManager {
* Get a rendered form for the context.
*
* @param \Drupal\context\ContextInterface $context
* The entity to be created or edited.
* @param string $formType
* The operation identifying the form variation to be returned.
* @param array $form_state_additions
* An associative array used to build the current state of the form.
*
* @return array
* The processed form for the given entity and operation.
*/
public function getForm(ContextInterface $context, $formType = 'edit', array $form_state_additions = []) {
return $this->entityFormBuilder->getForm($context, $formType, $form_state_additions);
......@@ -316,7 +345,6 @@ class ContextManager {
*
* @param \Drupal\context\Entity\ContextInterface $a
* First item for comparison.
*
* @param \Drupal\context\Entity\ContextInterface $b
* Second item for comparison.
*
......
......@@ -14,6 +14,8 @@ use Drupal\Core\Routing\RouteMatchInterface;
class ContextMenuActiveTrail extends MenuActiveTrail {
/**
* The Context module context manager.
*
* @var \Drupal\context\ContextManager
*/
protected $contextManager;
......
......@@ -8,7 +8,7 @@ use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Core\Plugin\PluginFormInterface;
/**
*
* Provides an interface for ContextReaction.
*/
interface ContextReactionInterface extends ConfigurableInterface, PluginFormInterface, PluginInspectionInterface, ExecutableInterface {
......@@ -16,6 +16,7 @@ interface ContextReactionInterface extends ConfigurableInterface, PluginFormInte
* Get the unique ID of this context reaction.
*
* @return string|null
* The Reaction id or null if reaction was not found.
*/
public function getId();
......@@ -23,6 +24,7 @@ interface ContextReactionInterface extends ConfigurableInterface, PluginFormInte
* Provides a human readable summary of the condition's configuration.
*
* @return \Drupal\Core\StringTranslation\TranslatableMarkup
* An object that, when cast to a string, returns the translated string.
*/
public function summary();
......
......@@ -7,7 +7,7 @@ use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
/**
*
* Provides a manager for Context Reactions.
*/
class ContextReactionManager extends DefaultPluginManager {
......
......@@ -6,7 +6,7 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginBase;
/**
*
* Provides a plugin base for Context Reactions.
*/
abstract class ContextReactionPluginBase extends PluginBase implements ContextReactionInterface {
......
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