/**
  * 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];
 }
Example #2
0
 /**
  * Create and load projects fixtures to database
  *
  * @param ObjectManager $manager Entity manager object
  */
 public function load(ObjectManager $manager)
 {
     $files = array('55f18a561ca39.jpeg', '55f18d6a43d1a.jpeg');
     $webCategory = $this->getReference('category-development');
     $mobileCategory = $this->getReference('mobile-development');
     $adminUser = $this->getReference('user-admin');
     $firstUser = $this->getReference('user-first');
     $secondUser = $this->getReference('user-second');
     // projects
     $preOrder = new Project();
     $preOrder->setName('preorder.it');
     $preOrder->setSlug('preorder-it');
     $preOrder->setUrl('http://preorder.it');
     $preOrder->setDate(new \DateTime('now'));
     $preOrder->setDescription('Press-releases and reviews of the latest electronic novelties. The possibility to leave a pre-order.');
     $preOrder->setTags('design, HTML markup, development');
     $preOrder->setShortDescription('design, HTML markup, development');
     $preOrder->setOnFrontPage(1);
     $preOrder->setOrdernum(0);
     $preOrder->addCategory($webCategory);
     $preOrder->addParticipant($adminUser);
     $preOrder->addParticipant($secondUser);
     $preOrder->setPublished(true);
     $preOrder->setImageFile($this->copyFile($files[array_rand($files)]));
     $manager->persist($preOrder);
     $manager->merge($webCategory);
     $ePrice = new Project();
     $ePrice->setName('eprice.kz');
     $ePrice->setSlug('eprice-kz');
     $ePrice->setUrl('http://eprice.kz');
     $ePrice->setDate(new \DateTime('now'));
     $ePrice->setDescription('Comparison of the prices of mobile phones, computers, monitors, audio and video in Kazakhstan');
     $ePrice->setTags('design');
     $ePrice->setShortDescription('design');
     $ePrice->setOnFrontPage(1);
     $ePrice->setPublished(true);
     $ePrice->setOrdernum(1);
     $ePrice->addCategory($webCategory);
     $ePrice->addCategory($mobileCategory);
     //        $ePrice->addParticipant($adminUser);
     //        $ePrice->addParticipant($firstUser);
     $ePrice->setImageFile($this->copyFile($files[array_rand($files)]));
     $manager->persist($ePrice);
     $manager->merge($webCategory);
     $manager->flush();
     $this->addReference('project-preorder', $preOrder);
     $this->addReference('project-eprice', $ePrice);
     for ($i = 0; $i < 20; $i++) {
         $example = new Project();
         $example->setName('example.com_' . $i);
         $example->setSlug('example-com_' . $i);
         $example->setUrl('http://example.com');
         $example->setDate(new \DateTime('now'));
         $example->setDescription('As described in RFC 2606, we maintain a number of domains such as EXAMPLE.COM and EXAMPLE.ORG for documentation purposes. These domains may be used as illustrative examples in documents without prior coordination with us. They are not available for registration.');
         $example->setTags('design, HTML markup, development');
         $example->setShortDescription('design, HTML markup, development');
         $example->setOnFrontPage(0);
         $example->setOrdernum(2 + $i);
         if ($i % 2) {
             $example->addCategory($webCategory);
         } else {
             $example->addCategory($mobileCategory);
         }
         $example->addParticipant($adminUser);
         $example->addParticipant($firstUser);
         $example->addParticipant($secondUser);
         $example->setPublished(true);
         $example->setImageFile($this->copyFile($files[array_rand($files)]));
         $manager->persist($example);
         $manager->merge($webCategory);
     }
     $manager->flush();
 }
 /**
  * Find by project
  *
  * @param Project $project Project
  *
  * @return array
  */
 public function findByProject($project)
 {
     $qb = $this->createQueryBuilder('uwp');
     return $qb->where($qb->expr()->eq('uwp.project', $project->getId()))->getQuery()->getResult();
 }
 public function testSetAndGetAndAddProjectRelativeProjects()
 {
     $project = new Project();
     $relativeProject = new Project();
     $project->addRelativeProject($relativeProject);
     $relativeProjects = $project->getRelativeProjects();
     $this->assertEquals($relativeProjects->count(), 1);
     $this->assertTrue(\is_a($relativeProjects, 'Doctrine\\Common\\Collections\\ArrayCollection'), 2);
     $project->setRelativeProjects($relativeProjects);
     $this->assertEquals($project->getRelativeProjects(), $relativeProjects);
 }