diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php index fe10916..1301dc3 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php @@ -7,15 +7,42 @@ namespace Drupal\entity_reference; -use Symfony\Component\DependencyInjection\ContainerAware; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Drupal\Core\ControllerInterface; /** * Defines route controller for entity reference. */ -class EntityReferenceController extends ContainerAware { +class EntityReferenceController implements ControllerInterface { + + /** + * The autocomplete helper for entity references. + * + * @var \Drupal\entity_reference\EntityReferenceAutocomplete + */ + protected $entityReferenceAutocomplete; + + /** + * Constructs a EntityReferenceController object. + * + * @param \Drupal\entity_reference\EntityReferenceAutocomplete $entity_reference_autcompletion + * The autocompletion helper for entity references + */ + public function __construct(EntityReferenceAutocomplete $entity_reference_autcompletion) { + $this->entityReferenceAutocomplete = $entity_reference_autcompletion; + } + + /** + * Implements \Drupal\Core\ControllerInterface::create(). + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('entity_reference.autocomplete') + ); + } /** * Autocomplete the label of an entity. @@ -66,7 +93,7 @@ public function handleAutocomplete(Request $request, $type, $field_name, $entity $prefix = count($items_typed) ? drupal_implode_tags($items_typed) . ', ' : ''; } - $matches = $this->container->get('entity_reference.autocomplete')->getMatches($field, $instance, $entity_type, $entity_id, $prefix, $last_item); + $matches = $this->entityReferenceAutocomplete->getMatches($field, $instance, $entity_type, $entity_id, $prefix, $last_item); return new JsonResponse($matches); }