Issues

ZF-12294: Zend_Validate_Barcode custom adapter support

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:


### 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

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

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! ;)