public function load(ObjectManager $manager) { $user = $this->getReference('user-user'); $usualCatalog = new Catalog(); $usualCatalog->setName('Usual Clothes')->setDescription('Description for the usual clothes catalog')->setReleasedAt(new \DateTime('tomorrow noon'))->setImageName('usual-clothes.png')->setAuthor($user); $manager->persist($usualCatalog); $sportsCatalog = new Catalog(); $sportsCatalog->setName('Sports Clothes')->setDescription('Description for the sports clothes catalog')->setReleasedAt(new \DateTime('tomorrow noon'))->setAuthor($user); $manager->persist($sportsCatalog); $manager->flush(); }
private function checkAuthor(Catalog $catalog) { $user = $this->get('security.token_storage')->getToken()->getUser(); if ($user != $catalog->getAuthor()) { throw new AccessDeniedException('You are not allowed to edit this catalog'); } }