Skip to content

Instantly share code, notes, and snippets.

@nickpeirson
Last active August 29, 2015 14:06
Show Gist options
  • Save nickpeirson/9478538351a240e73229 to your computer and use it in GitHub Desktop.
Save nickpeirson/9478538351a240e73229 to your computer and use it in GitHub Desktop.
<?php
namespace CG\Di\Definition\RuntimeDefinition;
use CG\Di\Definition\RuntimeDefinition;
use Zend\Di\Definition\IntrospectionStrategy;
use Zend\Cache\Storage\StorageInterface;
use Zend\Cache\Storage\Adapter\Memory;
class Cache extends RuntimeDefinition
{
protected $cache;
public function __construct(
IntrospectionStrategy $introspectionStrategy = null,
array $explicitClasses = null,
StorageInterface $cache = null
) {
parent::__construct($introspectionStrategy = null, $explicitClasses = null);
if (is_null($cache)) {
return;
}
$this->cache = $cache;
register_shutdown_function([$this, 'persistDefinitions']);
}
public function persistDefinitions()
{
$this->cache->setItem(
'classes',
array_merge(
$this->classes,
$this->cache->getItem('classes')
);
);
}
}
<?php
$definitions = new ArrayDefinition($cache->getItem('classes'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment