# HG changeset patch # User ymh # Date 1411718603 -7200 # Node ID 550862f07e6a3c222b20b63dc86cb78fc483a7ec # Parent 077ea5b34caf96e5c4ecd44ad1fb72e2c42a55f1 Add version file and add parameter to Entity/DocumentTagRepository::findOrderedTagsForDoc to control data hydration diff -r 077ea5b34caf -r 550862f07e6a Entity/DocumentTagRepository.php --- a/Entity/DocumentTagRepository.php Mon Jul 07 17:27:21 2014 +0200 +++ b/Entity/DocumentTagRepository.php Fri Sep 26 10:03:23 2014 +0200 @@ -10,6 +10,7 @@ namespace IRI\Bundle\WikiTagBundle\Entity; +use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; @@ -26,14 +27,19 @@ class DocumentTagRepository extends EntityRepository { /** - * Find ordered tags by document id + * Find ordered document tags by document id. + * Allow to control the hydration mode of the returned data (c.f. Doctrine\ORM\AbstractQuery::HYDRATE_*) + * + * @param mixed $doc_id The document id + * @param int $hydrationMode Value from Doctrine\ORM\AbstractQuery::HYDRATE_*. + * @return array (c.f from Doctrine\ORM\AbstractQuery::get_result()) */ - public function findOrderedTagsForDoc($doc_id) + public function findOrderedTagsForDoc($doc_id, $hydrationMode=AbstractQuery::HYDRATE_OBJECT) { return $this->getEntityManager() - ->createQuery("SELECT doctag FROM WikiTagBundle:DocumentTag doctag JOIN doctag.document doc WHERE doc.externalId=:doc_id ORDER BY doctag.tagOrder ASC") + ->createQuery("SELECT doctag, tag FROM WikiTagBundle:DocumentTag doctag JOIN doctag.tag tag JOIN doctag.document doc WHERE doc.externalId=:doc_id ORDER BY doctag.tagOrder ASC") ->setParameter("doc_id", strval($doc_id)) - ->getResult(); + ->getResult($hydrationMode); } private function findMaxOrderInUow($entityList, $doc_id, $max_order) { @@ -128,4 +134,4 @@ } } -} \ No newline at end of file +} diff -r 077ea5b34caf -r 550862f07e6a Version.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Version.php Fri Sep 26 10:03:23 2014 +0200 @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace IRI\Bundle\WikiTagBundle; + +/** + * Class to store and retrieve WikiTagBundle Version + * + */ +class Version { + + /** + * Current WikiTagBundle Version + */ + const VERSION = '0.18'; + + /** + * Compares a WikiTagBundlee version with the current one. + * + * @param string $version WikiTageBundle version to compare. + * @return int Returns -1 if older, 0 if it is the same, 1 if version + * passed as argument is newer. + */ + public static function compare($version) + { + $currentVersion = str_replace(' ', '', strtolower(self::VERSION)); + $version = str_replace(' ', '', $version); + + return version_compare($version, $currentVersion); + } + +}