Esempio n. 1
0
 public function cast($value)
 {
     if (is_a($value, '\\Core\\Model\\Base', true)) {
         return parent::cast($value->getPrimaryKey());
     } else {
         return parent::cast($value);
     }
 }
 public function __construct($model, $name = null, $parameters = null)
 {
     if (!isset($parameters['model'])) {
         throw new Exception('Model not set for parameter');
     }
     if (!isset($parameters['foreign'])) {
         throw new Exception('Foreign key not set for parameter');
     }
     $this->_modelClass = $parameters['model'];
     $this->_foreignKey = $parameters['foreign'];
     if (!is_subclass_of($this->_modelClass, '\\Core\\Model\\Base', true)) {
         throw new Exception($this->_modelClass . ' is not a valid Model');
     }
     parent::__construct($model, $name, $parameters);
 }