Пример #1
0
 public function load(ObjectManager $manager)
 {
     $user = $this->getReference('user');
     $topic = $this->getReference('topic');
     $countPosts = 25;
     for ($i = 1; $i <= $countPosts; $i++) {
         $post = new Post();
         $post->setTopic($topic);
         $post->setText('Test post ' . $i);
         $post->setUser($user);
         $manager->persist($post);
         $manager->flush();
     }
 }
Пример #2
0
 /**
  * Удалять могут: Пользователь-Владелец, Администратор
  */
 private function canDelete(Post $post, TokenInterface $token)
 {
     if (!$token->getUser() instanceof User) {
         return false;
     }
     if ($token->getUser() === $post->getUser()) {
         return true;
     }
     return $this->decisionManager->decide($token, array('ROLE_ADMIN'));
 }