Ejemplo n.º 1
0
 public function testSetAndGetProjectSlug()
 {
     $project = new Project();
     $slug = 'preorder-it';
     $project->setSlug($slug);
     $this->assertEquals($project->getSlug(), $slug);
 }
Ejemplo n.º 2
0
 /**
  * View project
  *
  * @param Request  $request  Request
  * @param Category $category Category
  * @param Project  $project  Project
  *
  * @return array
  *
  * @Route("/portfolio/{categorySlug}/{projectSlug}", name="portfolio_project_view")
  *
  * @Template()
  *
  * @ParamConverter("category", options={"mapping": {"categorySlug": "slug"}})
  * @ParamConverter("project", options={"mapping": {"projectSlug": "slug"}})
  */
 public function viewAction(Request $request, Category $category, Project $project)
 {
     $categorySlug = $project->getCategories()->first()->getSlug();
     $canonicalUrl = $this->generateUrl('portfolio_project_view', ['categorySlug' => $categorySlug, 'projectSlug' => $project->getSlug()], true);
     $seo = $this->get('sonata.seo.page');
     $seo->addMeta('name', 'description', $project->getMetaDescription())->addMeta('name', 'keywords', $project->getMetaKeywords())->addMeta('property', 'og:title', $project->getName())->addMeta('property', 'og:url', $canonicalUrl)->addMeta('property', 'og:type', 'portfolio')->addMeta('property', 'og:description', $project->getMetaDescription())->setLinkCanonical($canonicalUrl);
     if ($project->getImage()) {
         $vichUploader = $this->get('vich_uploader.templating.helper.uploader_helper');
         $seo->addMeta('property', 'og:image', $request->getSchemeAndHttpHost() . $vichUploader->asset($project, 'imageFile'));
     }
     return ['project' => $project, 'category' => $category];
 }