]> Raphaƫl G. Git Repositories - blogbundle/blobdiff - Repository/KeywordRepository.php
Version 0.0.2
[blogbundle] / Repository / KeywordRepository.php
index f531711d1b189ac22243988c7c55efb5eaf50ab4..db25c18c4313577732e0b9ff62f63af924702a93 100644 (file)
@@ -13,13 +13,15 @@ namespace Rapsys\BlogBundle\Repository;
 
 use Doctrine\ORM\Query\ResultSetMapping;
 
+use Rapsys\BlogBundle\Repository;
+
 /**
  * KeywordRepository
  *
  * This class was generated by the Doctrine ORM. Add your own custom
  * repository methods below.
  */
-class KeywordRepository extends EntityRepository {
+class KeywordRepository extends Repository {
        /**
         * Find keyword count as int
         *
@@ -46,7 +48,7 @@ SQL;
                $rsm->addScalarResult('count', 'count', 'integer');
 
                //Get result
-               return $this->_em
+               return $this->manager
                        ->createNativeQuery($req, $rsm)
                        ->getSingleScalarResult();
        }
@@ -72,7 +74,7 @@ SELECT
 FROM RapsysBlogBundle:Keyword AS k
 JOIN RapsysBlogBundle:KeywordTranslation AS kt ON (kt.keyword_id = k.id AND kt.locale = :locale)
 GROUP BY k.id
-ORDER BY updated, created DESC
+ORDER BY updated, created DESC, k.id
 LIMIT :offset, :count
 SQL;
 
@@ -90,13 +92,13 @@ SQL;
                        ->addScalarResult('description', 'description', 'string')
                        ->addScalarResult('slug', 'slug', 'string')
                        ->addScalarResult('title', 'title', 'string')
-                       ->addScalarResult('created', 'created', 'datetime')
-                       ->addScalarResult('updated', 'updated', 'datetime')
-                       ->addScalarResult('modified', 'modified', 'datetime')
+                       ->addScalarResult('created', 'created', 'datetime_immutable')
+                       ->addScalarResult('updated', 'updated', 'datetime_immutable')
+                       ->addScalarResult('modified', 'modified', 'datetime_immutable')
                        ->addIndexByScalar('id');
 
                //Get result
-               $result = $this->_em
+               $result = $this->manager
                        ->createNativeQuery($req, $rsm)
                        ->setParameter('offset', $page * $count)
                        ->setParameter('count', $count)
@@ -116,7 +118,7 @@ SQL;
                                'created' => $data['created'],
                                'updated' => $data['updated'],
                                'modified' => $data['modified'],
-                               'link' => $this->router->generate('rapsys_blog_keyword_view', ['id' => $id, 'slug' => $slug])
+                               'link' => $this->router->generate('rapsysblog_keyword_view', ['id' => $id, 'slug' => $slug])
                        ];
                }
 
@@ -230,12 +232,12 @@ SQL;
                        ->addScalarResult('ckt_locales', 'ckt_locales', 'string')
                        ->addScalarResult('ckt_slugs', 'ckt_slugs', 'string')
                        ->addScalarResult('ckt_titles', 'ckt_titles', 'string')
-                       ->addScalarResult('created', 'created', 'datetime')
-                       ->addScalarResult('updated', 'updated', 'datetime')
-                       ->addScalarResult('modified', 'modified', 'datetime');
+                       ->addScalarResult('created', 'created', 'datetime_immutable')
+                       ->addScalarResult('updated', 'updated', 'datetime_immutable')
+                       ->addScalarResult('modified', 'modified', 'datetime_immutable');
 
                //Get data
-               $data = $this->_em
+               $data = $this->manager
                        ->createNativeQuery($req, $rsm)
                        ->setParameter('id', $id)
                        ->getOneOrNullResult();
@@ -249,7 +251,7 @@ SQL;
                        'created' => $data['created'],
                        'updated' => $data['updated'],
                        'modified' => $data['modified'],
-                       'link' => $this->router->generate('rapsys_blog_keyword_view', ['id' => $id, 'slug' => $slug]),
+                       'link' => $this->router->generate('rapsysblog_keyword_view', ['id' => $id, 'slug' => $slug]),
                        'alternates' => [],
                        'articles' => []
                ];
@@ -273,7 +275,7 @@ SQL;
                                'description' => $data['a_descriptions'][$k],
                                'slug' => $slug = $data['a_slugs'][$k],
                                'title' => $data['a_titles'][$k],
-                               'link' => $this->router->generate('rapsys_blog_article_view', ['id' => $aid, 'slug' => $slug]),
+                               'link' => $this->router->generate('rapsysblog_article_view', ['id' => $aid, 'slug' => $slug]),
                                'keywords' => []
                        ];
                }
@@ -296,7 +298,7 @@ SQL;
                                'id' => $data['ak_kids'][$k],
                                'slug' => $slug = $data['ak_slugs'][$k],
                                'title' => $data['ak_titles'][$k],
-                               'link' => $this->router->generate('rapsys_blog_keyword_view', ['id' => $data['ak_kids'][$k], 'slug' => $slug]),
+                               'link' => $this->router->generate('rapsysblog_keyword_view', ['id' => $data['ak_kids'][$k], 'slug' => $slug]),
                        ];
                }
 
@@ -314,7 +316,7 @@ SQL;
                                'locale' => $locale,
                                'slug' => $slug = $data['ckt_slugs'][$k],
                                'title' => $data['ckt_titles'][$k],
-                               'link' => $this->router->generate('rapsys_blog_keyword_view', ['_locale' => $locale, 'id' => $id, 'slug' => $slug]),
+                               'link' => $this->router->generate('rapsysblog_keyword_view', ['_locale' => $locale, 'id' => $id, 'slug' => $slug]),
                        ];
                }