コード例 #1
0
 public function testGetAndSetOrdernum()
 {
     $category = new Category();
     // check default value
     $this->assertEquals(0, $category->getOrdernum());
     // check set/get
     $category->setOrdernum(2);
     $this->assertEquals(2, $category->getOrdernum());
 }
コード例 #2
0
 /**
  * List of categories
  *
  * @param Category $category Category
  *
  * @return array
  *
  * @Route("/services/{slug}", name="portfolio_categories_list")
  * @ParamConverter("category", class="StfalconPortfolioBundle:Category", options={"mapping": {"slug": "slug"}})
  * @Template()
  */
 public function servicesAction(Category $category)
 {
     $repository = $this->getDoctrine()->getManager()->getRepository('StfalconPortfolioBundle:Category');
     $categories = $repository->getServicesCategories();
     $linkTexts = array('web-development' => 'веб-разработки', 'web-design' => 'разработки дизайна', 'mobile-development' => 'разработки мобильных приложений', 'game-development' => 'создания игр', 'consulting-audit' => 'консалтинга и аудита');
     $seo = $this->get('sonata.seo.page');
     $seo->addMeta('name', 'description', $category->getMetaDescription())->addMeta('name', 'keywords', $category->getMetaKeywords())->addMeta('property', 'og:url', $this->generateUrl('portfolio_categories_list', ['slug' => $category->getSlug()], true))->addMeta('property', 'og:title', $category->getTitle())->addMeta('property', 'og:description', $category->getMetaDescription());
     return array('category' => $category, 'categories' => $categories, 'linkTexts' => $linkTexts);
 }
コード例 #3
0
 /**
  * Create and load categories fixtures to database
  *
  * @param ObjectManager $manager Entity manager object
  */
 public function load(ObjectManager $manager)
 {
     // categories
     $development = new Category();
     $development->setName('Web Development');
     $development->setSlug('web-development');
     $development->setDetails('web-development');
     $development->setDescription('In work we use Symfony2.');
     $development->setCost('20 000');
     $manager->persist($development);
     $mobileDevelopment = new Category();
     $mobileDevelopment->setName('Mobile Development');
     $mobileDevelopment->setSlug('mobile-development');
     $mobileDevelopment->setDetails('mobile-development');
     $mobileDevelopment->setDescription('In work we use Android and IOS.');
     $mobileDevelopment->setCost('30 000');
     $manager->persist($mobileDevelopment);
     $manager->flush();
     $this->addReference('category-development', $development);
     $this->addReference('mobile-development', $mobileDevelopment);
 }
コード例 #4
0
 /**
  * Get query for select projects by category
  *
  * @param Category $category
  * @param string   $orderBy
  * @param string   $orderDirection
  *
  * @return Query
  */
 public function getQueryForSelectProjectsByCategory(Category $category, $orderBy = 'p.date', $orderDirection = 'DESC')
 {
     $qb = $this->getQueryBuilderWithOrdering($orderBy, $orderDirection);
     return $qb->join('p.categories', 'c')->andWhere('c.id = :category')->setParameter('category', $category->getId())->getQuery();
 }