Public Member Functions | |
getAllowedChars () | |
getNextId () |
Properties:
Definition at line 37 of file Alphanum.php.
getAllowedChars | ( | ) |
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 }