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' into markup
Browse files Browse the repository at this point in the history
Conflicts:
	library/Zend/Markup/Parser/Textile.php
	library/Zend/Markup/Renderer/AbstractRenderer.php
	library/Zend/Markup/Renderer/Html.php
  • Loading branch information
kokx committed Oct 30, 2010
2 parents 1863312 + 9fceeb6 commit d95685a
Show file tree
Hide file tree
Showing 60 changed files with 552 additions and 176 deletions.
39 changes: 16 additions & 23 deletions src/Barcode.php
Expand Up @@ -16,18 +16,18 @@
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\Barcode;
use Zend\Barcode\Renderer,
Zend\Loader\PluginLoader,
use Zend\Loader\PluginLoader,
Zend\Loader\ShortNameLocater,
Zend\Config\Config,
Zend;
Zend,
Zend\Barcode\Exception\RendererCreationException,
Zend\Barcode\Exception\InvalidArgumentException;

/**
* Class for generate Barcode
Expand Down Expand Up @@ -78,7 +78,7 @@ public static function setPluginLoader(ShortNameLocater $loader, $type)
self::$_loaders[$type] = $loader;
return;
default:
throw new Exception(sprintf('Invalid type "%s" provided to setPluginLoader()', $type));
throw new InvalidArgumentException(sprintf('Invalid type "%s" provided to setPluginLoader()', $type));
}
}

Expand Down Expand Up @@ -107,7 +107,7 @@ public static function getPluginLoader($type)
}
return self::$_loaders[$type];
default:
throw new Exception(sprintf('Invalid type "%s" provided to getPluginLoader()', $type));
throw new InvalidArgumentException(sprintf('Invalid type "%s" provided to getPluginLoader()', $type));
}
}

Expand Down Expand Up @@ -166,9 +166,8 @@ public static function factory($barcode,
try {
$barcode = self::makeBarcode($barcode, $barcodeConfig);
$renderer = self::makeRenderer($renderer, $rendererConfig);
} catch (Zend\Exception $e) {
$renderable = ($e instanceof Exception) ? $e->isRenderable() : false;
if ($automaticRenderError && $renderable) {
} catch (Exception $e) {
if ($automaticRenderError && !($e instanceof RendererCreationException)) {
$barcode = self::makeBarcode('error', array( 'text' => $e->getMessage() ));
$renderer = self::makeRenderer($renderer, array());
} else {
Expand Down Expand Up @@ -215,7 +214,7 @@ public static function makeBarcode($barcode, $barcodeConfig = array())
* Verify that barcode parameters are in an array.
*/
if (!is_array($barcodeConfig)) {
throw new Exception(
throw new InvalidArgumentException(
'Barcode parameters must be in an array or a \Zend\Config\Config object'
);
}
Expand All @@ -224,7 +223,7 @@ public static function makeBarcode($barcode, $barcodeConfig = array())
* Verify that an barcode name has been specified.
*/
if (!is_string($barcode) || empty($barcode)) {
throw new Exception(
throw new InvalidArgumentException(
'Barcode name must be specified in a string'
);
}
Expand All @@ -241,7 +240,7 @@ public static function makeBarcode($barcode, $barcodeConfig = array())
* Verify that the object created is a descendent of the abstract barcode type.
*/
if (!$bcAdapter instanceof BarcodeObject) {
throw new Exception(
throw new InvalidArgumentException(
"Barcode class '$barcodeName' does not implement \Zend\Barcode\BarcodeObject"
);
}
Expand All @@ -257,7 +256,7 @@ public static function makeBarcode($barcode, $barcodeConfig = array())
*/
public static function makeRenderer($renderer = 'image', $rendererConfig = array())
{
if ($renderer instanceof Renderer) {
if ($renderer instanceof BarcodeRenderer) {
return $renderer;
}

Expand All @@ -281,22 +280,18 @@ public static function makeRenderer($renderer = 'image', $rendererConfig = array
* Verify that barcode parameters are in an array.
*/
if (!is_array($rendererConfig)) {
$e = new Exception(
throw new RendererCreationException(
'Barcode parameters must be in an array or a \Zend\Config\Config object'
);
$e->setIsRenderable(false);
throw $e;
}

/*
* Verify that an barcode name has been specified.
*/
if (!is_string($renderer) || empty($renderer)) {
$e = new Exception(
throw new RendererCreationException(
'Renderer name must be specified in a string'
);
$e->setIsRenderable(false);
throw $e;
}

$rendererName = self::getPluginLoader(self::RENDERER)->load($renderer);
Expand All @@ -310,12 +305,10 @@ public static function makeRenderer($renderer = 'image', $rendererConfig = array
/*
* Verify that the object created is a descendent of the abstract barcode type.
*/
if (!$rdrAdapter instanceof Renderer) {
$e = new Exception(
if (!$rdrAdapter instanceof BarcodeRenderer) {
throw new RendererCreationException(
"Renderer class '$rendererName' does not implements \Zend\Barcode\Renderer"
);
$e->setIsRenderable(false);
throw $e;
}
return $rdrAdapter;
}
Expand Down
1 change: 0 additions & 1 deletion src/BarcodeObject.php
Expand Up @@ -17,7 +17,6 @@
* @subpackage Object
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Renderer.php → src/BarcodeRenderer.php
Expand Up @@ -17,7 +17,6 @@
* @subpackage Renderer
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
Expand All @@ -35,7 +34,7 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Renderer
interface BarcodeRenderer
{
/**
* Constructor
Expand Down
35 changes: 3 additions & 32 deletions src/Exception.php
Expand Up @@ -16,51 +16,22 @@
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
* @namespace
*/
namespace Zend\Barcode;
use Zend;

/**
* Zend_Barcode_Exception
* Exception for Zend_Barcode component.
*
* @uses \Zend\Exception
* @uses Zend\Exception
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Exception extends Zend\Exception
interface Exception
{
/**
* Is this exception renderable?
* @var bool
*/
protected $_isRenderable = true;

/**
* Set renderable flag
*
* @param bool $flag
* @return \Zend\Barcode\Exception
*/
public function setIsRenderable($flag)
{
$this->_isRenderable = (bool) $flag;
return $this;
}

/**
* Retrieve renderable flag
*
* @return bool
*/
public function isRenderable()
{
return $this->_isRenderable;
}
}
41 changes: 41 additions & 0 deletions src/Exception/InvalidArgumentException.php
@@ -0,0 +1,41 @@
<?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 license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id$
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Barcode\Exception;
use Zend\Barcode\Exception;

/**
* Exception for Zend_Barcode component.
*
* @uses Zend\Exception
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class InvalidArgumentException
extends \InvalidArgumentException
implements Exception
{
}
41 changes: 41 additions & 0 deletions src/Exception/RendererCreationException.php
@@ -0,0 +1,41 @@
<?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 license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @version $Id$
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Barcode\Exception;
use Zend\Barcode\Exception;

/**
* Exception for Zend_Barcode component.
*
* @uses Zend\Exception
* @category Zend
* @package Zend_Barcode
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class RendererCreationException
extends \InvalidArgumentException
implements Exception
{
}

0 comments on commit d95685a

Please sign in to comment.