Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Resolved merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 15 changed files with 326 additions and 397 deletions.
56 changes: 0 additions & 56 deletions src/PatternBroker.php

This file was deleted.

40 changes: 19 additions & 21 deletions src/PatternFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@

namespace Zend\Cache;

use Traversable,
Zend\Loader\Broker,
Zend\Stdlib\ArrayUtils;
use Traversable;
use Zend\Stdlib\ArrayUtils;

/**
* @category Zend
Expand All @@ -33,11 +32,11 @@
class PatternFactory
{
/**
* The pattern broker
* The pattern manager
*
* @var null|Broker
* @var null|PatternPluginManager
*/
protected static $broker = null;
protected static $plugins = null;

/**
* Instantiate a cache pattern
Expand Down Expand Up @@ -68,44 +67,43 @@ public static function factory($patternName, $options = array())
return $patternName;
}

$pattern = static::getBroker()->load($patternName);
$pattern = static::getPluginManager()->get($patternName);
$pattern->setOptions($options);
return $pattern;
}

/**
* Get the pattern broker
* Get the pattern plugin manager
*
* @return Broker
* @return PatternPluginManager
*/
public static function getBroker()
public static function getPluginManager()
{
if (static::$broker === null) {
static::$broker = new PatternBroker();
static::$broker->setRegisterPluginsOnLoad(false);
if (static::$plugins === null) {
static::$plugins = new PatternPluginManager();
}

return static::$broker;
return static::$plugins;
}

/**
* Set the pattern broker
* Set the pattern plugin manager
*
* @param Broker $broker
* @param PatternPluginManager $plugins
* @return void
*/
public static function setBroker(Broker $broker)
public static function setPluginManager(PatternPluginManager $plugins)
{
static::$broker = $broker;
static::$plugins = $plugins;
}

/**
* Reset pattern broker to default
* Reset pattern plugin manager to default
*
* @return void
*/
public static function resetBroker()
public static function resetPluginManager()
{
static::$broker = null;
static::$plugins = null;
}
}
46 changes: 41 additions & 5 deletions src/PatternLoader.php → src/PatternPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,63 @@

namespace Zend\Cache;

use Zend\Loader\PluginClassLoader;
use Zend\ServiceManager\AbstractPluginManager;

/**
* Plugin Class Loader implementation for cache patterns.
* Plugin manager implementation for cache pattern adapters
*
* Enforces that adatpers retrieved are instances of
* Pattern\PatternInterface. Additionally, it registers a number of default
* patterns available.
*
* @category Zend
* @package Zend_Cache
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class PatternLoader extends PluginClassLoader
class PatternPluginManager extends AbstractPluginManager
{
/**
* @var array Pre-aliased adapters
* Default set of adapters
*
* @var array
*/
protected $plugins = array(
protected $invokableClasses = array(
'callback' => 'Zend\Cache\Pattern\CallbackCache',
'capture' => 'Zend\Cache\Pattern\CaptureCache',
'class' => 'Zend\Cache\Pattern\ClassCache',
'object' => 'Zend\Cache\Pattern\ObjectCache',
'output' => 'Zend\Cache\Pattern\OutputCache',
'page' => 'Zend\Cache\Pattern\PageCache',
);

/**
* Don't share by default
*
* @var array
*/
protected $shareByDefault = false;

/**
* Validate the plugin
*
* Checks that the pattern adapter loaded is an instance of Pattern\PatternInterface.
*
* @param mixed $plugin
* @return void
* @throws Exception\RuntimeException if invalid
*/
public function validatePlugin($plugin)
{
if ($plugin instanceof Pattern\PatternInterface) {
// we're okay
return;
}

throw new Exception\RuntimeException(sprintf(
'Plugin of type %s is invalid; must implement %s\Pattern\PatternInterface',
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
__NAMESPACE__
));
}
}
19 changes: 12 additions & 7 deletions src/Storage/Adapter/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
Zend\Cache\Storage\IterableInterface,
Zend\Cache\Storage\AvailableSpaceCapableInterface,
Zend\Cache\Storage\OptimizableInterface,
Zend\Cache\Storage\TagableInterface,
Zend\Cache\Storage\TaggableInterface,
Zend\Cache\Storage\TotalSpaceCapableInterface,
Zend\Cache\Utils,
Zend\Stdlib\ErrorHandler;
Expand All @@ -48,11 +48,16 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Filesystem
extends AbstractAdapter
implements FlushableInterface, ClearExpiredInterface, ClearByNamespaceInterface, ClearByPrefixInterface,
TagableInterface, IterableInterface, OptimizableInterface,
AvailableSpaceCapableInterface, TotalSpaceCapableInterface
class Filesystem extends AbstractAdapter implements
AvailableSpaceCapableInterface,
ClearByNamespaceInterface,
ClearByPrefixInterface,
ClearExpiredInterface,
FlushableInterface,
IterableInterface,
OptimizableInterface,
TaggableInterface,
TotalSpaceCapableInterface
{

/**
Expand Down Expand Up @@ -253,7 +258,7 @@ public function clearByPrefix($prefix)
return true;
}

/* TagableInterface */
/* TaggableInterface */

/**
* Set tags to an item by given key.
Expand Down
16 changes: 10 additions & 6 deletions src/Storage/Adapter/Memory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Zend\Cache\Storage\ClearByPrefixInterface,
Zend\Cache\Storage\FlushableInterface,
Zend\Cache\Storage\IterableInterface,
Zend\Cache\Storage\TagableInterface,
Zend\Cache\Storage\TaggableInterface,
Zend\Cache\Storage\AvailableSpaceCapableInterface,
Zend\Cache\Storage\TotalSpaceCapableInterface,
Zend\Cache\Utils;
Expand All @@ -41,10 +41,14 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Memory
extends AbstractAdapter
implements ClearExpiredInterface, ClearByPrefixInterface, FlushableInterface, TagableInterface,
IterableInterface, AvailableSpaceCapableInterface, TotalSpaceCapableInterface
class Memory extends AbstractAdapter implements
AvailableSpaceCapableInterface,
ClearByPrefixInterface,
ClearExpiredInterface,
FlushableInterface,
IterableInterface,
TaggableInterface,
TotalSpaceCapableInterface
{
/**
* Data Array
Expand Down Expand Up @@ -211,7 +215,7 @@ public function clearByPrefix($prefix)
return true;
}

/* TagableInterface */
/* TaggableInterface */

/**
* Set tags to an item by given key.
Expand Down
59 changes: 0 additions & 59 deletions src/Storage/AdapterBroker.php

This file was deleted.

Loading

0 comments on commit 52cb4e6

Please sign in to comment.