Commit 45c52bc9 authored by kbrodej's avatar kbrodej Committed by boshtian

Issue #3042764 by strozx, ngkoutsaik, kbrodej, lhridley, Sergiu Stici, bzoks:...

Issue #3042764 by strozx, ngkoutsaik, kbrodej, lhridley, Sergiu Stici, bzoks: Drupal 9 Deprecated Code Report
parent 812e2fa0
......@@ -3,3 +3,4 @@ description: 'Set conditions and configure reactions that should be implemented
package: Context
type: module
core: 8.x
core_version_requirement: ^8 || ^9
......@@ -13,6 +13,7 @@ use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Messenger\MessengerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ContextListBuilder extends ConfigEntityListBuilder implements FormInterface {
......@@ -31,6 +32,13 @@ class ContextListBuilder extends ConfigEntityListBuilder implements FormInterfac
*/
protected $formBuilder;
/**
* The messenger.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/**
* Constructs a new ContextListBuilder object.
*
......@@ -45,17 +53,22 @@ class ContextListBuilder extends ConfigEntityListBuilder implements FormInterfac
*
* @param \Drupal\Core\Form\FormBuilderInterface $formBuilder
* The Drupal form builder.
*
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger.
*/
public function __construct(
EntityTypeInterface $entity_type,
EntityStorageInterface $storage,
ContextManager $contextManager,
FormBuilderInterface $formBuilder
FormBuilderInterface $formBuilder,
MessengerInterface $messenger
) {
parent::__construct($entity_type, $storage);
$this->contextManager = $contextManager;
$this->formBuilder = $formBuilder;
$this->messenger = $messenger;
}
/**
......@@ -64,9 +77,10 @@ class ContextListBuilder extends ConfigEntityListBuilder implements FormInterfac
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('context.manager'),
$container->get('form_builder')
$container->get('form_builder'),
$container->get('messenger')
);
}
......@@ -159,11 +173,11 @@ class ContextListBuilder extends ConfigEntityListBuilder implements FormInterfac
$operations = [
'edit' => [
'title' => $this->t('Edit'),
'url' => $context->urlInfo('edit-form'),
'url' => $context->toUrl('edit-form'),
],
'delete' => [
'title' => $this->t('Delete'),
'url' => $context->urlInfo('delete-form'),
'url' => $context->toUrl('delete-form'),
'attributes' => $this->getAjaxAttributes(),
],
'disable' => [
......@@ -257,7 +271,7 @@ class ContextListBuilder extends ConfigEntityListBuilder implements FormInterfac
$context->save();
}
drupal_set_message($this->t('The context settings have been updated.'));
$this->messenger->addMessage($this->t('The context settings have been updated.'));
}
}
......@@ -320,7 +320,7 @@ class ContextUIController extends ControllerBase {
return $response;
}
$url = $context->urlInfo('edit-form');
$url = $context->toUrl('edit-form');
return $this->redirect($url->getRouteName(), $url->getRouteParameters());
}
......@@ -386,7 +386,7 @@ class ContextUIController extends ControllerBase {
return $response;
}
$url = $context->urlInfo('edit-form');
$url = $context->toUrl('edit-form');
return $this->redirect($url->getRouteName(), $url->getRouteParameters());
}
......
......@@ -72,7 +72,7 @@ class ConditionDeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getCancelUrl() {
return $this->context->urlInfo('edit-form');
return $this->context->toUrl('edit-form');
}
/**
......@@ -115,7 +115,7 @@ class ConditionDeleteForm extends ConfirmFormBase {
// If this is not an AJAX request then redirect and show a message.
if (!$this->getRequest()->isXmlHttpRequest()) {
drupal_set_message($this->t('The condition %name has been removed.', [
$this->messenger()->addMessage($this->t('The condition %name has been removed.', [
'%name' => $this->condition->getPluginDefinition()['label']]
));
......
......@@ -13,12 +13,12 @@ class ContextAddForm extends ContextFormBase {
$status = parent::save($form, $formState);
if ($status) {
drupal_set_message($this->t('The context %label has been added.', [
$this->messenger()->addMessage($this->t('The context %label has been added.', [
'%label' => $this->entity->getLabel(),
]));
}
else {
drupal_set_message($this->t('The context was not saved.'));
$this->messenger()->addMessage($this->t('The context was not saved.'));
}
$formState->setRedirect('entity.context.edit_form', [
......
......@@ -70,7 +70,7 @@ 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.', [
$this->messenger()->addMessage($this->t('The context %title has been deleted.', [
'%title' => $this->entity->getLabel(),
]));
......
......@@ -11,14 +11,14 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class ContextDisableForm extends EntityConfirmFormBase {
/**
* @var ContextManager
* @var \Drupal\context\ContextManager
*/
protected $contextManager;
/**
* @param ContextManager $contextManager
* @param \Drupal\context\ContextManager $contextManager
*/
function __construct(ContextManager $contextManager) {
public function __construct(ContextManager $contextManager) {
$this->contextManager = $contextManager;
}
......@@ -79,11 +79,12 @@ 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.', [
$this->messenger()->addMessage($this->t('The context %title has been %status.', [
'%title' => $this->entity->getLabel(),
'%status' => $this->entity->disabled() ? "disabled" : "enabled",
]));
$formState->setRedirectUrl($this->getCancelUrl());
}
}
......@@ -59,12 +59,12 @@ class ContextEditForm extends ContextFormBase {
$status = parent::save($form, $formState);
if ($status) {
drupal_set_message($this->t('The context %label has been saved.', [
$this->messenger()->addMessage($this->t('The context %label has been saved.', [
'%label' => $this->entity->getLabel(),
]));
}
else {
drupal_set_message($this->t('The context was not saved.'));
$this->messenger()->addMessage($this->t('The context was not saved.'));
}
}
......
......@@ -69,7 +69,7 @@ class ReactionDeleteForm extends ConfirmFormBase implements ContainerInjectionIn
* A URL object.
*/
public function getCancelUrl() {
return $this->context->urlInfo();
return $this->context->toUrl();
}
/**
......@@ -117,7 +117,7 @@ class ReactionDeleteForm extends ConfirmFormBase implements ContainerInjectionIn
// If this is not an AJAX request then redirect and show a message.
if (!$this->getRequest()->isXmlHttpRequest()) {
drupal_set_message($this->t('The %label context reaction has been removed.', [
$this->messenger()->addMessage($this->t('The %label context reaction has been removed.', [
'%label' => $definition['label']]
));
......
......@@ -4,10 +4,10 @@ namespace Drupal\context;
use Drupal\Core\Executable\ExecutableInterface;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Core\Plugin\PluginFormInterface;
interface ContextReactionInterface extends ConfigurablePluginInterface, PluginFormInterface, PluginInspectionInterface, ExecutableInterface {
interface ContextReactionInterface extends ConfigurableInterface, PluginFormInterface, PluginInspectionInterface, ExecutableInterface {
/**
* Get the unique ID of this context reaction.
......@@ -22,4 +22,5 @@ interface ContextReactionInterface extends ConfigurablePluginInterface, PluginFo
* @return \Drupal\Core\StringTranslation\TranslatableMarkup
*/
public function summary();
}
......@@ -2,6 +2,7 @@
namespace Drupal\context\Plugin\ContextReaction;
use Drupal\block\BlockRepositoryInterface;
use Drupal\Core\Plugin\PluginDependencyTrait;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
......@@ -710,7 +711,7 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
*
* @todo This could be moved to a service since we use it in a couple of places.
*/
protected function getSystemRegionList($theme, $show = REGIONS_ALL) {
protected function getSystemRegionList($theme, $show = BlockRepositoryInterface::REGIONS_ALL) {
return system_region_list($theme, $show);
}
......
<?php
namespace Drupal\context\Plugin\ContextReaction;
use Drupal\block\BlockRepositoryInterface;
use Drupal\context\ContextReactionPluginBase;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Form\FormState;
......@@ -156,7 +157,7 @@ class Regions extends ContextReactionPluginBase implements ContainerFactoryPlugi
*
* @todo This could be moved to a service since we use it in a couple of places.
*/
protected function getSystemRegionList($theme, $show = REGIONS_ALL) {
protected function getSystemRegionList($theme, $show = BlockRepositoryInterface::REGIONS_ALL) {
return system_region_list($theme, $show);
}
......
......@@ -84,7 +84,7 @@ class BlockDeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getCancelUrl() {
return $this->context->urlInfo();
return $this->context->toUrl();
}
/**
......@@ -124,7 +124,7 @@ class BlockDeleteForm extends ConfirmFormBase {
// If this is not an AJAX request then redirect and show a message.
if (!$this->getRequest()->isXmlHttpRequest()) {
drupal_set_message($this->t('The %label block has been removed.', [
$this->messenger()->addMessage($this->t('The %label block has been removed.', [
'%label' => $configuration['label']]
));
......
......@@ -2,6 +2,7 @@
namespace Drupal\context\Reaction\Blocks\Form;
use Drupal\block\BlockRepositoryInterface;
use Drupal\context\ContextManager;
use Drupal\context\ContextReactionManager;
use Drupal\context\Form\AjaxFormTrait;
......@@ -341,7 +342,7 @@ abstract class BlockFormBase extends FormBase {
*
* @return array
*/
protected function getThemeRegionOptions($theme, $show = REGIONS_ALL) {
protected function getThemeRegionOptions($theme, $show = BlockRepositoryInterface::REGIONS_ALL) {
$regions = system_region_list($theme, $show);
foreach ($regions as $region => $title) {
......
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