Пример #1
0
 /**
  * Lead a person command.
  *
  * @param ComActorsDomainEntityActor  $actor  that is going to be followed
  * @param ComPeopleDomainEntityPerson $person person that is going to be added as a follower to the $actor
  *
  * @return LibBaseTemplateObject
  */
 public function getLeadCommand($actor, $person)
 {
     if (!$actor->isFollowable() || !$person->isLeadable()) {
         return;
     }
     if ($actor->eql($person)) {
         return;
     }
     if ($actor->blocking($person)) {
         return;
     }
     if ($person->following($actor) && $actor->authorize('administration')) {
         $command = $this->getCommand('lead', array('receiver' => $person, 'actor' => $actor, 'action' => 'unlead'));
         $command->name = 'unlead';
     } elseif (!$person->following($actor) && $actor->authorize('lead')) {
         $command = $this->getCommand('lead', array('receiver' => $person, 'actor' => $actor, 'action' => 'lead'));
         $command->name = 'lead';
     } else {
         return;
     }
     return $command;
 }