Question about direct complements
Closed this issue · 7 comments
Hi,
first of all : nice one on making the bundle better it's getting great !
I have a little question, when for example :
$actionManager = $this->get('spy_timeline.action_manager');
$subject = $actionManager->findOrCreateComponent('\User', 'chucknorris');
$action = $actionManager->create($subject, 'control', array('directComplement' => 'the world' ));
$actionManager->updateAction($action);
'the world' supposed to be an entity, right ? ( or a sort of same thing as the subject ? )
In my case I'd like to see what happened to the world.
When I go to see chuck norris facts I can see that he does control the world but when I check on the worlds timeline : nothing.
How could I do that ?
Thanks !
Hi.
Thank you ;)
To have the behavior you expect, you have to change some things. First point, if you define array('directComplement' => 'the world')
. It consider directComplement
as a text, not a component, so you' ll not be able to fetch all actions where the world
was used.
Then, you should do that:
$actionManager = $this->get('spy_timeline.action_manager');
$subject = $actionManager->findOrCreateComponent('\User', 'chucknorris');
$world = $actionManager->findOrCreateComponent('\Object', 'theworld');
$action = $actionManager->create($subject, 'control', array('directComplement' => $world));
$actionManager->updateAction($action);
// here when you'll update action, it'll deploy on `subject` action (if you config on_subject is setted to true).
You have to define a spread which will deploy to the world. You can define a global spread which will deploy actions on each components used on action. Example:
class MySpread implements SpreadInterface
{
public function supports(ActionInterface $action)
{
return true;
}
public function process(ActionInterface $action, EntryCollection $coll)
{
foreach ($action->getActionComponents() as $actionComponent) {
if ($actionComponent->isText()) {
$coll->add(new Entry($actionComponent->getComponent()));
}
}
}
}
I hope it's clearer, if you have any question, you're welcome :)
In other words, to deploy an action to a component, you have to define spreads ;) By default, it deploy only on subject.
I close the issue, if you have any question, reopen it :)
Okay understood, thank you very much :)
Okay I have a new question : ( sorry can't reopen the issue no reopen button )
In my case $theWorld is an entity of my orm so I will need to get the entity with worldManager::findById( $componentIdenfitier ). ( not sure if there is a better one ).
And then ask the entity who is registered to it.
The problem is that this getter is a lazy loader so if I do a get class on the returned user I get a 'Proxies\__CG__\MG\UserBundle\Entity\User'
which throwed a Fatal error: Call to a member function expr() on a non-object
in Spy\TimelineBundle\Driver\ORM\ActionManager->findComponents( )
So I managed to get the real class using
ClassUtils::getRealClass( get_class( $user ) )
But I still get this error with
Variables in local scope (#23)
$hashes = array
'MG\UserBundle\Entity\User#s:1:"1";' => string 'MG\UserBundle\Entity\User#s:1:"1";' (length=34)
$qb = Undefined
Not sure what's happenning ?
Okay that was just fixed :D
That was my fault and it is fixed. Component manager supports proxies.
Sorry for inconvenience.
Envoyé de mon iPhone
Le 27 déc. 2012 à 19:55, Azer- notifications@github.com a écrit :
Okay I have a new question :
In my case $theWorld is an entity of my orm so I will need to get the
entity with worldManager::findById( $componentIdenfitier ). ( not sure if
there is a better one ).
And then ask the entity who is registered to it.
The problem is that this getter is a lazy loader so if I do a get class on
the returned user I get a 'Proxies__CG__\MG\UserBundle\Entity\User'
which throwed a Fatal error: Call to a member function expr() on a
non-object
So I managed to get the real class using
ClassUtils::getRealClass( get_class( $user ) )
But I still get this error in
Spy\TimelineBundle\Driver\ORM\ActionManager->findComponents(
)
and
Variables in local scope (#23)
$hashes = array
'MG\UserBundle\Entity\User#s:1:"1";' => string
'MG\UserBundle\Entity\User#s:1:"1";' (length=34)
$qb = Undefined
Not sure what's happenning ?
—
Reply to this email directly or view it on
GitHubhttps://github.com//issues/73#issuecomment-11715423.
Yes, a really stupid error :(
Envoyé de mon iPhone
Le 27 déc. 2012 à 20:06, Azer- notifications@github.com a écrit :
Okay that was just fixed :D
—
Reply to this email directly or view it on
GitHubhttps://github.com//issues/73#issuecomment-11715671.