Skip to content
Snippets Groups Projects
Commit f02168ef authored by Jürgen Haas's avatar Jürgen Haas Committed by Jürgen Haas
Browse files

Issue #3502543 by jurgenhaas: ECA Render: render view action doesn't check the...

Issue #3502543 by jurgenhaas: ECA Render: render view action doesn't check the access which leads to an exception


(cherry picked from commit c181c7b5)

Co-authored-by: default avatarjurgenhaas <juergen.haas@lakedrops.com>
parent 0384c277
No related branches found
Tags 8.x-1.11
No related merge requests found
Pipeline #407510 passed with warnings
......@@ -2,11 +2,13 @@
namespace Drupal\eca_render\Plugin\Action;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Render\Markup as RenderMarkup;
use Drupal\Core\Render\RenderContext;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\eca\Plugin\ECA\PluginFormTrait;
use Drupal\views\Entity\View;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -99,6 +101,35 @@ class Views extends RenderElementActionBase {
$this->configuration['arguments'] = $form_state->getValue('arguments');
}
/**
* {@inheritdoc}
*/
public function access($object, ?AccountInterface $account = NULL, $return_as_object = FALSE) {
$result = AccessResult::forbidden();
$view_id = $this->getViewId();
if ($view_id !== '') {
$view = View::load($view_id);
if ($view && $view->status()) {
$viewExecutable = $view->getExecutable();
$display_id = $this->getDisplayId();
$display = NULL;
if ($display_id !== '') {
if ($viewExecutable->setDisplay($display_id)) {
$display = $viewExecutable->getDisplay();
}
}
else {
$viewExecutable->initDisplay();
$display = $viewExecutable->getDisplay();
}
if ($display !== NULL) {
$result = AccessResult::allowedIf($display->access($account));
}
}
}
return $return_as_object ? $result : $result->isAllowed();
}
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment