Commit 88d191a1 authored by deepakkumar14's avatar deepakkumar14 Committed by boshtian

Issue #2961320 by deepakkumar14, Ronak.addweb: Convert module to use short...

Issue #2961320 by deepakkumar14, Ronak.addweb: Convert module to use short array syntax (new coding standard)
parent fda16e09
......@@ -18,7 +18,7 @@ function context_help($route_name, RouteMatchInterface $route_match) {
$output .= '<dt>' . t('Managing context') . '</dt>';
$output .= '<dd>' . t('Users with <em>Administer contexts</em> permission can add contextual conditions and reactions for different portions of their site. For each context, they can choose the conditions that trigger this context to be active and choose different aspects of their site that should react to this active context.') . '</dd>';
$output .= '<dt>' . t('Adding new custom reactions') . '</dt>';
$output .= '<dd>' . t('Reactions for the context module are defined trough the new <a href=":link">Drupal 8 Plugin API</a>.', array(':link' =>'https://www.drupal.org/developing/api/8/plugins')) . '</dd>';
$output .= '<dd>' . t('Reactions for the context module are defined trough the new <a href=":link">Drupal 8 Plugin API</a>.', [':link' =>'https://www.drupal.org/developing/api/8/plugins']) . '</dd>';
$output .= '<dd>' . t('The Context module defines a plugin type named ContextReaction that users can extend when creating their own plugins.') . '</dd>';
$output .= '<dd>' . t('A context reaction requires a configuration form and execute method. The execution of the plugin is also something that will have to be handled by the author of the reaction.') . '</dd>';
$output .= '</dl>';
......
......@@ -92,20 +92,20 @@ class ContextListBuilder extends ConfigEntityListBuilder implements FormInterfac
public function buildForm(array $form, FormStateInterface $form_state) {
$groups = $this->contextManager->getContextsByGroup();
$form['contexts'] = array(
$form['contexts'] = [
'#type' => 'table',
'#header' => array(
'#header' => [
$this->t('Context'),
$this->t('Description'),
$this->t('Group'),
$this->t('Weight'),
$this->t('Operations'),
),
],
'#empty' => $this->t('There are no contexts defined.'),
'#attributes' => array(
'#attributes' => [
'id' => 'contexts',
),
);
],
];
$group_options = [];
......@@ -120,27 +120,27 @@ class ContextListBuilder extends ConfigEntityListBuilder implements FormInterfac
foreach ($groups as $group => $contexts) {
$group_class = Html::getClass($group);
$form['contexts']['#tabledrag'][] = array(
$form['contexts']['#tabledrag'][] = [
'action' => 'match',
'relationship' => 'sibling',
'group' => 'context-group-select',
'subgroup' => 'context-group-' . $group_class,
'hidden' => FALSE,
);
];
$form['contexts']['#tabledrag'][] = array(
$form['contexts']['#tabledrag'][] = [
'action' => 'order',
'relationship' => 'sibling',
'group' => 'context-weight',
'subgroup' => 'context-weight-' . $group_class,
);
];
$form['contexts']['group-' . $group_class] = array(
'#attributes' => array(
'class' => array('group-label', 'group-label-' . $group_class),
$form['contexts']['group-' . $group_class] = [
'#attributes' => [
'class' => ['group-label', 'group-label-' . $group_class],
'no_striping' => TRUE,
),
);
],
];
$form['contexts']['group-' . $group_class] = [
'#attributes' => [
......@@ -212,16 +212,16 @@ class ContextListBuilder extends ConfigEntityListBuilder implements FormInterfac
}
}
$form['actions'] = array(
$form['actions'] = [
'#type' => 'actions',
);
];
if (count($groups) > 0) {
$form['actions']['submit'] = array(
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save contexts'),
'#button_type' => 'primary',
);
];
}
return $form;
......
......@@ -35,9 +35,9 @@ class ContextDeleteForm extends EntityConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to delete the %label context?', array(
return $this->t('Are you sure you want to delete the %label context?', [
'%label' => $this->entity->getLabel(),
));
]);
}
/**
......@@ -70,9 +70,9 @@ class ContextDeleteForm extends EntityConfirmFormBase {
public function submitForm(array &$form, FormStateInterface $formState) {
$this->entity->delete();
drupal_set_message($this->t('The context %title has been deleted.', array(
drupal_set_message($this->t('The context %title has been deleted.', [
'%title' => $this->entity->getLabel(),
)));
]));
$formState->setRedirectUrl($this->getCancelUrl());
}
......
......@@ -35,20 +35,20 @@ class ContextDisableForm extends EntityConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
return $this->t('Are you sure you want to %status the %label context?', array(
return $this->t('Are you sure you want to %status the %label context?', [
'%status' => $this->entity->disabled() ? "enable" : "disable",
'%label' => $this->entity->getLabel(),
));
]);
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->t('This action will %status the %label context.', array(
return $this->t('This action will %status the %label context.', [
'%status' => $this->entity->disabled() ? "enable" : "disable",
'%label' => $this->entity->getLabel(),
));
]);
}
/**
......@@ -79,10 +79,10 @@ class ContextDisableForm extends EntityConfirmFormBase {
*/
public function submitForm(array &$form, FormStateInterface $formState) {
$this->entity->disable();
drupal_set_message($this->t('The context %title has been %status.', array(
drupal_set_message($this->t('The context %title has been %status.', [
'%title' => $this->entity->getLabel(),
'%status' => $this->entity->disabled() ? "disabled" : "enabled",
)));
]));
$formState->setRedirectUrl($this->getCancelUrl());
}
......
......@@ -34,9 +34,9 @@ class ContextEditForm extends ContextFormBase {
'#suffix' => '</div>',
'#markup' => '<h3>' . $this->t('Conditions') . '</h3>',
'#tree' => TRUE,
'#process' => array(
array($this, 'processConditions'),
),
'#process' => [
[$this, 'processConditions'],
],
];
$form['reactions'] = [
......@@ -44,9 +44,9 @@ class ContextEditForm extends ContextFormBase {
'#suffix' => '</div>',
'#markup' => '<h3>' . $this->t('Reactions') . '</h3>',
'#tree' => TRUE,
'#process' => array(
array($this, 'processReactions'),
),
'#process' => [
[$this, 'processReactions'],
],
];
return $form;
......@@ -83,7 +83,7 @@ class ContextEditForm extends ContextFormBase {
public function processConditions(&$element, FormStateInterface $form_state) {
$conditions = $this->entity->getConditions();
$element['add_condition'] = array(
$element['add_condition'] = [
'#type' => 'link',
'#title' => $this->t('Add condition'),
'#url' => Url::fromRoute('context.conditions_library', [
......@@ -98,7 +98,7 @@ class ContextEditForm extends ContextFormBase {
'width' => 700,
]),
],
);
];
if (!count($conditions)) {
$element['reactions']['empty'] = [
......
......@@ -300,7 +300,7 @@ class ContextManager {
* @param array $form_state_additions
* @return array
*/
public function getForm(ContextInterface $context, $formType = 'edit', array $form_state_additions = array()) {
public function getForm(ContextInterface $context, $formType = 'edit', array $form_state_additions = []) {
return $this->entityFormBuilder->getForm($context, $formType, $form_state_additions);
}
......
......@@ -53,7 +53,7 @@ class BlockPageDisplayVariantSubscriber implements EventSubscriberInterface {
* {@inheritdoc}
*/
static function getSubscribedEvents() {
$events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = array('onSelectPageDisplayVariant');
$events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = ['onSelectPageDisplayVariant'];
return $events;
}
......
......@@ -147,7 +147,7 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
*
* @return array
*/
public function execute(array $build = array(), $title = NULL, $main_content = NULL) {
public function execute(array $build = [], $title = NULL, $main_content = NULL) {
$cacheability = CacheableMetadata::createFromRenderArray($build);
......
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