diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php index f650ee2..e61713b 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php @@ -16,6 +16,13 @@ class LinkDelete extends ConfirmFormBase { /** + * The menu link to delete. + * + * @var \Drupal\menu_link\Plugin\Core\Entity\MenuLink + */ + protected $menuLink; + + /** * {@inheritdoc} */ public function getFormID() { diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetDelete.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/SetDelete.php index dc45e74..7c03fa0 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetDelete.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/SetDelete.php @@ -7,13 +7,57 @@ namespace Drupal\shortcut\Form; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\ControllerInterface; use Drupal\Core\Form\ConfirmFormBase; +use Drupal\Core\Database\Database; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\shortcut\Plugin\Core\Entity\Shortcut; /** * Builds the shortcut set deletion form. */ -class SetDelete extends ConfirmFormBase { +class SetDelete extends ConfirmFormBase implements ControllerInterface { + + /** + * The database connection. + * + * @var \Drupal\Core\Database\Database + */ + protected $database; + + /** + * The module handler service. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** + * The shortcut set being deleted. + * + * @var \Drupal\shortcut\Plugin\Core\Entity\Shortcut + */ + protected $shortcut; + + /** + * Constructs a SetDelete object. + */ + public function __construct(Database $database, ModuleHandlerInterface $module_handler) { + + $this->database = $database; + $this->moduleHandler = $module_handler; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('database'), + $container->get('module_handler') + ); + } /** * {@inheritdoc} @@ -51,7 +95,7 @@ public function buildForm(array $form, array &$form_state, Shortcut $shortcut = // Find out how many users are directly assigned to this shortcut set, and // make a message. - $number = db_query('SELECT COUNT(*) FROM {shortcut_set_users} WHERE set_name = :name', array(':name' => $this->shortcut->id()))->fetchField(); + $number = $this->database->query('SELECT COUNT(*) FROM {shortcut_set_users} WHERE set_name = :name', array(':name' => $this->shortcut->id()))->fetchField(); $info = ''; if ($number) { $info .= '
' . format_plural($number, @@ -61,7 +105,7 @@ public function buildForm(array $form, array &$form_state, Shortcut $shortcut = // Also, if a module implements hook_shortcut_default_set(), it's possible // that this set is being used as a default set. Add a message about that too. - if (\Drupal::service('module_handler')->getImplementations('shortcut_default_set')) { + if ($this->moduleHandler->getImplementations('shortcut_default_set')) { $info .= '
' . t('If you have chosen this shortcut set as the default for some or all users, they may also be affected by deleting it.') . '
'; }