public function import($scope)
 {
     if (!$this->className) {
         throw new WrongStateException("no class defined for PrimitiveEnumeration '{$this->name}'");
     }
     if (isset($scope[$this->name])) {
         $scopedValue = urldecode($scope[$this->name]);
         $anyId = ClassUtils::callStaticMethod($this->className . '::getAnyId');
         $object = new $this->className($anyId);
         $names = $object->getNameList();
         foreach ($names as $key => $value) {
             if ($value == $scopedValue) {
                 try {
                     $this->value = new $this->className($key);
                 } catch (MissingElementException $e) {
                     $this->value = null;
                     return false;
                 }
                 return true;
             }
         }
         return false;
     }
     return null;
 }
 public function testStaticMethodCalling()
 {
     $this->assertEquals(ClassUtils::callStaticMethod('Singleton::getInstance', 'UrlEncodeFilter'), Singleton::getInstance('UrlEncodeFilter'));
     $this->assertEquals(ClassUtils::callStaticMethod('ImaginaryDialect::me'), ImaginaryDialect::me());
     try {
         ClassUtils::callStaticMethod('InexistantClass::InSaNeMeThOd');
         $this->fail();
     } catch (ClassNotFoundException $e) {
         /* first pass */
     } catch (WrongArgumentException $e) {
         /* and all others */
     }
     try {
         ClassUtils::callStaticMethod('complete nonsense');
         $this->fail();
     } catch (WrongArgumentException $e) {
         /* pass */
     }
     try {
         ClassUtils::callStaticMethod('Identifier::comp::lete::non::sense');
         $this->fail();
     } catch (WrongArgumentException $e) {
         /* pass */
     }
 }
 protected function uncacheClassName($className, SegmentHandler $handler)
 {
     $handler->drop();
     $dao = ClassUtils::callStaticMethod($className . '::dao');
     /* @var $dao StorableDAO */
     return Cache::worker($dao)->uncacheByQuery($dao->makeSelectHead());
 }
 public function getList()
 {
     if ($this->value) {
         return ClassUtils::callStaticMethod(get_class($this->value) . '::getList');
     } elseif ($this->default) {
         return ClassUtils::callStaticMethod(get_class($this->default) . '::getList');
     } else {
         $object = new $this->className(ClassUtils::callStaticMethod($this->className . '::getAnyId'));
         return $object->getObjectList();
     }
     Assert::isUnreachable();
 }
 public function uncache()
 {
     foreach ($this->classNameMap as $className => $uncaches) {
         list($idKeys, $tags, $worker) = $uncaches;
         /* @var $worker TaggableDaoWorker */
         $worker->expireTags($tags);
         foreach ($idKeys as $key) {
             Cache::me()->mark($className)->delete($idKey);
         }
         ClassUtils::callStaticMethod("{$className}::dao")->uncacheLists();
     }
 }
 public function testAnyId()
 {
     foreach (get_declared_classes() as $className) {
         if (is_subclass_of($className, 'Enumeration')) {
             try {
                 $enum = new $className(call_user_func(array($className, 'getAnyId')));
                 /* pass */
             } catch (MissingElementException $e) {
                 $this->fail($className);
             }
         } elseif (is_subclass_of($className, 'Enum')) {
             try {
                 $enum = new $className(ClassUtils::callStaticMethod($className . '::getAnyId'));
                 /* pass */
             } catch (MissingElementException $e) {
                 $this->fail($className);
             }
         }
     }
 }
 protected function actualImportValue($value)
 {
     return strpos($this->methodName, '::') === false ? $this->dao()->{$this->methodName}($value) : ClassUtils::callStaticMethod($this->methodName, $value);
 }
 protected function actualImportValue($value)
 {
     if (is_callable($this->methodName)) {
         return call_user_func($this->methodName, $value);
     } elseif (strpos($this->methodName, '::') === false) {
         return $this->dao()->{$this->methodName}($value);
     } else {
         return ClassUtils::callStaticMethod($this->methodName, $value);
     }
 }
 private function checkEnumerationReferentialIntegrity($enumeration, $tableName)
 {
     Assert::isTrue($enumeration instanceof Enumeration || $enumeration instanceof Enum, 'argument enumeation must be instacne of Enumeration or Enum! gived, "' . gettype($enumeration) . '"');
     $updateQueries = null;
     $db = DBPool::me()->getLink();
     $class = get_class($enumeration);
     $ids = array();
     if ($enumeration instanceof Enumeration) {
         $list = $enumeration->getList();
     } elseif ($enumeration instanceof Enum) {
         $list = ClassUtils::callStaticMethod($class . '::getList');
     }
     foreach ($list as $enumerationObject) {
         $ids[$enumerationObject->getId()] = $enumerationObject->getName();
     }
     $rows = $db->querySet(OSQL::select()->from($tableName)->multiGet('id', 'name'));
     echo "\n";
     foreach ($rows as $row) {
         if (!isset($ids[$row['id']])) {
             echo "Class '{$class}', strange id: {$row['id']} found. \n";
         } else {
             if ($ids[$row['id']] != $row['name']) {
                 echo "Class '{$class}',id: {$row['id']} sync names. \n";
                 $updateQueries .= OSQL::update($tableName)->set('name', $ids[$row['id']])->where(Expression::eq('id', $row['id']))->toDialectString($db->getDialect()) . ";\n";
             }
             unset($ids[$row['id']]);
         }
     }
     foreach ($ids as $id => $name) {
         echo "Class '{$class}', id: {$id} not present in database. \n";
     }
     echo $updateQueries;
     return $this;
 }
 protected function actualExportValue($value)
 {
     if (!ClassUtils::isInstanceOf($value, $this->className)) {
         return null;
     }
     if (is_callable($this->extractMethod)) {
         return call_user_func($this->extractMethod, $value);
     } elseif (strpos($this->extractMethod, '::') === false) {
         return $value->{$this->extractMethod}($value);
     } else {
         ClassUtils::callStaticMethod($this->extractMethod, $value);
     }
 }