/**
  * Create a new instance.
  *
  * @param string      $model
  * @param string|null $message
  *
  * @return void
  */
 public function __construct($model, $message = null)
 {
     if (!$message) {
         $message = "No class was defined for the model of type: '{$model}'.";
     }
     parent::__construct($model, $message);
 }
Beispiel #2
0
 /**
  * Constructs a new exception for the specified model
  *
  * @param  string     $alias   The alias to use when looking for error messages
  * @param  Validation $object  The Validation object of the model
  * @param  string     $message The error message
  * @param  array      $values  The array of values for the error message
  * @param  integer    $code    The error code for the exception
  * @param Exception   $previous
  */
 public function __construct($alias, Validation $object, $message = 'Failed to validate array', array $values = null, $code = 0, Exception $previous = null)
 {
     $this->_alias = $alias;
     $this->_objects['_object'] = $object;
     $this->_objects['_hasMany'] = false;
     parent::__construct($message, $values, $code, $previous);
 }
 /**
  * Create a new delete failed exception instance.
  *
  * @param string      $class   The model class name.
  * @param string|null $message The exception message.
  *
  * @return void
  */
 public function __construct($class, $message = null)
 {
     if (!$message) {
         $message = "We could not delete the model: '{$class}'.";
     }
     parent::__construct($class, $message);
 }
 /**
  * Create a new instance.
  *
  * @param string      $model
  * @param string|null $message
  *
  * @return void
  */
 public function __construct($model, $message = null)
 {
     if (!$message) {
         $message = "No factory definition(s) were defined for the model of type: '{$model}'.";
     }
     parent::__construct($model, $message);
 }
 /**
  * Create a new instance.
  *
  * @param string      $model
  * @param string|null $message
  *
  * @return void
  */
 public function __construct($model, $message = null)
 {
     if (!$message) {
         $message = "We could not delete the model of type: '{$model}'.";
     }
     parent::__construct($model, $message);
 }
 /**
  * Create a new model not found exception instance.
  *
  * @param string      $class   The model class name.
  * @param string|null $message The exception message.
  *
  * @return void
  */
 public function __construct($class, $message = null)
 {
     if (!$message) {
         $message = "The model class '{$class}' is undefined.";
     }
     parent::__construct($class, $message);
 }
 /**
  * Create a new instance.
  *
  * @param string      $model
  * @param string      $method
  * @param string|null $message
  *
  * @return void
  */
 public function __construct($model, $method, $message = null)
 {
     $this->method = $method;
     if (!$message) {
         $message = "The static method '{$method}' was not found on the model of type: '{$model}'.";
     }
     parent::__construct($model, $message);
 }
 /**
  * Output the ModelValidationException as a string.
  *
  * @return string A formatted string representation of the exception.
  */
 public function __toString()
 {
     $output = [parent::__toString()];
     foreach ($this->validationMessages as $field => $errors) {
         foreach ($errors as $error) {
             $output[] .= "[{$field}#{$error['code']}] {$error['message']}";
         }
     }
     return implode("\n", $output);
 }
 /**
  * Create a new instance.
  *
  * @param string      $model
  * @param string|null $errors
  * @param string|null $message
  *
  * @return void
  */
 public function __construct($model, $errors = null, $message = null)
 {
     $this->errors = $errors;
     if (!$message) {
         if ($errors) {
             $message = "{$errors} We could not save the model of type: '{$model}'.";
         } else {
             $message = "We could not save the model of type: '{$model}'.";
         }
     }
     parent::__construct($model, $message);
 }
 /**
  * Create a new save failed exception instance.
  *
  * @param string      $class   The model class name.
  * @param string|null $errors  The validation errors.
  * @param string|null $message The exception message.
  *
  * @return void
  */
 public function __construct($class, $errors = null, $message = null)
 {
     $errors = $this->formatErrors($errors);
     $this->validationErrors = $errors;
     if (!$message) {
         if ($errors) {
             $message = "{$errors} We could not save the model: '{$class}'.";
         } else {
             $message = "We could not save the model: '{$class}'.";
         }
     }
     parent::__construct($class, $message);
 }
 public function __construct($model)
 {
     parent::__construct(sprintf("You tried to access %s's primary key, but it " . "has no discernible primary key. Either ensure you've " . "declared a 'Primary' attribute or set the 'pk' on the " . "model's metadata to return your primary attribute.", $model));
 }
 public function __construct($message, $itemId = null)
 {
     parent::__construct($message);
     $this->itemId = $itemId;
 }
 public function __construct($model, $attr)
 {
     parent::__construct(sprintf("You tried to access an attribute named '%s' on the '%s' " . "model, but it doesn't exist. Are you sure you've declared it?", $attr, $model));
 }
Beispiel #14
0
 /**
  * Sets a has-one relationship.
  *
  * @param   string      $key    The relationship key (field) name.
  * @param   Model|null  $model  The model to relate.
  * @return  self
  */
 protected function setHasOne($key, Model $model = null)
 {
     if (true === $this->isInverse($key)) {
         throw ModelException::cannotModifyInverse($this, $key);
     }
     if (null !== $model) {
         $this->validateRelSet($key, $model->getType());
     }
     $this->touch();
     $this->hasOneRelationships->set($key, $model);
     $this->doDirtyCheck();
     return $this;
 }
 /**
  * Create a new method not found exception instance.
  *
  * @param string $class   The model class name.
  * @param string $method  The method name.
  * @param string $message The exception message.
  *
  * @return void
  */
 public function __construct($class, $method, $message)
 {
     $this->methodName = $method;
     parent::__construct($class, $message);
 }
 public function __construct($model, $attr, $type)
 {
     parent::__construct(sprintf("The type you declared for '%s:%s' is invalid. You specified " . "'%s', but it was unusable. You can either pass a valid " . "string or a valid callback that returns an instance of " . "'Mismatch\\Model\\Attr\\AttrInterface'.", $model, $attr, $type));
 }
 public function __construct($model)
 {
     parent::__construct(sprintf("You must set an 'attrs' key on '%s' model's metadata before " . "accessing attributes. This may be as simple as adding a " . "'use Mismatch\\Model' or ensuring that you have used it " . "before another trait that requires the 'attrs' key.", $model));
 }
 /**
  * @param Blog       $blog
  * @param int        $code
  * @param \Exception $previous
  */
 public function __construct(Blog $blog, $code = 0, \Exception $previous = null)
 {
     parent::__construct(sprintf('Blog "%s" cannot change its author.', $blog), $code, $previous);
 }
Beispiel #19
0
 /**
  * Sets the exception message to show the undefined property's name.
  *
  * @param str $class_name name of the model that is read only
  * @param str $method_name name of method which attempted to modify the model
  * @return void
  */
 public function __construct($class_name, $method_name)
 {
     $this->message = "{$class_name}::{$method_name}() cannot be invoked because this model is set to read only";
     parent::__construct();
 }
Beispiel #20
0
 /**
  * @param string     $string
  * @param int        $limit
  * @param int        $code
  * @param \Exception $previous
  */
 public function __construct($string, $limit, $code = 0, \Exception $previous = null)
 {
     parent::__construct(sprintf('Text "%s" is over the length limit (%d) for a title.', $string, $limit), $code, $previous);
 }