Issue #2869903 by martin107: ContextualController: remove ContainerAwareTrait
parent
26ad8f8529
commit
0022c5e115
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
namespace Drupal\contextual;
|
namespace Drupal\contextual;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
use Drupal\Core\Render\RendererInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
|
@ -11,9 +12,32 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
/**
|
/**
|
||||||
* Returns responses for Contextual module routes.
|
* Returns responses for Contextual module routes.
|
||||||
*/
|
*/
|
||||||
class ContextualController implements ContainerAwareInterface {
|
class ContextualController implements ContainerInjectionInterface {
|
||||||
|
|
||||||
use ContainerAwareTrait;
|
/**
|
||||||
|
* The renderer.
|
||||||
|
* @var \Drupal\Core\Render\RendererInterface
|
||||||
|
*/
|
||||||
|
protected $render;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructors a new ContextualController
|
||||||
|
*
|
||||||
|
* @param \Drupal\Core\Render\RendererInterface $renderer
|
||||||
|
* The renderer.
|
||||||
|
*/
|
||||||
|
public function __construct(RendererInterface $renderer) {
|
||||||
|
$this->renderer = $renderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public static function create(ContainerInterface $container) {
|
||||||
|
return new static(
|
||||||
|
$container->get('renderer')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the requested rendered contextual links.
|
* Returns the requested rendered contextual links.
|
||||||
|
@ -38,7 +62,7 @@ class ContextualController implements ContainerAwareInterface {
|
||||||
'#type' => 'contextual_links',
|
'#type' => 'contextual_links',
|
||||||
'#contextual_links' => _contextual_id_to_links($id),
|
'#contextual_links' => _contextual_id_to_links($id),
|
||||||
];
|
];
|
||||||
$rendered[$id] = $this->container->get('renderer')->renderRoot($element);
|
$rendered[$id] = $this->renderer->renderRoot($element);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new JsonResponse($rendered);
|
return new JsonResponse($rendered);
|
||||||
|
|
Loading…
Reference in New Issue