当前位置: 首页>>代码示例>>PHP>>正文


PHP ORMException::findByRequiresParameter方法代码示例

本文整理汇总了PHP中Doctrine\ORM\ORMException::findByRequiresParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP ORMException::findByRequiresParameter方法的具体用法?PHP ORMException::findByRequiresParameter怎么用?PHP ORMException::findByRequiresParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\ORMException的用法示例。


在下文中一共展示了ORMException::findByRequiresParameter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __call

 /**
  * Adds support for magic finders.
  *
  * @return array|object The found entity/entities.
  * @throws BadMethodCallException  If the method called is an invalid find* method
  *                                 or no find* method at all and therefore an invalid
  *                                 method call.
  */
 public function __call($method, $arguments)
 {
     switch (true) {
         case 0 === strpos($method, 'findBy'):
             $by = substr($method, 6);
             $method = 'findBy';
             break;
         case 0 === strpos($method, 'findOneBy'):
             $by = substr($method, 9);
             $method = 'findOneBy';
             break;
         default:
             throw new \BadMethodCallException("Undefined method '{$method}'. The method name must start with " . "either findBy or findOneBy!");
     }
     if (empty($arguments)) {
         throw ORMException::findByRequiresParameter($method . $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
         }
     }
     throw ORMException::invalidFindByCall($this->_entityName, $fieldName, $method . $by);
 }
开发者ID:paulodacosta,项目名称:LearnFlash,代码行数:42,代码来源:EntityRepository.php

示例2: __call

 /**
  * Adds support for magic finders.
  *
  * @return array|object The found entity/entities.
  * @throws BadMethodCallException  If the method called is an invalid find* method
  *                                 or no find* method at all and therefore an invalid
  *                                 method call.
  */
 public function __call($method, $arguments)
 {
     if (substr($method, 0, 6) == 'findBy') {
         $by = substr($method, 6, strlen($method));
         $method = 'findBy';
     } else {
         if (substr($method, 0, 9) == 'findOneBy') {
             $by = substr($method, 9, strlen($method));
             $method = 'findOneBy';
         } else {
             throw new \BadMethodCallException("Undefined method '{$method}'. The method name must start with " . "either findBy or findOneBy!");
         }
     }
     if (!isset($arguments[0])) {
         // we dont even want to allow null at this point, because we cannot (yet) transform it into IS NULL.
         throw ORMException::findByRequiresParameter($method . $by);
     }
     $fieldName = lcfirst(\Doctrine\Common\Util\Inflector::classify($by));
     if ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName)) {
         return $this->{$method}(array($fieldName => $arguments[0]));
     } else {
         throw ORMException::invalidFindByCall($this->_entityName, $fieldName, $method . $by);
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:32,代码来源:EntityRepository.php

示例3: resolveMagicCall

 /**
  * Resolves a magic method call to the proper existent method at `EntityRepository`.
  *
  * @param string $method    The method to call
  * @param string $by        The property name used as condition
  * @param array  $arguments The arguments to pass at method call
  *
  * @throws ORMException If the method called is invalid or the requested field/association does not exist
  *
  * @return mixed
  */
 private function resolveMagicCall($method, $by, array $arguments)
 {
     if (!$arguments) {
         throw ORMException::findByRequiresParameter($method . $by);
     }
     $fieldName = lcfirst(Inflector::classify($by));
     if (!($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName))) {
         throw ORMException::invalidMagicCall($this->_entityName, $fieldName, $method . $by);
     }
     return $this->{$method}([$fieldName => $arguments[0]], ...array_slice($arguments, 1));
 }
开发者ID:AdactiveSAS,项目名称:doctrine2,代码行数:22,代码来源:EntityRepository.php


注:本文中的Doctrine\ORM\ORMException::findByRequiresParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。