/** * @Method({"GET"}) * @Route("/{id}/show/{slug}", name="app_blog_tag_show", requirements={"id" = "\d+", "slug" = "[a-z0-9_-]+"}, defaults={"slug" = null}) * @Template("blog/tag/show.html.twig") */ public function showAction(Request $request, BlogTag $tag, $slug = null) { /** @var Slugify $slugify */ $slugify = $this->get('slugify'); $slugCheck = $slugify->slugify($tag->getTitle()); if ($slug !== $slugCheck) { return $this->redirect($this->generateUrl('app_blog_tag_show', ['id' => $tag->getId(), 'slug' => $slugCheck])); } return ['tag' => $tag]; }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { $blogTagRecords = []; for ($i = 0; $i < 10; ++$i) { $blogTagRecords[] = ['title' => 'Tag #' . ($i + 1), 'description' => 'Description of the Tag #' . ($i + 1)]; } foreach ($blogTagRecords as $blogTagRecord) { $blogTag = new BlogTag(); $blogTag->setTitle($blogTagRecord['title']); $blogTag->setDescription($blogTagRecord['description']); $manager->persist($blogTag); $manager->flush(); $this->referenceRepository->addReference('blog-tag-' . $blogTag->getId(), $blogTag); } }