Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fixes and refactoring

  • Loading branch information...
commit 22a901a12a552c4ee9083b7c4f57eb2536d80219 1 parent 5a228ce
Stepan Tanasiychuk authored
7 Admin/CategoryAdmin.php
@@ -14,7 +14,9 @@ protected function configureFormFields(FormMapper $formMapper)
14 14 $formMapper
15 15 ->add('slug')
16 16 ->add('name')
17   - ->add('description', 'textarea', array('attr' => array("class" => 'xxlarge')))
  17 + ->add('description', 'textarea', array('attr' => array("class" => 'input-xxlarge')))
  18 + // @todo сделать сортировку через sortable (по аналогии с проектами)
  19 + ->add('ordernum')
18 20 ;
19 21 }
20 22
@@ -22,8 +24,7 @@ protected function configureListFields(ListMapper $listMapper)
22 24 {
23 25 $listMapper
24 26 ->addIdentifier('slug')
25   - ->add('description')
26   - ->add('ordernum')
  27 + ->add('name')
27 28 ;
28 29 }
29 30 }
17 Admin/ProjectAdmin.php
@@ -21,34 +21,35 @@ public function __construct($code, $class, $baseControllerName)
21 21 );
22 22 }
23 23 }
  24 +
24 25 protected function configureFormFields(FormMapper $formMapper)
25 26 {
26 27 $formMapper
27   - ->add('slug')
28 28 ->add('name')
29   - ->add('description', 'textarea', array('attr' => array("class" => 'xxlarge')))
  29 + ->add('slug')
30 30 ->add('url')
31   - ->add('date', 'datetime', array('required' => false))
32   - ->add('imageFile', 'file')
33   - ->add('categories')
34   - ->add('users', 'textarea', array('attr' => array("class" => 'xxlarge')))
  31 + ->add('description', 'textarea', array('attr' => array("class" => 'input-xxlarge')))
  32 + ->add('imageFile', 'file', array('required' => false))
  33 + ->add('date', 'date', array('required' => false))
  34 + ->add('categories', null, array('required' => false))
  35 + ->add('users', 'textarea', array('required' => false, 'attr' => array("class" => 'input-xxlarge')))
35 36 ->add('onFrontPage', 'checkbox', array('required' => false))
36 37 ;
37 38 }
38 39
  40 + // @todo с sortable проблемы начиная со второй страницы
