本文整理匯總了PHP中Doctrine\ORM\EntityRepository::__call方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityRepository::__call方法的具體用法?PHP EntityRepository::__call怎麽用?PHP EntityRepository::__call使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ORM\EntityRepository
的用法示例。
在下文中一共展示了EntityRepository::__call方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __call
/**
* Doctrine\ORM\EntityRepository.__call()と同じ動きで自前のfindBy関數を動かす
*
* @see Doctrine\ORM\EntityRepository::__call()
*/
public function __call($method, $arguments)
{
$by = null;
switch (true) {
case 0 === strpos($method, 'findCountBy'):
$by = substr($method, 11);
$method = 'findCountBy';
break;
}
// $by があれば、上記に定義した獨自関數だったとする
if (!is_null($by)) {
$fieldName = lcfirst(\Doctrine\Common\Util\Inflector::classify($by));
if ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName)) {
switch (count($arguments)) {
case 1:
return $this->{$method}(array($fieldName => $arguments[0]));
case 2:
return $this->{$method}(array($fieldName => $arguments[0]), $arguments[1]);
case 3:
return $this->{$method}(array($fieldName => $arguments[0]), $arguments[1], $arguments[2]);
case 4:
return $this->{$method}(array($fieldName => $arguments[0]), $arguments[1], $arguments[2], $arguments[3]);
default:
// Do nothing
}
}
}
return parent::__call($method, $arguments);
}
示例2: __call
public function __call($method, $args)
{
$result = $this->callTreeUtilMethods($method, $args);
if (null !== $result) {
return $result;
}
return parent::__call($method, $args);
}
示例3: __call
/**
* {@inheritdoc}
*/
public function __call($method, $arguments)
{
if (0 === strpos($method, 'find')) {
if (method_exists($this, $builder = 'build' . substr($method, 4))) {
$qb = call_user_func_array(array($this, $builder), $arguments);
if (0 === strpos(substr($method, 4), 'One')) {
return $qb->getQuery()->getOneOrNullResult();
}
return $qb->getQuery()->getResult();
}
}
return parent::__call($method, $arguments);
}
示例4: __call
/**
* Call to undefined method
*
* @param string method name
* @param array arguments
* @return mixed
* @throws \Nette\MemberAccessException
*/
public function __call($name, $args)
{
try {
return parent::__call($name, $args);
} catch (\BadMethodCallException $e) {
return ObjectMixin::call($this, $name, $args);
}
}
示例5: __call
/**
* Call to undefined method.
*
* @param string $name
* @param array $args
*
* @throws \Nette\MemberAccessException
* @return mixed
*/
public function __call($name, $args)
{
if (strpos($name, 'findBy') === 0 || strpos($name, 'findOneBy') === 0) {
return parent::__call($name, $args);
}
return ObjectMixin::call($this, $name, $args);
}