[Beeframework-svn] SF.net SVN: beeframework:[243] trunk/framework/Bee
Brought to you by:
b_hartmann,
m_plomer
From: <m_p...@us...> - 2014-10-05 23:57:49
|
Revision: 243 http://sourceforge.net/p/beeframework/code/243 Author: m_plomer Date: 2014-10-05 23:57:40 +0000 (Sun, 05 Oct 2014) Log Message: ----------- Persistence: introduced JsonSerializable subclass of Doctrine2 Paginator Modified Paths: -------------- trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php Added Paths: ----------- trunk/framework/Bee/Persistence/Doctrine2/JsonSerializablePaginator.php trunk/framework/Bee/Utils/IJsonSerializable.php Modified: trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php 2014-10-01 18:36:44 UTC (rev 242) +++ trunk/framework/Bee/Persistence/Doctrine2/DaoBase.php 2014-10-05 23:57:40 UTC (rev 243) @@ -154,7 +154,7 @@ if (!is_null($orderAndLimitHolder) && $orderAndLimitHolder->getPageSize() > 0) { $q->setFirstResult($orderAndLimitHolder->getCurrentPage() * $orderAndLimitHolder->getPageSize()); $q->setMaxResults($orderAndLimitHolder->getPageSize()); - $paginator = new Paginator($q, $this->useWhereInPagination()); + $paginator = new JsonSerializablePaginator($q, $this->useWhereInPagination()); $paginator->setUseOutputWalkers(false); $orderAndLimitHolder->setResultCount(count($paginator)); return $paginator; Added: trunk/framework/Bee/Persistence/Doctrine2/JsonSerializablePaginator.php =================================================================== --- trunk/framework/Bee/Persistence/Doctrine2/JsonSerializablePaginator.php (rev 0) +++ trunk/framework/Bee/Persistence/Doctrine2/JsonSerializablePaginator.php 2014-10-05 23:57:40 UTC (rev 243) @@ -0,0 +1,16 @@ +<?php +namespace Bee\Persistence\Doctrine2; + +use Doctrine\ORM\Tools\Pagination\Paginator; +use Bee\Utils\IJsonSerializable; + +/** + * Class JsonSerializablePaginator + * @package Bee\Tools\Entities + */ +class JsonSerializablePaginator extends Paginator implements IJsonSerializable { + + public function jsonSerialize() { + return $this->getIterator()->getArrayCopy(); + } +} \ No newline at end of file Added: trunk/framework/Bee/Utils/IJsonSerializable.php =================================================================== --- trunk/framework/Bee/Utils/IJsonSerializable.php (rev 0) +++ trunk/framework/Bee/Utils/IJsonSerializable.php 2014-10-05 23:57:40 UTC (rev 243) @@ -0,0 +1,13 @@ +<?php +namespace Bee\Utils; + +/** + * Interface IJsonSerializable + * @package Iter8\Utils + */ +interface IJsonSerializable { + /** + * @return mixed + */ + function jsonSerialize(); +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |