Inheritance: extends Validatable
Esempio n. 1
0
 private function selectModelColumns(Model $metaInstance, $alias)
 {
     if ($this->_selectModel) {
         $prefix = $this->aliasPrefixForSelect($alias);
         $this->_query->selectColumns = $this->_query->selectColumns + ColumnAliasHandler::createSelectColumnsWithAliases($prefix, $metaInstance->_getFields(), $alias);
     }
 }
Esempio n. 2
0
 public function matches($argument)
 {
     if (get_class($this->expected) !== get_class($argument)) {
         return false;
     }
     $actualAttributes = Arrays::filterByAllowedKeys($argument->attributes(), $this->expected->getFields());
     return $this->expectedAttributes == $actualAttributes;
 }
Esempio n. 3
0
 private function _generatePredefinedAttributes($field)
 {
     $id = $this->_generateId($field);
     $attributes = array('id' => $id);
     if (in_array($field, $this->_object->getErrorFields())) {
         $attributes['class'] = 'error';
     }
     return $attributes;
 }
Esempio n. 4
0
 public function validate()
 {
     parent::validate();
     if (!$this->name) {
         parent::error('Empty name');
         $this->_errorFields[] = 'name';
     }
 }
Esempio n. 5
0
 public function __construct($attributes = array())
 {
     parent::__construct(array('hasMany' => array('products' => array('class' => 'Test\\Product', 'foreignKey' => 'id_category'), 'products_starting_with_b' => array('class' => 'Test\\Product', 'foreignKey' => 'id_category', 'conditions' => "products.name LIKE 'b%'"), 'products_ending_with_b_or_y' => array('class' => 'Test\\Product', 'foreignKey' => 'id_category', 'conditions' => function () {
         return WhereClause::create("products.name LIKE ? OR products.name LIKE ?", array('%b', '%y'));
     }), 'products_name_bob' => array('class' => 'Test\\Product', 'foreignKey' => 'id_category', 'conditions' => array("products.name" => "bob")), 'products_ordered_by_name' => array('class' => 'Test\\Product', 'foreignKey' => 'id_category', 'order' => array("products.name ASC"))), 'hasOne' => array('product_named_billy' => array('class' => 'Test\\Product', 'foreignKey' => 'id_category', 'conditions' => "products.name = 'billy'")), 'belongsTo' => array('parent' => array('class' => 'Test\\Category', 'foreignKey' => 'id_parent', 'referencedColumn' => 'id')), 'attributes' => $attributes, 'fields' => $this->_fields));
 }
Esempio n. 6
0
 public function __construct($attributes = array())
 {
     parent::__construct(array('table' => 'products', 'attributes' => $attributes, 'fields' => array('description' => self::$defaultDescription, 'name' => function () {
         return ProductWithDefaults::$defaultName;
     }, 'id_category', 'id_manufacturer', 'sale')));
 }
Esempio n. 7
0
 public function __construct($attributes = array())
 {
     parent::__construct(array('table' => 'orders', 'sequence' => 'orders_id_order_seq', 'primaryKey' => 'id_order', 'attributes' => $attributes, 'fields' => $this->_fields));
 }
Esempio n. 8
0
 public function __construct($attributes = array(), $beforeSaveCallback = null, $afterSaveCallback = null)
 {
     parent::__construct(array('beforeSave' => $beforeSaveCallback, 'afterSave' => $afterSaveCallback, 'table' => 'products', 'primaryKey' => 'id', 'attributes' => $attributes, 'fields' => array('name')));
 }
Esempio n. 9
0
 public function __construct($attributes = [])
 {
     parent::__construct(['attributes' => $attributes, 'fields' => ['id', 'name', 'params', 'created_at' => Clock::nowAsString()]]);
 }
Esempio n. 10
0
 public function __construct($attributes = [])
 {
     parent::__construct(['attributes' => $attributes, 'fields' => ['id', 'game_user_id', 'field', 'multiplier', 'round'], 'belongsTo' => ['game_user' => ['class' => 'GameUser', 'foreignKey' => 'game_user_id', 'referencedColumn' => 'id']]]);
 }
Esempio n. 11
0
 public function __construct(array $params)
 {
     parent::__construct($params);
 }
Esempio n. 12
0
 private function _assertSamePersistentAttributes(Model $expected)
 {
     $expectedAttributes = Arrays::filterByAllowedKeys($expected->attributes(), $expected->getFields());
     $actualAttributes = Arrays::filterByAllowedKeys($this->_actual->attributes(), $this->_actual->getFields());
     AssertAdapter::assertEquals($expectedAttributes, $actualAttributes, 'Models have different attributes ');
 }
Esempio n. 13
0
 /**
  * @return bool
  */
 public function delete()
 {
     $this->current_game_user_id = null;
     $this->winner_game_user_id = null;
     $this->update();
     GameUser::where(['game_id' => $this->id])->deleteEach();
     return parent::delete();
 }
Esempio n. 14
0
 public function __construct($attributes = array())
 {
     parent::__construct(array('table' => 'products', 'primaryKey' => '', 'attributes' => $attributes, 'fields' => $this->_fields));
 }
Esempio n. 15
0
 /**
  * @test
  */
 public function shouldThrowExceptionIfNoRelation()
 {
     $model = new Model(array('fields' => array('field1')));
     //when
     try {
         $model->getRelation('invalid');
         $this->fail();
     } catch (InvalidArgumentException $e) {
     }
 }
Esempio n. 16
0
 public function __construct($attributes = array())
 {
     parent::__construct(array('table' => 'order_products', 'sequence' => '', 'primaryKey' => '', 'attributes' => $attributes, 'belongsTo' => array('product' => array('class' => 'Test\\Product', 'foreignKey' => 'id_product'), 'order' => array('class' => 'Test\\Order', 'foreignKey' => 'id_order')), 'fields' => $this->_fields));
 }
Esempio n. 17
0
 public function validate()
 {
     parent::validate();
     $this->validateNotBlank($this->login, 'Login cannot be blank');
 }
Esempio n. 18
0
 public function __construct($attributes = array())
 {
     parent::__construct(array('table' => 'products', 'primaryKey' => 'id', 'fields' => array('name'), 'sequence' => '', 'attributes' => $attributes));
 }
Esempio n. 19
0
 /**
  * @return bool
  */
 public function delete()
 {
     Hit::where(['game_user_id' => $this->id])->deleteAll();
     return parent::delete();
 }
Esempio n. 20
0
 public static function getNoLazy(Model $model, $attribute)
 {
     return Arrays::getValue($model->attributes(), $attribute);
 }
Esempio n. 21
0
 public function __construct()
 {
     parent::__construct(array('fields' => array('name')));
 }
Esempio n. 22
0
 public function __construct($attributes = array())
 {
     parent::__construct(array('hasMany' => array('products' => array('class' => 'Test\\Product', 'foreignKey' => 'id_manufacturer')), 'attributes' => $attributes, 'fields' => $this->_fields));
 }