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

Commit

Permalink
Switch type hinting for plugin loaders
Browse files Browse the repository at this point in the history
- In most instances, switched from typehinting on PrefixPathMapper to use
  ShortNameLocater instead. For functionality depending on PrefixPathMapper
  definitions, added conditional logic.
- Re-fixed broken merge in Zend\Application\Resource\CacheManager tests and
  Zend\Cache\Cache front/backend loading
  • Loading branch information
weierophinney committed Jul 23, 2010
4 parents a950ec0 + b4276de + 8c41fda + 46a9a43 commit 2413f67
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
27 changes: 20 additions & 7 deletions src/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
namespace Zend\Paginator;

use Zend\Loader\PluginLoader,
Zend\Loader\PrefixPathMapper,
Zend\Loader\ShortNameLocater,
Zend\View,
Zend\Json;

Expand Down Expand Up @@ -57,7 +59,7 @@ class Paginator implements \Countable, \IteratorAggregate
/**
* Adapter plugin loader
*
* @var \Zend\Loader\PrefixPathMapper
* @var \Zend\Loader\ShortNameLocater
*/
protected static $_adapterLoader = null;

Expand Down Expand Up @@ -85,7 +87,7 @@ class Paginator implements \Countable, \IteratorAggregate
/**
* Scrolling style plugin loader
*
* @var \Zend\Loader\PrefixPathMapper
* @var \Zend\Loader\ShortNameLocater
*/
protected static $_scrollingStyleLoader = null;

Expand Down Expand Up @@ -287,7 +289,7 @@ public static function factory($data, $adapter = self::INTERNAL_ADAPTER,

$pluginLoader = self::getAdapterLoader();

if (null !== $prefixPaths) {
if (null !== $prefixPaths && $pluginLoader instanceof PrefixPathMapper) {
foreach ($prefixPaths as $prefix => $path) {
$pluginLoader->addPrefixPath($prefix, $path);
}
Expand All @@ -299,17 +301,28 @@ public static function factory($data, $adapter = self::INTERNAL_ADAPTER,
}
}

/**
* Set the adapter loader
*
* @param PluginLoader\ShortNameLocater $loader
* @return void
*/
public static function setAdapterLoader(ShortNameLocater $loader)
{
self::$_adapterLoader = $loader;
}

/**
* Returns the adapter loader. If it doesn't exist it's created.
*
* @return \Zend\Loader\PrefixPathMapper
* @return \Zend\Loader\ShortNameLocater
*/
public static function getAdapterLoader()
{
if (self::$_adapterLoader === null) {
self::$_adapterLoader = new PluginLoader(
self::setAdapterLoader(new PluginLoader(
array('Zend\Paginator\Adapter' => 'Zend/Paginator/Adapter')
);
));
}

return self::$_adapterLoader;
Expand Down Expand Up @@ -397,7 +410,7 @@ public static function setDefaultScrollingStyle($scrollingStyle = 'Sliding')
* Returns the scrolling style loader. If it doesn't exist it's
* created.
*
* @return \Zend\Loader\PrefixPathMapper
* @return \Zend\Loader\ShortNameLocater
*/
public static function getScrollingStyleLoader()
{
Expand Down
2 changes: 1 addition & 1 deletion src/SerializableLimitIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function offsetExists($offset)
$current = $this->current();
$this->seek($currentOffset);
return null !== $current;
} catch (OutOfBoundsException $e) {
} catch (\OutOfBoundsException $e) {
// reset position in case of exception is assigned null
$this->seek($currentOffset);
return false;
Expand Down
4 changes: 2 additions & 2 deletions test/PaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,8 @@ public function testInvalidDataInConstructor_ThrowsException()
*/
public function testArrayAccessInClassSerializableLimitIterator()
{
$iterator = new ArrayIterator(array('zf9396', 'foo', null));
$paginator = Zend_Paginator::factory($iterator);
$iterator = new \ArrayIterator(array('zf9396', 'foo', null));
$paginator = Paginator\Paginator::factory($iterator);

$this->assertEquals('zf9396', $paginator->getItem(1));

Expand Down
Binary file modified test/_files/test.sqlite
Binary file not shown.

0 comments on commit 2413f67

Please sign in to comment.