39 41 protected function configureListFields(ListMapper $listMapper)
40 42 {
41 43 $listMapper
42 44 ->addIdentifier('slug')
43 45 ->add('name')
44   - ->add('description')
45 46 ->add('date')
46 47 ;
47 48 }
48 49
49 50 public function setTemplates(array $templates)
50 51 {
51   - $templates['list'] = 'StfalconPortfolioBundle::list.html.twig';
  52 + $templates['list'] = 'StfalconPortfolioBundle:ProjectAdmin:list.html.twig';
52 53 parent::setTemplates($templates);
53 54 }
54 55 }
49 Controller/CategoryController.php
@@ -3,23 +3,16 @@
3 3 namespace Stfalcon\Bundle\PortfolioBundle\Controller;
4 4
5 5 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6   -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
7   -use Symfony\Component\HttpFoundation\RedirectResponse;
8 6 use Symfony\Component\HttpFoundation\Response;
9   -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
10 7 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
11 8 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
12 9 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
13 10
14   -
15 11 use Stfalcon\Bundle\PortfolioBundle\Entity\Project;
16 12 use Stfalcon\Bundle\PortfolioBundle\Entity\Category;
17   -use Stfalcon\Bundle\PortfolioBundle\Form\CategoryForm;
18 13
19 14 /**
20   - * CRUD categories. Services widget.
21   - *
22   - * @author Stepan Tanasiychuk <ceo@stfalcon.com>
  15 + * Category Controller
23 16 */
24 17 class CategoryController extends Controller
25 18 {
@@ -32,23 +25,20 @@ class CategoryController extends Controller
32 25 * @return array
33 26 * @Route(
34 27 * "/portfolio/{slug}/{page}",
35   - * name="portfolioCategoryView",
  28 + * name="portfolio_category_view",
36 29 * requirements={"page" = "\d+"},
37 30 * defaults={"page" = "1"}
38 31 * )
39 32 * @Template()
40 33 */
41   - public function viewAction(Category $category)
  34 + public function viewAction(Category $category, $page = 1)
42 35 {
43   - $knpPaginator = $this->get('knp_paginator');
44   - $paginator = $knpPaginator->paginate(
45   - $this->get('doctrine.orm.entity_manager')
46   - ->getRepository("StfalconPortfolioBundle:Project")
47   - ->getProjectsQueryForPagination($category->getId()),
48   - $this->getRequest()->get('page', 1) /*page number*/,
49   - 6 /*limit per page*/
50   - );
51   - $paginator->setUsedRoute('portfolioCategoryView');
  36 + $query = $this->get('doctrine.orm.entity_manager')
  37 + ->getRepository("StfalconPortfolioBundle:Project")
  38 + ->getQueryForSelectProjectsByCategory($category);
  39 +
  40 + $paginator = $this->get('knp_paginator')->paginate($query, $page, 6);
  41 + $paginator->setUsedRoute('portfolio_category_view');
52 42
53 43 if ($this->has('application_default.menu.breadcrumbs')) {
54 44 $breadcrumbs = $this->get('application_default.menu.breadcrumbs');
@@ -58,7 +48,7 @@ public function viewAction(Category $category)
58 48
59 49 return array(
60 50 'category' => $category,
61   - 'paginator' => $paginator,
  51 + 'paginator' => $paginator, // @todo переименовать переменную
62 52 );
63 53 }
64 54
@@ -73,6 +63,7 @@ public function viewAction(Category $category)
73 63 */
74 64 public function servicesAction(Category $category, $project = null)
75 65 {
  66 + // @todo помоему этот блок отключен
76 67 $categories = $this->get('doctrine.orm.entity_manager')
77 68 ->getRepository("StfalconPortfolioBundle:Category")->getAllCategories();
78 69
@@ -80,22 +71,6 @@ public function servicesAction(Category $category, $project = null)
80 71 }
81 72
82 73 /**
83   - * Show projects by category
84   - *
85   - * @param Category $category
86   - *
87   - * @return array
88   - * @Route("/admin/portfolio/category/{slug}/projects", name="portfolioProjectsByCategory")
89   - * @Template()
90   - */
91   - public function projectsAction(Category $category)
92   - {
93   - return array(
94   - 'category' => $category,
95   - );
96   - }
97   -
98   - /**
99 74 * Ajax order projects
100 75 *
101 76 * @return string
@@ -104,6 +79,8 @@ public function projectsAction(Category $category)
104 79 */
105 80 public function orderProjects()
106 81 {
  82 + // @todo переименовать метод и роут
  83 + // @todo перенести сортировку проектов в админку
107 84 $projects = $this->getRequest()->get('projects');
108 85 $em = $this->get('doctrine')->getEntityManager();
109 86 foreach ($projects as $projectInfo) {
32 Controller/ProjectController.php
@@ -4,19 +4,14 @@
4 4
5 5 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6 6 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
7   -use Symfony\Component\HttpFoundation\RedirectResponse;
8   -use Symfony\Component\HttpFoundation\Response;
9   -use Stfalcon\Bundle\PortfolioBundle\Form\ProjectForm;
10   -use Stfalcon\Bundle\PortfolioBundle\Entity\Project;
11   -use Stfalcon\Bundle\PortfolioBundle\Entity\Category;
12   -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
13 7 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
14 8 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
15 9
  10 +use Stfalcon\Bundle\PortfolioBundle\Entity\Project;
  11 +use Stfalcon\Bundle\PortfolioBundle\Entity\Category;
  12 +
16 13 /**
17   - * CRUD projects. Show users and nearby projects widget.
18   - *
19   - * @author Stepan Tanasiychuk <ceo@stfalcon.com>
  14 + * Project controller
20 15 */
21 16 class ProjectController extends Controller
22 17 {
@@ -27,11 +22,13 @@ class ProjectController extends Controller
27 22 * @param string $projectSlug Slug of project
28 23 *
29 24 * @return array
30   - * @Route("/portfolio/{categorySlug}/{projectSlug}", name="portfolioCategoryProjectView")
  25 + * @Route("/portfolio/{categorySlug}/{projectSlug}", name="portfolio_project_view")
31 26 * @Template()
32 27 */
33 28 public function viewAction($categorySlug, $projectSlug)
34 29 {
  30 + // @todo упростить когда что-то разрулят с этим PR https://github.com/sensio/SensioFrameworkExtraBundle/pull/42
  31 +
35 32 // try find category by slug
36 33 $category = $this->_findCategoryBySlug($categorySlug);
37 34
@@ -43,7 +40,7 @@ public function viewAction($categorySlug, $projectSlug)
43 40 $breadcrumbs->addChild(
44 41 $category->getName(),
45 42 array(
46   - 'route' => 'portfolioCategoryView',
  43 + 'route' => 'portfolio_category_view',
47 44 'routeParameters' => array('slug' => $category->getSlug())
48 45 )
49 46 );
@@ -65,21 +62,21 @@ public function viewAction($categorySlug, $projectSlug)
65 62 public function nearbyProjectsAction($categorySlug, $projectSlug)
66 63 {
67 64 // try find category by slug
68   - $categorySlug = $this->_findCategoryBySlug($categorySlug);
  65 + $category = $this->_findCategoryBySlug($categorySlug);
69 66
70 67 // try find project by slug
71   - $projectSlug = $this->_findProjectBySlug($projectSlug);
  68 + $project = $this->_findProjectBySlug($projectSlug);
72 69
73 70 $em = $this->get('doctrine')->getEntityManager();
74 71
75 72 // get all projects from this category
76 73 $projects = $em->getRepository("StfalconPortfolioBundle:Project")
77   - ->getProjectsByCategory($categorySlug);
  74 + ->getProjectsByCategory($category);
78 75
79 76 // get next and previous projects from this category
80 77 $i = 0; $previousProject = null; $nextProject = null;
81 78 foreach ($projects as $p) {
82   - if ($projectSlug->getId() == $p->getId()) {
  79 + if ($project->getId() == $p->getId()) {
83 80 $previousProject = isset($projects[$i-1]) ? $projects[$i-1] : null;
84 81 $nextProject = isset($projects[$i+1]) ? $projects[$i+1] : null;
85 82 break;
@@ -87,7 +84,7 @@ public function nearbyProjectsAction($categorySlug, $projectSlug)
87 84 $i++;
88 85 }
89 86
90   - return array('category' => $categorySlug, 'previousProject' => $previousProject, 'nextProject' => $nextProject);
  87 + return array('category' => $category, 'previousProject' => $previousProject, 'nextProject' => $nextProject);
91 88 }
92 89
93 90 /**
@@ -120,10 +117,9 @@ private function _findCategoryBySlug($slug)
120 117 private function _findProjectBySlug($slug)
121 118 {
122 119 $em = $this->get('doctrine')->getEntityManager();
123   -
124   - // try find project by slug
125 120 $project = $em->getRepository("StfalconPortfolioBundle:Project")
126 121 ->findOneBy(array('slug' => $slug));
  122 +
127 123 if (!$project) {
128 124 throw new NotFoundHttpException('The project does not exist.');
129 125 }
20 DataFixtures/ORM/LoadProjectData.php
@@ -54,16 +54,16 @@ public function load(ObjectManager $manager)
54 54 $this->addReference('project-eprice', $eprice);
55 55
56 56 for ($i = 0; $i < 6; $i++) {
57   - $eprice = new Project();
58   - $eprice->setName('eprice.kz_' . $i);
59   - $eprice->setSlug('eprice-kz_' . $i);
60   - $eprice->setUrl('http://eprice.kz');
61   - $eprice->setDate(new \DateTime('now'));
62   - $eprice->setDescription('Comparison of the prices of mobile phones, computers, monitors, audio and video in Kazakhstan');
63   - $eprice->setOnFrontPage(0);
64   - $eprice->setOrdernum(2 + $i);
65   - $eprice->addCategory($manager->merge($this->getReference('category-development')));
66   - $manager->persist($eprice);
  57 + $example = new Project();
  58 + $example->setName('example.com_' . $i);
  59 + $example->setSlug('example-com_' . $i);
  60 + $example->setUrl('http://example.com');
  61 + $example->setDate(new \DateTime('now'));
  62 + $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.');
  63 + $example->setOnFrontPage(0);
  64 + $example->setOrdernum(2 + $i);
  65 + $example->addCategory($manager->merge($this->getReference('category-development')));
  66 + $manager->persist($example);
67 67 }
68 68 $manager->flush();
69 69 }
6 Entity/Category.php
@@ -9,7 +9,6 @@
9 9 /**
10 10 * Category entity. It groups projects in portfolio
11 11 *
12   - * @author Stepan Tanasiychuk <ceo@stfalcon.com>
13 12 * @ORM\Table(name="portfolio_categories")
14 13 * @ORM\Entity(repositoryClass="Stfalcon\Bundle\PortfolioBundle\Repository\CategoryRepository")
15 14 */
@@ -55,7 +54,10 @@ class Category
55 54 /**
56 55 * @var Doctrine\Common\Collections\ArrayCollection
57 56 *
58   - * @ORM\ManyToMany(targetEntity="Stfalcon\Bundle\PortfolioBundle\Entity\Project", mappedBy="categories")
  57 + * @ORM\ManyToMany(
  58 + * targetEntity="Stfalcon\Bundle\PortfolioBundle\Entity\Project",
  59 + * mappedBy="categories", fetch="EXTRA_LAZY"
  60 + * )
59 61 * @ORM\OrderBy({"ordernum" = "ASC", "date" = "DESC"})
60 62 */
61 63 private $projects;
24 Entity/Project.php
@@ -13,10 +13,8 @@
13 13 /**
14 14 * Project entity
15 15 *
16   - * @author Stepan Tanasiychuk <ceo@stfalcon.com>
17 16 * @ORM\Table(name="portfolio_projects")
18 17 * @ORM\Entity(repositoryClass="Stfalcon\Bundle\PortfolioBundle\Repository\ProjectRepository")
19   - * @ORM\HasLifecycleCallbacks
20 18 * @Vich\Uploadable
21 19 */
22 20 class Project
@@ -50,7 +48,7 @@ class Project
50 48 private $slug;
51 49
52 50 /**
53   - * @var text $description
  51 + * @var string $description
54 52 *
55 53 * @Assert\NotBlank()
56 54 * @Assert\MinLength(10)
@@ -59,7 +57,7 @@ class Project
59 57 private $description;
60 58
61 59 /**
62   - * @var text $url
  60 + * @var string $url
63 61 *
64 62 * @Assert\Url
65 63 * @ORM\Column(name="url", type="string", length=255, nullable=true)
@@ -90,13 +88,13 @@ class Project
90 88 private $updated;
91 89
92 90 /**
  91 + * @var File $image
  92 + *
93 93 * @Assert\File(
94 94 * maxSize="4M",
95 95 * mimeTypes={"image/png", "image/jpeg", "image/pjpeg"}
96 96 * )
97 97 * @Vich\UploadableField(mapping="project_image", fileNameProperty="image")
98   - *
99   - * @var File $image
100 98 */
101 99 protected $imageFile;
102 100
@@ -116,8 +114,10 @@ class Project
116 114 private $ordernum = 0;
117 115
118 116 /**
119   - * @var bool $onFrontPage
120 117 * Check if this project can be published on main page of the site
  118 + *
  119 + * @var bool $onFrontPage
  120 + *
121 121 * @ORM\Column(name="onFrontPage", type="boolean")
122 122 */
123 123 private $onFrontPage = true;
@@ -138,7 +138,7 @@ class Project
138 138 private $categories;
139 139
140 140 /**
141   - * @var text $users
  141 + * @var string $users
142 142 *
143 143 * @ORM\Column(name="users", type="text", nullable=true)
144 144 */
@@ -177,11 +177,11 @@ public function getCategories()
177 177 /**
178 178 * Add category to project
179 179 *
180   - * @param \Stfalcon\Bundle\PortfolioBundle\Entity\Category $category Category entity
  180 + * @param Category $category Category entity
181 181 *
182 182 * @return void
183 183 */
184   - public function addCategory(\Stfalcon\Bundle\PortfolioBundle\Entity\Category $category)
  184 + public function addCategory(Category $category)
185 185 {
186 186 $this->categories[] = $category;
187 187 }
@@ -465,6 +465,10 @@ public function getOnFrontPage()
465 465 */
466 466 public function setImageFile($imageFile)
467 467 {
  468 + if (null === $imageFile) {
  469 + return;
  470 + }
  471 +
468 472 $this->imageFile = $imageFile;
469 473 $imagine = new Imagine\Gd\Imagine();
470 474 $imagePath = $imagine->open($this->imageFile->getPathName());
2  Naming/ProjectNaming.php
@@ -9,6 +9,8 @@
9 9 class ProjectNaming implements NamerInterface
10 10 {
11 11 /**
  12 + * Generate unique name for project image
  13 + *
12 14 * @param Project $obj
13 15 * @param string $field
14 16 *
7 Repository/CategoryRepository.php
@@ -5,12 +5,7 @@
5 5 use Doctrine\ORM\EntityRepository;
6 6
7 7 /**
8   - * CategoryRepository
9   - *
10   - * This class was generated by the Doctrine ORM. Add your own custom
11   - * repository methods below.
12   - *
13   - * @author Stepan Tanasiychuk <ceo@stfalcon.com>
  8 + * Category Repository
14 9 */
15 10 class CategoryRepository extends EntityRepository
16 11 {
57 Repository/ProjectRepository.php
@@ -6,74 +6,39 @@
6 6 use Stfalcon\Bundle\PortfolioBundle\Entity\Category;
7 7
8 8 /**
9   - * ProjectRepository
10   - *
11   - * @author Stepan Tanasiychuk <ceo@stfalcon.com>
  9 + * Project Repository
12 10 */
13 11 class ProjectRepository extends EntityRepository
14 12 {
15   - /**
16   - * Get all projects from this category
17   - *
18   - * @param Category $category A category object
19   - *
20   - * @return array
21   - */
22   - public function getProjectsByCategory(Category $category)
23   - {
24   - $query = $this->getEntityManager()
25   - ->createQuery('SELECT p FROM StfalconPortfolioBundle:Project p
26   - JOIN p.categories c WHERE c.id = ?1 ORDER BY p.ordernum ASC');
27   - $query->setParameter(1, $category->getId());
28   -
29   - return $query->getResult();
30   - }
31 13
32 14 /**
33   - * Get all projects
  15 + * Get query for select projects by category
34 16 *
35   - * @return array
36   - */
37   - public function getAllProjects()
38   - {
39   - $query = $this->getEntityManager()
40   - ->createQuery('SELECT p FROM StfalconPortfolioBundle:Project p
41   - ORDER BY p.ordernum ASC');
42   -
43   - return $query->getResult();
44   - }
45   -
46   - /**
47   - * Project Query For Pagination
48   - * @param int $categoryId
  17 + * @param Category $category
49 18 *
50 19 * @return Doctrine\ORM\Query
51 20 */
52   - public function getProjectsQueryForPagination($categoryId = 0)
  21 + public function getQueryForSelectProjectsByCategory(Category $category)
53 22 {
54 23 return $this->createQueryBuilder('p')
55 24 ->select('p')
56 25 ->join('p.categories', 'c')
57 26 ->where('c.id = ?1')
58 27 ->orderBy('p.ordernum', 'ASC')
59   - ->setParameter(1, $categoryId)
  28 + ->setParameter(1, $category->getId())
60 29 ->getQuery();
61 30 }
62 31
63 32 /**
64   - * get projects for index page
65   - * @param Category $category
  33 + * Get all projects from this category
  34 + *
  35 + * @param Category $category A category object
66 36 *
67 37 * @return array
68 38 */
69   - public function getIndexPageProjectsForCategory(Category $category)
  39 + public function getProjectsByCategory(Category $category)
70 40 {
71   - $query = $this->getEntityManager()
72   - ->createQuery('SELECT p FROM StfalconPortfolioBundle:Project p
73   - JOIN p.categories c WHERE c.id = ?1 AND p.onFrontPage = 1
74   - ORDER BY p.ordernum ASC');
75   - $query->setParameter(1, $category->getId());
76   -
77   - return $query->getResult();
  41 + return $this->getQueryForSelectProjectsByCategory($category)
  42 + ->getResult();
78 43 }
79 44 }
20 Resources/views/Category/projects.html.twig
... ... @@ -1,20 +0,0 @@
1   -{% extends 'StfalconPortfolioBundle::layout.html.twig' %}
2   -
3   -{% block content %}
4   - <h4>Projects in category: {{ category.getName }}</h4>
5   - {% if category.getProjects.count > 0 %}
6   - <ul id="listProjects">
7   - {% for project in category.getProjects %}
8   - <li>
9   - {{ project.name }}
10   - (<a href="{{ path('portfolioProjectEdit', { 'slug': project.slug }) }}">Edit project</a>
11   - / <a href="{{ path('portfolioProjectDelete', { 'slug': project.slug }) }}">Delete project</a>)
12   - </li>
13   - {% endfor %}
14   - </ul>
15   - {% else %}
16   - <div class="info">
17   - There are no projects in this category
18   - </div>
19   - {% endif %}
20   -{% endblock %}{# empty Twig template #}
6 Resources/views/Category/services.html.twig
... ... @@ -1,20 +1,21 @@
1 1 <h2>
2 2 {% trans %}Услуги{% endtrans %}
3 3 </h2>
  4 +
4 5 <div id="accordion" class="servises">
5 6 {% for category in categories %}
6 7 {% if category.projects.count %}
7 8 <h3>{{ category.name }}</h3>
8 9 <ul>
9 10 {% for project in category.projects %}
10   - {% if currentProject.id is defined and currentProject.id == project.id
  11 + {% if currentProject.id is defined and currentProject.id == project.id
11 12 and currentCategory.id is defined and currentCategory.id == category.id %}
12 13 <li class="active {category_index:{{ loop.parent.loop.index0 }} }">
13 14 {{ project.name }}
14 15 </li>
15 16 {% else %}
16 17 <li>
17   - <a href="{{ path('portfolioCategoryProjectView', {'categorySlug': category.slug, 'projectSlug': project.slug }) }}">
  18 + <a href="{{ path('portfolio_project_view', {'categorySlug': category.slug, 'projectSlug': project.slug }) }}">
18 19 {{ project.name }}
19 20 </a>
20 21 </li>
@@ -24,5 +25,4 @@
24 25 {% endif %}
25 26 {% endfor %}
26 27 <div class="clear"></div>
27   -
28 28 </div>
4 Resources/views/Category/view.html.twig
... ... @@ -1,4 +1,4 @@
1   -{% extends 'StfalconPortfolioBundle::internal.html.twig' %}
  1 +{% extends 'StfalconPortfolioBundle::layout.html.twig' %}
2 2
3 3 {% block content %}
4 4 <h1>{{ category.name }}</h1>
@@ -11,7 +11,7 @@
11 11 <ul class="projects">
12 12 {% for project in paginator %}
13 13 <li>
14   - <a href="{{ path('portfolioCategoryProjectView', { 'categorySlug': category.slug, 'projectSlug': project.slug }) }}">
  14 + <a href="{{ path('portfolio_project_view', { 'categorySlug': category.slug, 'projectSlug': project.slug }) }}">
15 15 <span>
16 16 <img src="/uploads/portfolio/projects/{{ project.image }}" width="240" height="198"
17 17 alt="{{ project.name }}" title="{{ project.name }}" class="project-thumb" />
12 Resources/views/Project/nearbyProjects.html.twig
... ... @@ -1,27 +1,25 @@
1   -<!--pagination for project-->
2 1 <div class="next-prev-projects">
3 2 <div class="next">
4 3 {% if nextProject %}
5   - <a href="{{ path('portfolioCategoryProjectView', { 'categorySlug': category.slug, 'projectSlug': nextProject.slug }) }}">
  4 + <a href="{{ path('portfolio_project_view', { 'categorySlug': category.slug, 'projectSlug': nextProject.slug }) }}">
6 5 {{ "Следующий проект"|trans }} →
7 6 </a>
8 7 <br />
9 8 {{ nextProject.name }}
10 9 {% else %}
11   - Следующий проект
  10 + {{ "Следующий проект"|trans }}
12 11 {% endif %}
13 12 </div>
14 13
15 14 <div class="prev">
16 15 {% if previousProject %}
17   - <a href="{{ path('portfolioCategoryProjectView', { 'categorySlug': category.slug, 'projectSlug': previousProject.slug }) }}">
  16 + <a href="{{ path('portfolio_project_view', { 'categorySlug': category.slug, 'projectSlug': previousProject.slug }) }}">
18 17 ← {{ "Предыдущий проект"|trans }}
19 18 </a>
20 19 <br />
21 20 {{ previousProject.name }}
22 21 {% else %}
23   - ← Предыдущий проект
  22 + ← {{ "Предыдущий проект"|trans }}
24 23 {% endif %}
25 24 </div>
26   -</div>
27   -<!--pagination for project-->
  25 +</div>
2  Resources/views/Project/view.html.twig
... ... @@ -1,4 +1,4 @@
1   -{% extends 'StfalconPortfolioBundle::internal.html.twig' %}
  1 +{% extends 'StfalconPortfolioBundle::layout.html.twig' %}
2 2
3 3 {% block title %}{{ parent() }} / {{ project.name }}{% endblock %}
4 4
1  Resources/views/list.html.twig → Resources/views/ProjectAdmin/list.html.twig
... ... @@ -1,4 +1,5 @@
1 1 {% extends 'SonataAdminBundle:CRUD:base_list.html.twig' %}
  2 +
2 3 {% block javascripts %}
3 4 {{ parent() }}
4 5 <script type="text/javascript" >
1  Resources/views/internal.html.twig
... ... @@ -1 +0,0 @@
1   -{% extends '::internal.html.twig' %}
22 Resources/views/layout.html.twig
... ... @@ -1,21 +1 @@
1   -{% extends '::layout.html.twig' %}
2   -
3   -{% block javascripts %}
4   - {{ parent() }}
5   -
6   - <script type="text/javascript" >
7   - $(document).ready(function() {
8   - $("#projects-sortable").sortable({
9   - placeholder: "ui-state-highlight",
10   - update: function(event, ui) {
11   - var array = [];
12   - $(this).find('li').each(function(index){
13   - array.push({id: $(this).attr('data-id'), index: index});
14   - });
15   - $.post('{{ path('portfolioProjectsApplyOrder') }}', {projects: array}, function(response){});
16   - }
17   - });
18   - $("#projects-sortable").disableSelection();
19   - });
20   - </script>
21   -{% endblock %}
  1 +{% extends '::internal.html.twig' %}
8 Tests/Controller/CategoryControllerTest.php
@@ -120,7 +120,7 @@ public function testViewCategory()
120 120 {
121 121 $this->loadFixtures(array('Stfalcon\Bundle\PortfolioBundle\DataFixtures\ORM\LoadCategoryData'));
122 122 $crawler = $this->fetchCrawler(
123   - $this->getUrl('portfolioCategoryView', array('slug' => 'web-development')), 'GET', true, true
  123 + $this->getUrl('portfolio_category_view', array('slug' => 'web-development')), 'GET', true, true
124 124 );
125 125
126 126 $this->assertEquals(1, $crawler->filter('html:contains("Web Development")')->count());
@@ -132,7 +132,7 @@ public function testViewNonExistCategory()
132 132 {
133 133 $this->loadFixtures(array());
134 134 $client = $this->makeClient(true);
135   - $crawler = $client->request('GET', $this->getUrl('portfolioCategoryView', array('slug' => 'web-design')));
  135 + $crawler = $client->request('GET', $this->getUrl('portfolio_category_view', array('slug' => 'web-design')));
136 136
137 137 // check 404
138 138 $this->assertEquals(404, $client->getResponse()->getStatusCode());
@@ -223,13 +223,13 @@ public function testPortfolioPagination()
223 223 'Stfalcon\Bundle\PortfolioBundle\DataFixtures\ORM\LoadProjectData'
224 224 ));
225 225 $crawler = $this->fetchCrawler(
226   - $this->getUrl('portfolioCategoryView', array('slug' => 'web-development')), 'GET', true, true
  226 + $this->getUrl('portfolio_category_view', array('slug' => 'web-development')), 'GET', true, true
227 227 );
228 228 $this->assertEquals(1, $crawler->filter('.pagination .current:contains("1")')->count());
229 229 $this->assertEquals(6, $crawler->filter('img.project-thumb')->count());
230 230
231 231 $crawler = $this->fetchCrawler(
232   - $this->getUrl('portfolioCategoryView', array('slug' => 'web-development', 'page'=> 2)), 'GET', true, true
  232 + $this->getUrl('portfolio_category_view', array('slug' => 'web-development', 'page'=> 2)), 'GET', true, true
233 233 );
234 234 $this->assertEquals(1, $crawler->filter('.pagination .current:contains("2")')->count());
235 235 $this->assertEquals(2, $crawler->filter('img.project-thumb')->count());
21 Tests/Controller/ProjectControllerTest.php
@@ -41,7 +41,8 @@ public function testProjectsList()
41 41
42 42 // check display projects
43 43 $this->assertEquals(1, $crawler->filter('table tbody tr td:contains("preorder.it")')->count());
44   - $this->assertEquals(7, $crawler->filter('table tbody tr td:contains("eprice.kz")')->count());
  44 + $this->assertEquals(1, $crawler->filter('table tbody tr td:contains("eprice.kz")')->count());
  45 + $this->assertEquals(6, $crawler->filter('table tbody tr td:contains("example.com")')->count());
45 46 }
46 47
47 48 public function testCreateValidProject()
@@ -50,14 +51,12 @@ public function testCreateValidProject()
50 51 $client = $this->makeClient(true);
51 52 $crawler = $client->request('GET', $this->getUrl('admin_bundle_portfolio_project_create', array()));
52 53
53   - $inputs = $crawler->filter('form input');
54   - $inputs->first();
55   - $formId = str_replace("_slug", "", $inputs->current()->getAttribute('id'));
  54 + $form = $crawler->selectButton('Создать и редактировать')->form();
56 55
57 56 $em = $this->getContainer()->get('doctrine')->getEntityManager();
58 57 $category = $em->getRepository("StfalconPortfolioBundle:Category")->findOneBy(array('slug' => 'web-development'));
59 58
60   - $form = $crawler->selectButton('Создать и редактировать')->form();
  59 + $formId = substr($form->getUri(), -14);
61 60
62 61 $form[$formId . '[name]'] = 'wallpaper.in.ua';
63 62 $form[$formId . '[slug]'] = 'wallpaper-in-ua';
@@ -70,9 +69,9 @@ public function testCreateValidProject()
70 69 $crawler = $client->submit($form);
71 70
72 71 // check redirect to list of categories
73   -// $this->assertTrue($client->getResponse()->isRedirect());
74 72 $this->assertTrue($client->getResponse()->isRedirect($this->getUrl('admin_bundle_portfolio_project_edit', array('id' => 1) )));
75 73
  74 + // @todo дальше лишние проверки. достаточно проверить или проект создался в БД
76 75 $crawler = $client->followRedirect();
77 76
78 77 // check responce
@@ -131,7 +130,7 @@ public function testViewProject()
131 130
132 131 $crawler = $this->fetchCrawler(
133 132 $this->getUrl(
134   - 'portfolioCategoryProjectView',
  133 + 'portfolio_project_view',
135 134 array('categorySlug' => 'web-development', 'projectSlug' => 'preorder-it')
136 135 ), 'GET', true, true);
137 136
@@ -142,7 +141,7 @@ public function testViewProject()
142 141 $this->assertEquals(1, $crawler->filter('html:contains("' . $description . '")')->count());
143 142 $this->assertEquals(1, $crawler->filter('a[href="http://preorder.it"]')->count());
144 143
145   - $epriceUrl = $this->getUrl('portfolioCategoryProjectView',
  144 + $epriceUrl = $this->getUrl('portfolio_project_view',
146 145 array('categorySlug' => 'web-development', 'projectSlug' => 'eprice-kz'));
147 146 // check display prev/next project url
148 147 $this->assertEquals(1, $crawler->filter('#content a[href="' . $epriceUrl . '"]')->count());
@@ -161,14 +160,12 @@ public function testFilledProjectUsersList()
161 160 // Check project preorder.it
162 161 $crawler = $this->fetchCrawler(
163 162 $this->getUrl(
164   - 'portfolioCategoryProjectView', array('categorySlug' => 'web-development', 'projectSlug' => 'preorder-it')
  163 + 'portfolio_project_view', array('categorySlug' => 'web-development', 'projectSlug' => 'preorder-it')
165 164 ), 'GET', true, true);
166 165
167   -
168 166 // check display project info
169 167 $this->assertEquals(1, $crawler->filter('html:contains("Над проектом работали")')->count());
170 168 $this->assertEquals(1, $crawler->filter('html #sidebar dl>dt:contains("art-director and designer")')->count());
171   -
172 169 }
173 170
174 171 public function testEmptyProjectUsersList()
@@ -181,7 +178,7 @@ public function testEmptyProjectUsersList()
181 178 // Check project eprice.kz
182 179 $crawler = $this->fetchCrawler(
183 180 $this->getUrl(
184   - 'portfolioCategoryProjectView', array('categorySlug' => 'web-development', 'projectSlug' => 'eprice-kz')
  181 + 'portfolio_project_view', array('categorySlug' => 'web-development', 'projectSlug' => 'eprice-kz')
185 182 ), 'GET', true, true);
186 183
187 184
4 Tests/Menu/MenuBuilderTest.php
@@ -39,9 +39,9 @@ protected function _testBreadcrumbsMenuForProject($projectSlug, $itemContent)
39 39 {
40 40 $client = $this->createClient();
41 41
42   - $projectListUrl = $this->getUrl('portfolioCategoryView', array('slug' => 'web-development'));
  42 + $projectListUrl = $this->getUrl('portfolio_category_view', array('slug' => 'web-development'));
43 43
44   - $crawler = $client->request('GET', $this->getUrl('portfolioCategoryProjectView', array(
  44 + $crawler = $client->request('GET', $this->getUrl('portfolio_project_view', array(
45 45 'categorySlug' => 'web-development',
46 46 'projectSlug' => $projectSlug
47 47 )));

0 comments on commit 22a901a

Please sign in to comment.
Something went wrong with that request. Please try again.