Issues

ZF-12294: Zend_Validate_Barcode custom adapter support

Issue Type: Bug Created: 2012-06-20T08:27:50.000+0000 Last Updated: 2012-07-11T11:07:47.000+0000 Status: Open Fix version(s): Reporter: Yaroslav Zenin (yaroslavzenin) Assignee: Mickael Perraud (mikaelkael) Tags: - Zend_Barcode

  • Zend_Validate

Related issues: Attachments:

Description

Zend_Validate_Barcode should support custom adapters which should be possible to set ins constructor. Adapter instance of class should be supported and classes which are not located in Zend/Validate/Barcode/ directory

quick fix for that:

<pre class="highlight">
### Eclipse Workspace Patch 1.0
Index: library/Zend/Validate/Barcode.php
===================================================================
--- library/Zend/Validate/Barcode.php   (revision 20552)
+++ library/Zend/Validate/Barcode.php   (working copy)
@@ -131,17 +131,22 @@
      */
     public function setAdapter($adapter, $options = null)
     {
-        $adapter = ucfirst(strtolower($adapter));
-        require_once 'Zend/Loader.php';
-        if (Zend_Loader::isReadable('Zend/Validate/Barcode/' . $adapter. '.php')) {
-            $adapter = 'Zend_Validate_Barcode_' . $adapter;
-        }
+        if (is_object($adapter)) {
+            $this->_adapter = $adapter;
+        } else {
+            $adapter = ucfirst(strtolower($adapter));
+            require_once 'Zend/Loader.php';
+            if (Zend_Loader::isReadable('Zend/Validate/Barcode/' . $adapter. '.php')) {
+                $adapter = 'Zend_Validate_Barcode_' . $adapter;
+            }
 
-        if (!class_exists($adapter)) {
-            Zend_Loader::loadClass($adapter);
+            if (!class_exists($adapter)) {
+                Zend_Loader::loadClass($adapter);
+            }
+
+            $this->_adapter = new $adapter($options);
         }
 
-        $this->_adapter = new $adapter($options);
         if (!$this->_adapter instanceof Zend_Validate_Barcode_AdapterInterface) {
             require_once 'Zend/Validate/Exception.php';
             throw new Zend_Validate_Exception(

Comments

Posted by Yaroslav Zenin (yaroslavzenin) on 2012-07-11T09:23:20.000+0000

Я напевне в цьому житті чогось не розумію :( От невже так складно добавити цей патч в репозітарій. Таке враження що всім пофиг :(

Posted by Frank Brückner (frosch) on 2012-07-11T11:07:47.000+0000

Hi Yaroslav, before we can add the patch you must fill out and send the CLA to Zend. Then add a patch file with unit tests (!) to this issue.

Thanks.

PS: Please write in english! ;)

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts