Closed ppounder closed 10 years ago
Answered my own question, but just wondered if anyone had a better way of doing this? I also have another question.underneath my solution:
CONST ANNOUNCEMENT_CLASS = 'Acme\DemoBundle\Entity\Announcement';
public function supports(ActionInterface $action)
{
if($action->hasComponent('directComplement'))
{
$dComplement = $action->getComponent('directComplement');
if (is_object($dComplement) && $dComplement->getModel() == self::ANNOUNCEMENT_CLASS) {
return true;
}
return false;
}
return false;
}
I can get the object ID in the process() method by $announcement = $action->getComponent('directComplement')->getIdentifier();
but how do I go about getting the full announcement object. Will I need to pass the Entity Manager into my Spread to pull from the DB or is there a method hidden somewhere to do this?
Hi,
Your solution is good, no way to do it differently.
To get the full object, do you add DataHydrator filter ? If yes, use $action->getComponent('directComplement')->getData()
Hi Stéphane,
I haven't added the DataHydrator but I will do, that will be exactly what I need. Many thanks
Paul
You're welcome.
Hi there,
I'm trying to locate the object that I've set against a directComplement in my
supports()
method in my spread.I've created my timeline using the following
$subject
is a User object,$announcement
is an announcement object, which has a OneToMany relationship to groups to which I've set the announcement to be viewed by. In the groups theres a relationship to the Users in that group.What I'm looking at doing is checking to see if the action is a an Announcement object, if it does, I then process the users who can view that announcement.
I can't do the following:
as it the component is actually "directComplement".
Can anyone advise how I can find the object set in the directComplement against that action, or a better way of setting my timeline action?
Kind regards, Paul