Пример #1
0
 /**
  * @param string $attribute
  * @param ReportInterface $report
  * @param UserInterface $user
  * @return bool
  */
 protected function isGranted($attribute, $report, $user = null)
 {
     if (!$user instanceof UserInterface) {
         return false;
     }
     switch ($attribute) {
         // Users can perform any CRUD operations on their own reports.
         // Check if the given report's owning user is the given user.
         case self::CREATE:
         case self::VIEW:
         case self::EDIT:
         case self::DELETE:
             return $user->getId() === $report->getUser()->getId();
             break;
     }
     return false;
 }
Пример #2
0
 /**
  * @param string $attribute
  * @param ReportInterface $report
  * @param TokenInterface $token
  * @return bool
  */
 protected function voteOnAttribute($attribute, $report, TokenInterface $token)
 {
     $user = $token->getUser();
     if (!$user instanceof UserInterface) {
         return false;
     }
     switch ($attribute) {
         // Users can perform any CRUD operations on their own reports.
         // Check if the given report's owning user is the given user.
         case self::CREATE:
         case self::VIEW:
         case self::EDIT:
         case self::DELETE:
             return $this->usersAreIdentical($user, $report->getUser());
             break;
     }
     return false;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function deleteReport(ReportInterface $report)
 {
     $report->setDeleted(true);
     $this->updateReport($report);
 }