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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 11 changed files with 204 additions and 335 deletions.
14 changes: 0 additions & 14 deletions .travis/run-tests.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .travis/skipped-components

This file was deleted.

61 changes: 0 additions & 61 deletions .travis/tested-components

This file was deleted.

42 changes: 20 additions & 22 deletions src/Barcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

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

/**
Expand All @@ -50,45 +48,45 @@ class Barcode
protected static $staticFont = null;

/**
* The parser broker
* The parser plugin manager
*
* @var Broker
* @var ObjectPluginManager
*/
protected static $objectBroker;
protected static $objectPlugins;

/**
* The renderer broker
* The renderer plugin manager
*
* @var Broker
* @var RendererPluginManager
*/
protected static $rendererBroker;
protected static $rendererPlugins;

/**
* Get the parser broker
* Get the parser plugin manager
*
* @return Broker
* @return ObjectPluginManager
*/
public static function getObjectBroker()
public static function getObjectPluginManager()
{
if (!self::$objectBroker instanceof Broker) {
self::$objectBroker = new ObjectBroker();
if (!self::$objectPlugins instanceof ObjectPluginManager) {
self::$objectPlugins = new ObjectPluginManager();
}

return self::$objectBroker;
return self::$objectPlugins;
}

/**
* Get the renderer broker
* Get the renderer plugin manager
*
* @return Broker
* @return RendererPluginManager
*/
public static function getRendererBroker()
public static function getRendererPluginManager()
{
if (!self::$rendererBroker instanceof Broker) {
self::$rendererBroker = new RendererBroker();
if (!self::$rendererPlugins instanceof RendererPluginManager) {
self::$rendererPlugins = new RendererPluginManager();
}

return self::$rendererBroker;
return self::$rendererPlugins;
}

/**
Expand Down Expand Up @@ -210,7 +208,7 @@ public static function makeBarcode($barcode, $barcodeConfig = array())
);
}

return self::getObjectBroker()->load($barcode, $barcodeConfig);
return self::getObjectPluginManager()->get($barcode, $barcodeConfig);
}

/**
Expand Down Expand Up @@ -261,7 +259,7 @@ public static function makeRenderer($renderer = 'image', $rendererConfig = array
);
}

return self::getRendererBroker()->load($renderer, $rendererConfig);
return self::getRendererPluginManager()->get($renderer, $rendererConfig);
}

/**
Expand Down
54 changes: 0 additions & 54 deletions src/ObjectBroker.php

This file was deleted.

58 changes: 0 additions & 58 deletions src/ObjectLoader.php

This file was deleted.

88 changes: 88 additions & 0 deletions src/ObjectPluginManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Barcode;

use Zend\ServiceManager\AbstractPluginManager;

/**
* Plugin manager implementation for barcode parsers.
*
* Enforces that barcode parsers retrieved are instances of
* Object\AbstractObject. Additionally, it registers a number of default
* barcode parsers.
*
* @category Zend
* @package Zend_Barcode
* @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 ObjectPluginManager extends AbstractPluginManager
{
/**
* Default set of barcode parsers
*
* @var array
*/
protected $invokableClasses = array(
'codabar' => 'Zend\Barcode\Object\Codabar',
'code128' => 'Zend\Barcode\Object\Code128',
'code25' => 'Zend\Barcode\Object\Code25',
'code25interleaved' => 'Zend\Barcode\Object\Code25interleaved',
'code39' => 'Zend\Barcode\Object\Code39',
'ean13' => 'Zend\Barcode\Object\Ean13',
'ean2' => 'Zend\Barcode\Object\Ean2',
'ean5' => 'Zend\Barcode\Object\Ean5',
'ean8' => 'Zend\Barcode\Object\Ean8',
'error' => 'Zend\Barcode\Object\Error',
'identcode' => 'Zend\Barcode\Object\Identcode',
'itf14' => 'Zend\Barcode\Object\Itf14',
'leitcode' => 'Zend\Barcode\Object\Leitcode',
'planet' => 'Zend\Barcode\Object\Planet',
'postnet' => 'Zend\Barcode\Object\Postnet',
'royalmail' => 'Zend\Barcode\Object\Royalmail',
'upca' => 'Zend\Barcode\Object\Upca',
'upce' => 'Zend\Barcode\Object\Upce',
);

/**
* Validate the plugin
*
* Checks that the barcode parser loaded is an instance
* of Object\AbstractObject.
*
* @param mixed $plugin
* @return void
* @throws Exception\InvalidArgumentException if invalid
*/
public function validatePlugin($plugin)
{
if ($plugin instanceof Object\AbstractObject) {
// we're okay
return;
}

throw new Exception\InvalidArgumentException(sprintf(
'Plugin of type %s is invalid; must extend %s\Object\AbstractObject',
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
__NAMESPACE__
));
}
}
Loading

0 comments on commit c78a364

Please sign in to comment.