diff --git a/core/modules/menu/lib/Drupal/menu/MenuFormController.php b/core/modules/menu/lib/Drupal/menu/MenuFormController.php index 5fd91c5..b262820 100644 --- a/core/modules/menu/lib/Drupal/menu/MenuFormController.php +++ b/core/modules/menu/lib/Drupal/menu/MenuFormController.php @@ -7,13 +7,43 @@ namespace Drupal\menu; +use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Entity\EntityFormController; +use Drupal\Core\Entity\Query\QueryFactory; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Base form controller for menu edit forms. */ -class MenuFormController extends EntityFormController { +class MenuFormController extends EntityFormController implements ControllerInterface { + + /** + * The factory for entity queries. + * + * @var \Drupal\Core\Entity\Query\QueryFactory + */ + protected $entityQueryFactory; + + /** + * Constructs a MenuFormController object. + * + * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory + * The factory for entity queries. + * @param string|null $operation + * (optional) The name of the current operation, defaults to NULL. + */ + public function __construct(QueryFactory $entity_query_factory, $operation = NULL) { + parent::__construct($operation); + + $this->entityQueryFactory = $entity_query_factory; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static($container->get('entity.query')); + } /** * {@inheritdoc} @@ -88,7 +118,7 @@ public function menuNameExists($value) { $custom_exists = entity_load('menu', $value); // 'menu-' is added to the menu name to avoid name-space conflicts. $value = 'menu-' . $value; - $link_exists = \Drupal::entityQuery('menu_link')->condition('menu_name', $value)->range(0,1)->count()->execute(); + $link_exists = $this->entityQueryFactory->get('menu_link')->condition('menu_name', $value)->range(0,1)->count()->execute(); return $custom_exists || $link_exists; }