diff --git a/core/modules/book/lib/Drupal/book/Form/BookRemoveForm.php b/core/modules/book/lib/Drupal/book/Form/BookRemoveForm.php index 8c1fee4..c6da0ae 100644 --- a/core/modules/book/lib/Drupal/book/Form/BookRemoveForm.php +++ b/core/modules/book/lib/Drupal/book/Form/BookRemoveForm.php @@ -4,10 +4,13 @@ use Drupal\Core\ControllerInterface; use Drupal\Core\Form\FormInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Database\Connection; use Drupal\node\Plugin\Core\Entity\Node; class BookRemoveForm implements ControllerInterface, FormInterface { + protected $database; + /** * Injects database service. * @@ -15,13 +18,18 @@ class BookRemoveForm implements ControllerInterface, FormInterface { * Symfony Container Interface. */ public static function create(ContainerInterface $container) { - return new static(); + return new static($container->get('database')); } /** * Constructs a BookRemoveForm object. + * + * @param \Drupal\Core\Database\Connection $database + * Database connection. */ - public function __construct() {} + public function __construct(Connection $database) { + $this->database = $database; + } /** * Implements \Drupal\Core\Form\FormInterface::getFormID(). @@ -70,7 +78,7 @@ public function submitForm(array &$form, array &$form_state) { $node = $form['#node']; if (_book_node_is_removable($node)) { menu_link_delete($node->book['mlid']); - db_delete('book') + $this->database->delete('book') ->condition('nid', $node->nid) ->execute(); drupal_set_message(t('The post has been removed from the book.'));