Skip to content
Browse files

Facade: added cache

  • Loading branch information...
1 parent db8213b commit 4befb9424d02a858e18755618aa428bec4d9ae64 @kolinger committed Dec 28, 2012
Showing with 23 additions and 5 deletions.
  1. +23 −5 Model/Facade.php
View
28 Model/Facade.php
@@ -21,8 +21,9 @@
abstract class Facade extends \Nette\Object
{
- const FLUSH = true;
- const WITHOUT_FLUSH = false;
+ const CACHE_NAMESPACE = 'Square.Model';
+ const FLUSH = true,
+ WITHOUT_FLUSH = false;
/**
* @var \Doctrine\ORM\EntityManager
@@ -34,16 +35,23 @@
*/
private $repository;
+ /**
+ * @var \Nette\Caching\Cache
+ */
+ private $cache;
+
/**
- * @param \Doctrine\ORM\EntityRepository
- * @param \Doctrine\ORM\EntityManager
+ * @param \Doctrine\ORM\EntityRepository $repository
+ * @param \Doctrine\ORM\EntityManager $entityManager
+ * @param \Nette\Caching\IStorage $storage
*/
- public function __construct(\Doctrine\ORM\EntityRepository $repository, \Doctrine\ORM\EntityManager $entityManager)
+ public function __construct(\Doctrine\ORM\EntityRepository $repository, \Doctrine\ORM\EntityManager $entityManager, \Nette\Caching\IStorage $storage)
{
$this->entityManager = $entityManager;
$this->repository = $repository;
+ $this->cache = new \Nette\Caching\Cache($storage, self::CACHE_NAMESPACE);
}
@@ -69,6 +77,16 @@ public function getRepository()
/**
+ * @return \Nette\Caching\Cache
+ */
+ public function getCache()
+ {
+ return $this->cache;
+ }
+
+
+
+ /**
* @return object
*/
public function create()

0 comments on commit 4befb94

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