We need the possibility to select a filter for the FE editing module/ce. (Use case: A member must not edit items of an other member).
This is POC is working, when I add a possibility to pass the caller instance to the dcg. However, the way I am trying to make the caller instance available is not cool at all.
82865e3 AND
Index: src/FrontendEditor.php
@@ -46,17 +46,28 @@
*/
private $translator;
+
+ /**
+ * The module or content element calling the front end editor.
+ *
+ * @var object
+ */
+ private $caller;
+
/**
* Create a new instance.
*
* @param EventDispatcherInterface $dispatcher The event dispatcher.
*
* @param TranslatorInterface $translator The translator.
+ *
+ * @param object $caller The instance calling the front end editor
*/
- public function __construct(EventDispatcherInterface $dispatcher, TranslatorInterface $translator)
+ public function __construct(EventDispatcherInterface $dispatcher, TranslatorInterface $translator, $caller)
{
$this->dispatcher = $dispatcher;
$this->translator = $translator;
+ $this->caller = $caller;
}
/**
@@ -75,6 +86,7 @@
$action = new Action($actionName);
$event = new ActionEvent($environment, $action);
+ $environment->getSessionStorage()->set('frontend-editor-caller', $this->caller);
$this->dispatcher->dispatch(DcGeneralEvents::ACTION, $event);
if (!$result = $event->getResponse()) {
@authors in touched PHP filesUsing the session storage for this is definitely out of question. There MUST ONLY be literals and arrays stored in there, no object instances.
We need something better here.
@discordier speaks about using a DCG filter instead of a MetaModels fiter, as the dc-general-fronted is used. This PR goes the wrong way. Although, a filter for the front end editing mask is an important feature.
@richardhj What would be the right way? Rights management is one of the most requested features in the forum.