upgrades core to 8.4.2
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
|
||||
namespace Drupal\contextual;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||
use Drupal\Core\Render\RendererInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
@@ -11,9 +12,32 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
/**
|
||||
* 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.
|
||||
@@ -38,7 +62,7 @@ class ContextualController implements ContainerAwareInterface {
|
||||
'#type' => 'contextual_links',
|
||||
'#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);
|
||||
|
||||
@@ -78,7 +78,7 @@ class ContextualLinks extends RenderElement {
|
||||
$class = Html::getClass($class);
|
||||
$links[$class] = [
|
||||
'title' => $item['title'],
|
||||
'url' => Url::fromRoute(isset($item['route_name']) ? $item['route_name'] : '', isset($item['route_parameters']) ? $item['route_parameters'] : []),
|
||||
'url' => Url::fromRoute(isset($item['route_name']) ? $item['route_name'] : '', isset($item['route_parameters']) ? $item['route_parameters'] : [], $item['localized_options']),
|
||||
];
|
||||
}
|
||||
$element['#links'] = $links;
|
||||
|
||||
@@ -138,7 +138,7 @@ class ContextualLinks extends FieldPluginBase {
|
||||
'#type' => 'contextual_links_placeholder',
|
||||
'#id' => _contextual_links_to_id($contextual_links),
|
||||
];
|
||||
return drupal_render($element);
|
||||
return \Drupal::service('renderer')->render($element);
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
@@ -148,6 +148,6 @@ class ContextualLinks extends FieldPluginBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() { }
|
||||
public function query() {}
|
||||
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ class ContextualDynamicContextTest extends WebTestBase {
|
||||
// Get a page where contextual links are directly rendered.
|
||||
$this->drupalGet(Url::fromRoute('menu_test.contextual_test'));
|
||||
$this->assertEscaped("<script>alert('Welcome to the jungle!')</script>");
|
||||
$this->assertLink('Edit menu - contextual');
|
||||
$this->assertRaw('<li class="menu-testcontextual-hidden-manage-edit"><a href="' . base_path() . 'menu-test-contextual/1/edit" class="use-ajax" data-dialog-type="modal" data-is-something>Edit menu - contextual</a></li>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user