Add de/serialization methods for collection caching

This commit is contained in:
Thibaud Fabre
2015-07-09 12:25:30 +02:00
parent ea6a4fdbf0
commit 2623f39488
5 changed files with 78 additions and 19 deletions

View File

@@ -236,6 +236,16 @@ EOT;
return $collection;
}
/**
* @var Application
*/
protected $app;
/**
* @var databox
*/
protected $databox;
/**
* @var CollectionReference
*/
@@ -261,21 +271,17 @@ EOT;
*/
protected $labels = [];
/**
* @var databox
*/
protected $databox;
/**
* @var int[]|string
*/
protected $binary_logo;
/**
* @var Application
* @param Application $app
* @param $baseId
* @param CollectionReference $reference
* @param array $row
*/
protected $app;
public function __construct(Application $app, $baseId, CollectionReference $reference, array $row)
{
$this->app = $app;
@@ -295,6 +301,24 @@ EOT;
];
}
public function __sleep()
{
return array(
'reference',
'name',
'preferences',
'pub_wm',
'labels',
'binary_logo'
);
}
public function hydrate(Application $app)
{
$this->app = $app;
$this->databox = $app->getApplicationBox()->get_databox($this->reference->getDataboxId());
}
private function dispatch($eventName, CollectionEvent $event)
{
$this->app['dispatcher']->dispatch($eventName, $event);