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 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 uncache() { foreach ($this->classNameMap as $className => $tags) { $dao = ClassUtils::callStaticMethod("{$className}::dao"); /* @var $dao StorableDAO */ $worker = Cache::worker($dao); Assert::isInstance($worker, TaggableDaoWorker::class); $worker->expireTags($tags); } }
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(); } }
public function uncache() { foreach ($this->classNameMap as $className => $uncaches) { list($idKeys, $tags) = $uncaches; $dao = ClassUtils::callStaticMethod("{$className}::dao"); /* @var $dao StorableDAO */ $worker = Cache::worker($dao); Assert::isInstance($worker, TaggableDaoWorker::class); $worker->expireTags($tags); foreach ($idKeys as $key) { Cache::me()->mark($className)->delete($key); } $dao->uncacheLists(); } }
protected function getPropertiesByClassName($className) { $proto = ClassUtils::callStaticMethod($className . '::proto'); return $proto->getPropertyList(); }
private function checkEnumerationReferentialIntegrity($enumeration, $tableName) { Assert::isTrue($enumeration instanceof Enumeration || $enumeration instanceof Enum || $enumeration instanceof Registry, 'argument enumeation must be instacne of Enumeration or Enum! gived, "' . gettype($enumeration) . '"'); $updateQueries = null; $db = DBPool::me()->getLink(); $class = get_class($enumeration); $ids = []; if ($enumeration instanceof Enumeration) { $list = $enumeration->getList(); } elseif ($enumeration instanceof Enum) { $list = ClassUtils::callStaticMethod($class . '::getList'); } elseif ($enumeration instanceof Registry) { $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 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); } }
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); } }