예제 #1
0
 /**
  * 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));
 }