Closed berdyshev closed 9 years ago
Hi,
What is difference between Entry and EntryUnaware
When you deploy action to friends, you could choose to not fetch entities of theses friends.
Imagine you have to deploy to 500 users, and you have not theses 500 users fetched from database. You will be able to provide an array of 500 EntryUnaware
with only the class and identifier. If you use Entry
, you will have to fetch theses users.
but this action didn't appeared in user's friends' timelines. Why? May be my previous answer would fix it ?
2) There is possibility to pass array of IDs as second argument of EntryUnaware — what is difference if I create new EntryUnaware for each ID or I create single EntryUnaware with array of IDs.
An array of id is for composite keys only. ONE instance of EntryUnaware is for ONE entity.
3) Is there possibility to get user's timeline for two (or even all) contexts at once?
Sure, you will have to use QueryBuilder
(see documentation), but it's a bit difficult. Or try to understand how timelines and actions work to create your own sql query.
4) You could use
EntryUnaware
. Or yes, you have to inject container :(. At this moment, we do not provide entityManager with spread system.
You're welcome.
Thanks a lot, Stéphane, for your so fast answer.
I've just tried to create an array of EntryUnaware
for each friend, but it doesn't work somehow. Only in case I create Entry
for each friend (with fully loaded User
entity) - it works, but for EntryUnaware
- doesn't.
Here is my process() code:
/** @var User $user */
$user = $action->getSubject()->getData();
$user2Id = $action->getComponent('complement')->getIdentifier();
foreach ($user->getFriends() as $friend) {
$friendId = $friend->getUser2()->getId();
if ($friendId != $user->getId() && $friendId != $user2Id) {
$entry = new EntryUnaware(self::USER_CLASS, $friendId);
$coll->add($entry, 'FRIENDS');
}
}
Works only this implementation:
foreach ($user->getFriends() as $friend) {
$friendId = $friend->getUser2()->getId();
if ($friendId != $user->getId() && $friendId != $user2Id) {
$subject = $this->actionManager->findOrCreateComponent($friend->getUser2());
$entry = new Entry($subject);
$coll->add($entry, 'FRIENDS');
}
}
But what is really interesting, this way of component creation for the last code example doesn't work as well:
$subject = $this->actionManager->findOrCreateComponent(self::USER_CLASS, $friendId);
I'm getting timeline for now this way (code from controller):
$user = $this->getUser();
$actionManager = $this->get('spy_timeline.action_manager');
$subject = $actionManager->findOrCreateComponent($user);
$timelineManager = $this->get('spy_timeline.timeline_manager');
$timeline = $timelineManager->getTimeline($subject, ['context' => 'FRIENDS']);
Sorry, it was my mistake — wrong Model name in USER_CLASS
Hi, I'm trying to understand how to use a timeline, but it's difficult, because a lot of things are not described in documentation. So, I will list here couple of questions and will be glad if you could help me:
Thanks a lot for any help.