Exemplo n.º 1
0
 /**
  * Check if current user is the transaction owner
  *
  * @param Transaction $transaction
  *
  * @return boolean
  */
 public function isCurrentUserOwner(Transaction $transaction)
 {
     if ($this->securityContext->getToken()->getUser()->isGranted('ROLE_ADMIN')) {
         return true;
     }
     $currentUserId = $this->securityContext->getToken()->getUser()->getId();
     //actor owner
     if ($transaction->getActor() instanceof Actor) {
         if ($currentUserId == $transaction->getActor()->getId()) {
             return true;
         } elseif ($currentUserId == $transaction->getItems()->first()->getProduct()->getActor()->getId()) {
             return true;
         }
     }
     return false;
 }