Mage_Eav_Model_Entity_Increment_Alphanum Class Reference

Inheritance diagram for Mage_Eav_Model_Entity_Increment_Alphanum:

Mage_Eav_Model_Entity_Increment_Abstract Varien_Object Mage_Eav_Model_Entity_Increment_Interface

List of all members.

Public Member Functions

 getAllowedChars ()
 getNextId ()


Detailed Description

Enter description here...

Properties:

Definition at line 37 of file Alphanum.php.


Member Function Documentation

getAllowedChars (  ) 

Definition at line 40 of file Alphanum.php.

00041     {
00042         return '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
00043     }

getNextId (  ) 

Implements Mage_Eav_Model_Entity_Increment_Interface.

Definition at line 45 of file Alphanum.php.

00046     {
00047         $lastId = $this->getLastId();
00048         
00049         if (strpos($lastId, $this->getPrefix())===0) {
00050             $lastId = substr($lastId, strlen($this->getPrefix()));
00051         }
00052         
00053         $lastId = str_pad((string)$lastId, $this->getPadLength(), $this->getPadChar(), STR_PAD_LEFT);
00054         
00055         $nextId = '';
00056         $bumpNextChar = true;
00057         $chars = $this->getAllowedChars();
00058         $lchars = strlen($chars);
00059         $lid = strlen($lastId)-1;
00060         
00061         for ($i = $lid; $i >= 0; $i--) {
00062             $p = strpos($chars, $lastId{$i});
00063             if (false===$p) {
00064                 throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid character encountered in increment ID: %s', $lastId));
00065             }
00066             if ($bumpNextChar) {
00067                 $p++;
00068                 $bumpNextChar = false;
00069             }
00070             if ($p===$lchars) {
00071                 $p = 0;
00072                 $bumpNextChar = true;
00073             }
00074             $nextId = $chars{$p}.$nextId;
00075         }
00076         
00077         return $this->format($nextId);
00078     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:11 2009 for Magento by  doxygen 1.5.8