Просмотр исходного кода

[GENERIC] Zend_Barcode: add constructor hook to set default options for particular barcode object

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20042 44c647ce-9c0f-0410-b52a-842ac1e357ba
mikaelkael 16 лет назад
Родитель
Сommit
c7846b0b97

+ 6 - 3
library/Zend/Barcode/Object/Code25interleaved.php

@@ -43,10 +43,13 @@ class Zend_Barcode_Object_Code25interleaved extends Zend_Barcode_Object_Code25
     private $_withBearerBars = false;
 
     /**
-     * Number of characters in the barcode
-     * @var $_barcodeLength integer | string
+     * Default options for Code25interleaved barcode
+     * @return void
      */
-    protected $_barcodeLength = 'even';
+    protected function _getDefaultOptions()
+    {
+        $this->_barcodeLength = 'even';
+    }
 
     /**
      * Activate/deactivate drawing of bearer bars

+ 7 - 10
library/Zend/Barcode/Object/Identcode.php

@@ -42,17 +42,14 @@ class Zend_Barcode_Object_Identcode extends Zend_Barcode_Object_Code25interleave
 {
 
     /**
-     * Number of characters in the barcode
-     * @var $_barcodeLength integer | string
+     * Default options for Identcode barcode
+     * @return void
      */
-    protected $_barcodeLength = 12;
-
-    /**
-     * Activation of mandatory checksum
-     * to deactivate unauthorized modification
-     * @var $_mandatoryChecksum boolean
-     */
-    protected $_mandatoryChecksum = true;
+    protected function _getDefaultOptions()
+    {
+        $this->_barcodeLength = 12;
+        $this->_mandatoryChecksum = true;
+    }
 
     /**
      * Retrieve text to display

+ 7 - 10
library/Zend/Barcode/Object/Itf14.php

@@ -38,15 +38,12 @@ class Zend_Barcode_Object_Itf14 extends Zend_Barcode_Object_Code25interleaved
 {
 
     /**
-     * Number of characters in the barcode
-     * @var $_barcodeLength integer | string
+     * Default options for Identcode barcode
+     * @return void
      */
-    protected $_barcodeLength = 14;
-
-    /**
-     * Activation of mandatory checksum
-     * to deactivate unauthorized modification
-     * @var $_mandatoryChecksum boolean
-     */
-    protected $_mandatoryChecksum = true;
+    protected function _getDefaultOptions()
+    {
+        $this->_barcodeLength = 14;
+        $this->_mandatoryChecksum = true;
+    }
 }

+ 7 - 3
library/Zend/Barcode/Object/Leitcode.php

@@ -42,10 +42,14 @@ class Zend_Barcode_Object_Leitcode extends Zend_Barcode_Object_Identcode
 {
 
     /**
-     * Number of characters in the barcode
-     * @var $_barcodeLength integer | string
+     * Default options for Leitcode barcode
+     * @return void
      */
-    protected $_barcodeLength = 14;
+    protected function _getDefaultOptions()
+    {
+        $this->_barcodeLength = 14;
+        $this->_mandatoryChecksum = true;
+    }
 
     /**
      * Retrieve text to display

+ 9 - 0
library/Zend/Barcode/Object/ObjectAbstract.php

@@ -206,6 +206,7 @@ abstract class Zend_Barcode_Object_ObjectAbstract
      */
     public function __construct($options = null)
     {
+        $this->_getDefaultOptions();
         if (self::$_staticFont !== null) {
             $this->_font = self::$_staticFont;
         }
@@ -223,6 +224,14 @@ abstract class Zend_Barcode_Object_ObjectAbstract
     }
 
     /**
+     * Set default options for particular object
+     * @return void
+     */
+    protected function _getDefaultOptions()
+    {
+    }
+
+    /**
      * Set barcode state from options array
      * @param  array $options
      * @return Zend_Barcode_Object