/** * Perform a single access check operation on a given attribute, object and (optionally) user * It is safe to assume that $attribute and $object's class pass supportsAttribute/supportsClass * $user can be one of the following: * a UserInterface object (fully authenticated user) * a string (anonymously authenticated user) * * @param string $attribute * @param Reviewer $object * @param UserInterface|string $user * * @return bool */ protected function isGranted($attribute, $object, $user = null) { if ($object->getUser() == $user) { return true; } return false; }
/** * @Given there are following reviewer: * * @param TableNode $tableNode */ public function createReviewer(TableNode $tableNode) { $em = $this->getEntityManager(); foreach ($tableNode->getHash() as $reviewerHash) { $reviewer = new Reviewer(); $user = $this->getEntityManager()->getRepository('AppBundle:User')->findOneByUsername($reviewerHash['username']); $article = $this->getEntityManager()->getRepository('AppBundle:Article')->findOneByTitle($reviewerHash['title']); $reviewer->setUser($user); $reviewer->setArticle($article); $em->persist($reviewer); } $em->flush(); }