本文整理汇总了PHP中Assert::classExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::classExists方法的具体用法?PHP Assert::classExists怎么用?PHP Assert::classExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert
的用法示例。
在下文中一共展示了Assert::classExists方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: of
/**
* @throws WrongArgumentException
* @return PrimitiveForm
*
* @deprecated You should use ofProto() instead
**/
public function of($className)
{
Assert::classExists($className);
$protoClass = EntityProto::PROTO_CLASS_PREFIX . $className;
Assert::classExists($protoClass);
return $this->ofProto(Singleton::getInstance($protoClass));
}
示例2: __construct
public function __construct($root, $path)
{
Assert::isString($path, 'non-string path given');
if (is_object($root)) {
$className = get_class($root);
} else {
Assert::classExists($root);
$className = $root;
}
$this->root = $className;
$this->path = $path;
$this->fetchHelpers($className);
$proto = self::$protos[$className];
$path = explode('.', $path);
for ($i = 0, $size = count($path); $i < $size; ++$i) {
$this->properties[$i] = $property = $proto->getPropertyByName($path[$i]);
if ($className = $property->getClassName()) {
$this->fetchHelpers($className);
$proto = self::$protos[$className];
} elseif ($i < $size) {
continue;
} else {
throw new WrongArgumentException('corrupted path');
}
}
}
示例3: ofBase
/**
* @throws WrongArgumentException
* @return PrimitivePolymorphicIdentifier
**/
public function ofBase($className)
{
Assert::classExists($className);
Assert::isInstance($className, 'DAOConnected', "class '{$className}' must implement DAOConnected interface");
$this->baseClassName = $className;
return $this;
}
示例4: of
/**
* @throws WrongArgumentException
* @return PrimitiveEnum
**/
public function of($class)
{
$className = $this->guessClassName($class);
Assert::classExists($className);
Assert::isInstance($className, 'Enum');
$this->className = $className;
return $this;
}
示例5: dropWith
public function dropWith($worker)
{
Assert::classExists($worker);
if ($this->modifiedIds) {
$workerObject = new $worker($this->dao);
$workerObject->uncacheByIds($this->modifiedIds);
$this->modifiedIds = array();
}
return $this;
}
示例6: setDefaultLocker
public static function setDefaultLocker($name)
{
Assert::classExists($name);
self::$lockerName = $name;
self::$locker = Singleton::getInstance($name);
}
示例7: spawn
/**
* @return BasePrimitive
**/
public static function spawn($primitive, $name)
{
Assert::classExists($primitive);
return new $primitive($name);
}
示例8: setDefaultHandler
public static function setDefaultHandler($handler)
{
Assert::classExists($handler);
self::$defaultHandler = $handler;
}
示例9: __construct
public function __construct($controllerName)
{
Assert::classExists($controllerName);
$this->url = $controllerName;
}
示例10: toValue
public function toValue(ProtoDAO $dao = null, $array, $prefix = null)
{
$raw = $array[$prefix . $this->columnName];
if ($this->type == 'binary') {
return DBPool::getByDao($dao)->getDialect()->unquoteBinary($raw);
}
if ($this->className == 'HttpUrl') {
return HttpUrl::create()->parse($raw);
}
if (!$this->identifier && $this->generic && $this->className) {
return call_user_func(array($this->className, 'create'), $raw);
} elseif (!$this->identifier && $this->className) {
// BOVM: prevents segfault on >=php-5.2.5
Assert::classExists($this->className);
if (!is_subclass_of($this->className, 'Enumeration')) {
$remoteDao = call_user_func(array($this->className, 'dao'));
$joinPrefix = $remoteDao->getJoinPrefix($this->columnName, $prefix);
$joined = $this->strategyId == FetchStrategy::JOIN || isset($array[$joinPrefix . $remoteDao->getIdName()]);
if ($joined) {
return $remoteDao->makeObject($array, $joinPrefix);
} else {
// will be fetched later
// by AbstractProtoClass::fetchEncapsulants
$object = new $this->className();
$object->setId($raw);
return $object;
}
} else {
return new $this->className($raw);
}
}
// veeeeery "special" handling, by tradition.
// MySQL returns 0/1, others - t/f
if ($this->type == 'boolean') {
return (bool) strtr($raw, array('f' => null));
}
return $raw;
}
示例11: setDefaultWorker
public static function setDefaultWorker($worker)
{
Assert::classExists($worker);
self::$worker = $worker;
}
示例12: processPath
private function processPath(AbstractProtoClass $proto, $probablyPath, JoinCapableQuery $query, $table, $parentRequired = true, $prefix = null)
{
$path = explode('.', $probablyPath);
try {
$property = $proto->getPropertyByName($path[0]);
} catch (MissingElementException $e) {
// oh, it's a value, not a property
return new DBValue($probablyPath);
}
unset($path[0]);
Assert::isTrue($property->getRelationId() != null && !$property->isGenericType());
Assert::classExists($property->getClassName());
// checking whether we're playing with value object
if (!method_exists($property->getClassName(), 'dao')) {
if (method_exists($property->getClassName(), 'proto') && count($path) > 1) {
return $this->processPath($property->getProto(), implode('.', $path), $query, $table);
} else {
return $this->guessAtom(implode('.', $path), $query, $table, $prefix);
}
} else {
$propertyDao = call_user_func(array($property->getClassName(), 'dao'));
Assert::isNotNull($propertyDao, 'can not find target dao for "' . $property->getName() . '" property at "' . get_class($proto) . '"');
}
$alias = $propertyDao->getJoinName($property->getColumnName(), $prefix);
if ($property->getRelationId() == MetaRelation::ONE_TO_MANY || $property->getRelationId() == MetaRelation::MANY_TO_MANY) {
$remoteName = $property->getClassName();
$selfName = $this->getObjectName();
$self = new $selfName();
$getter = $property->getGetter();
$dao = call_user_func(array($remoteName, 'dao'));
if ($property->getRelationId() == MetaRelation::MANY_TO_MANY) {
$helperTable = $self->{$getter}()->getHelperTable();
$helperAlias = $helperTable;
if (!$query->hasJoinedTable($helperAlias)) {
$logic = Expression::eq(DBField::create($this->getIdName(), $table), DBField::create($self->{$getter}()->getParentIdField(), $helperAlias));
if ($property->isRequired()) {
$query->join($helperTable, $logic, $helperAlias);
} else {
$query->leftJoin($helperTable, $logic, $helperAlias);
}
}
$logic = Expression::eq(DBField::create($propertyDao->getIdName(), $alias), DBField::create($self->{$getter}()->getChildIdField(), $helperAlias));
} else {
$logic = Expression::eq(DBField::create($self->{$getter}()->getParentIdField(), $alias), DBField::create($this->getIdName(), $table));
}
if (!$query->hasJoinedTable($alias)) {
if ($property->isRequired() && $parentRequired) {
$query->join($dao->getTable(), $logic, $alias);
} else {
$query->leftJoin($dao->getTable(), $logic, $alias);
}
}
} else {
// OneToOne, lazy OneToOne
// prevents useless joins
if (isset($path[1]) && count($path) == 1 && $path[1] == $propertyDao->getIdName()) {
return new DBField($property->getColumnName(), $table);
}
if (!$query->hasJoinedTable($alias)) {
$logic = Expression::eq(DBField::create($property->getColumnName(), $table), DBField::create($propertyDao->getIdName(), $alias));
if ($property->isRequired() && $parentRequired) {
$query->join($propertyDao->getTable(), $logic, $alias);
} else {
$query->leftJoin($propertyDao->getTable(), $logic, $alias);
}
}
}
if ($path) {
return $propertyDao->guessAtom(implode('.', $path), $query, $alias, $property->isRequired() && $parentRequired, $propertyDao->getJoinPrefix($property->getColumnName(), $prefix));
}
// ok, we're done
}