當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ORMException::invalidFindByCall方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\ORMException::invalidFindByCall方法的典型用法代碼示例。如果您正苦於以下問題:PHP ORMException::invalidFindByCall方法的具體用法?PHP ORMException::invalidFindByCall怎麽用?PHP ORMException::invalidFindByCall使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\ORMException的用法示例。


在下文中一共展示了ORMException::invalidFindByCall方法的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: __call

 /**
  * For consistency, allow standard calls, but fail for everything
  *
  * @param $method
  * @param $arguments
  *
  * @throws ORMException
  */
 public function __call($method, $arguments)
 {
     throw ORMException::invalidFindByCall($this->getClassName(), '*', $method);
 }
開發者ID:illuminate3,項目名稱:laravel-doctrine-tenancy,代碼行數:12,代碼來源:TenantAwareRepository.php


注:本文中的Doctrine\ORM\ORMException::invalidFindByCall方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。