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

Issue #3164065 by paulocs: Fix all drupal code standard errors from context/modules/context_ui

parent c3ba108d
......@@ -2,24 +2,25 @@
/**
* @file
* Defines Drupal hooks for context_ui module.
*/
/**
*
* Implements hook_entity_insert().
*/
function context_ui_context_insert($entity) {
Drupal::service('context_ui.menu_builder')->addSubMenuItem($entity);
}
/**
*
* Implements hook_entity_update().
*/
function context_ui_context_update($entity) {
Drupal::service('context_ui.menu_builder')->updateSubMenuItem($entity);
}
/**
*
* Implements hook_entity_delete().
*/
function context_ui_context_delete($entity) {
Drupal::service('context_ui.menu_builder')->deleteSubMenuItem($entity);
......
......@@ -16,7 +16,7 @@ use Drupal\Core\Messenger\MessengerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
*
* Provides a class to crate the Context List.
*/
class ContextListBuilder extends ConfigEntityListBuilder implements FormInterface {
......@@ -30,6 +30,8 @@ class ContextListBuilder extends ConfigEntityListBuilder implements FormInterfac
protected $contextManager;
/**
* The form builder.
*
* @var \Drupal\Core\Form\FormBuilderInterface
*/
protected $formBuilder;
......@@ -46,16 +48,12 @@ class ContextListBuilder extends ConfigEntityListBuilder implements FormInterfac
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
*
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The entity storage class.
*
* @param \Drupal\context\ContextManager $contextManager
* The Context module context manager.
*
* @param \Drupal\Core\Form\FormBuilderInterface $formBuilder
* The Drupal form builder.
*
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/
......
......@@ -20,7 +20,7 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
*
* Provides the Context UI Controller.
*/
class ContextUIController extends ControllerBase {
......@@ -50,10 +50,8 @@ class ContextUIController extends ControllerBase {
*
* @param \Drupal\context\ContextManager $contextManager
* The Context module context manager.
*
* @param \Drupal\context\ContextReactionManager $contextReactionManager
* The Context module context reaction plugin manager.
*
* @param \Drupal\Core\Condition\ConditionManager $conditionManager
* The Drupal core condition manager.
*/
......@@ -118,6 +116,7 @@ class ContextUIController extends ControllerBase {
* The context to display available conditions for.
*
* @return array
* An array with the build information.
*/
public function listConditions(ContextInterface $context) {
......@@ -193,6 +192,7 @@ class ContextUIController extends ControllerBase {
* The context to display available.
*
* @return array
* An array with the build information.
*/
public function listReactions(ContextInterface $context) {
......@@ -266,14 +266,13 @@ class ContextUIController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @param \Drupal\context\ContextInterface $context
* The context to add the reaction to.
*
* @param $reaction_id
* @param string $reaction_id
* The ID of the reaction to add.
*
* @return \Drupal\Core\Ajax\AjaxResponse|RedirectResponse
* An AJAX response or a redirect response.
*/
public function addReaction(Request $request, ContextInterface $context, $reaction_id) {
......@@ -289,8 +288,10 @@ class ContextUIController extends ControllerBase {
throw new HttpException(400, $e->getMessage());
}
// If one of the condition is "Current theme", prevent adding Theme reaction.
// Else this will cause an infinite loop when checking for active contexts.
// If one of the condition is "Current theme",
// prevent adding Theme reaction.
// Else this will cause an infinite loop
// when checking for active contexts.
if ($reaction_id == 'theme') {
$conditions = $context->getConditions();
foreach ($conditions as $condition) {
......@@ -332,14 +333,13 @@ class ContextUIController extends ControllerBase {
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @param \Drupal\context\ContextInterface $context
* The context to add the condition to.
*
* @param $condition_id
* @param string $condition_id
* The ID of the condition to add.
*
* @return \Drupal\Core\Ajax\AjaxResponse|RedirectResponse
* An AJAX response or A redirect response.
*/
public function addCondition(Request $request, ContextInterface $context, $condition_id) {
......@@ -355,7 +355,8 @@ class ContextUIController extends ControllerBase {
throw new HttpException(400, $e->getMessage());
}
// Prevent adding "Current theme" condition, if "Theme" reaction is already set.
// Prevent adding "Current theme" condition,
// if "Theme" reaction is already set.
// Else this will cause an infinite loop when checking for active contexts.
if ($condition_id == 'current_theme') {
$reactions = $context->getReactions();
......
......@@ -12,7 +12,7 @@ use Drupal\Core\Ajax\CloseModalDialogCommand;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
*
* Provides a Condition delete form.
*/
class ConditionDeleteForm extends ConfirmFormBase {
......@@ -41,6 +41,7 @@ class ConditionDeleteForm extends ConfirmFormBase {
* Construct a condition delete form.
*
* @param \Drupal\context\ContextManager $contextManager
* The Context module context manager.
*/
public function __construct(ContextManager $contextManager) {
$this->contextManager = $contextManager;
......@@ -131,6 +132,7 @@ class ConditionDeleteForm extends ConfirmFormBase {
* Handle when the form is submitted trough AJAX.
*
* @return \Drupal\Core\Ajax\AjaxResponse
* An AJAX response.
*/
public function submitFormAjax() {
$contextForm = $this->contextManager->getForm($this->context, 'edit');
......
......@@ -5,7 +5,7 @@ namespace Drupal\context_ui\Form;
use Drupal\Core\Form\FormStateInterface;
/**
*
* Provides a form to add a context.
*/
class ContextAddForm extends ContextFormBase {
......
......@@ -9,17 +9,22 @@ use Drupal\Core\Entity\EntityConfirmFormBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
*
* Provides a form to delete a context.
*/
class ContextDeleteForm extends EntityConfirmFormBase {
/**
* The Context module context manager.
*
* @var \Drupal\context\ContextManager
*/
protected $contextManager;
/**
* ContextDeleteForm constructor.
*
* @param \Drupal\context\ContextManager $contextManager
* The Context module context manager.
*/
public function __construct(ContextManager $contextManager) {
$this->contextManager = $contextManager;
......
......@@ -9,17 +9,22 @@ use Drupal\Core\Entity\EntityConfirmFormBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
*
* Provides a form to disable a context.
*/
class ContextDisableForm extends EntityConfirmFormBase {
/**
* The Context module context manager.
*
* @var \Drupal\context\ContextManager
*/
protected $contextManager;
/**
* The ContextDisableForm constructor.
*
* @param \Drupal\context\ContextManager $contextManager
* The Context module context manager.
*/
public function __construct(ContextManager $contextManager) {
$this->contextManager = $contextManager;
......
......@@ -9,7 +9,7 @@ use Drupal\Component\Serialization\Json;
use Drupal\Core\Form\FormStateInterface;
/**
*
* Provides a form to edit context.
*/
class ContextEditForm extends ContextFormBase {
......@@ -75,15 +75,15 @@ class ContextEditForm extends ContextFormBase {
/**
* Process function for the conditions.
*
* @param $element
* @param array $element
* The element to process.
*
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current form state.
*
* @return array
* An array with the condition element.
*/
public function processConditions(&$element, FormStateInterface $form_state) {
public function processConditions(array &$element, FormStateInterface $form_state) {
$conditions = $this->entity->getConditions();
$element['add_condition'] = [
......@@ -150,15 +150,15 @@ class ContextEditForm extends ContextFormBase {
/**
* Process function for the reactions.
*
* @param $element
* @param array $element
* The element to process.
*
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current form state.
*
* @return array
* An array with the reaction element.
*/
public function processReactions(&$element, FormStateInterface $form_state) {
public function processReactions(array &$element, FormStateInterface $form_state) {
$reactions = $this->entity->getReactions();
$element['add_reaction'] = [
......
......@@ -12,7 +12,7 @@ use Drupal\Core\Plugin\Context\ContextRepositoryInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
*
* Provides a context form base.
*/
abstract class ContextFormBase extends EntityForm {
......@@ -41,7 +41,9 @@ abstract class ContextFormBase extends EntityForm {
* Construct a new context form.
*
* @param \Drupal\context\ContextManager $contextManager
* The Context module context manager.
* @param \Drupal\context\Entity\ContextRepositoryInterface $contextRepository
* The Drupal context repository.
*/
public function __construct(ContextManager $contextManager, ContextRepositoryInterface $contextRepository) {
$this->contextManager = $contextManager;
......@@ -145,7 +147,6 @@ abstract class ContextFormBase extends EntityForm {
*
* @param array $form
* The rendered form.
*
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current form state.
*/
......@@ -173,7 +174,6 @@ abstract class ContextFormBase extends EntityForm {
*
* @param array $form
* The rendered form.
*
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current form state.
*/
......@@ -195,7 +195,6 @@ abstract class ContextFormBase extends EntityForm {
*
* @param array $form
* The rendered form.
*
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current form state.
*/
......@@ -242,6 +241,7 @@ abstract class ContextFormBase extends EntityForm {
* The machine name to check for.
*
* @return bool
* TRUE if context exists. FALSE if context doesn't exist.
*/
public function contextExists($name) {
return $this->contextManager->contextExists($name);
......
......@@ -13,16 +13,20 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
/**
*
* Provides a context reaction delete form.
*/
class ReactionDeleteForm extends ConfirmFormBase implements ContainerInjectionInterface {
/**
* The Context module context manager.
*
* @var \Drupal\context\ContextInterface
*/
protected $context;
/**
* The context reaction.
*
* @var \Drupal\context\ContextReactionInterface
*/
protected $reaction;
......@@ -38,6 +42,7 @@ class ReactionDeleteForm extends ConfirmFormBase implements ContainerInjectionIn
* Construct.
*
* @param \Drupal\context\ContextManager $contextManager
* The Context module context manager.
*/
public function __construct(ContextManager $contextManager) {
$this->contextManager = $contextManager;
......@@ -132,6 +137,7 @@ class ReactionDeleteForm extends ConfirmFormBase implements ContainerInjectionIn
* Handle when the form is submitted through AJAX.
*
* @return \Drupal\Core\Ajax\AjaxResponse
* An AJAX response.
*/
public function submitFormAjax() {
$response = new AjaxResponse();
......
......@@ -8,15 +8,18 @@ use Drupal\Core\Url;
use Drupal\menu_link_content\Entity\MenuLinkContent;
/**
* Implements the MenuBuilder class, which configures and updates the submenu
* context items.
* Implements the MenuBuilder class.
*
* MenuBuilder configures and updates the submenu context items.
*
* @package Drupal\context_ui
*/
class MenuBuilder {
/**
* @var \Drupal\Core\Menu\MenuLinkManagerInterfaceStoresthemenuLinkManagerinterface
* The menu link plugin manager.
*
* @var \Drupal\Core\Menu\MenuLinkManagerInterface
*/
protected $menuLinkManager;
......@@ -24,17 +27,14 @@ class MenuBuilder {
* MenuBuilder constructor.
*
* @param \Drupal\Core\Menu\MenuLinkManagerInterface $menuLinkManager
* The menu link plugin manager.
*/
public function __construct(MenuLinkManagerInterface $menuLinkManager) {
$this->menuLinkManager = $menuLinkManager;
}
/**
* Create function.
*
* @param \Drupal\context_ui\ContainerInterface $container
*
* @return static
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
......@@ -111,7 +111,8 @@ class MenuBuilder {
* @param \Drupal\context\Entity\Context $entity
* The context entity.
*
* @return string The URI string.
* @return string
* The URI string.
*/
private function getUriString(Context $entity) {
$url = Url::fromRoute('entity.context.edit_form', ['context' => $entity->id()]);
......
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