Example #1
0
 /**
  * Constructs an object that represents a relationship between two model classes.
  *
  * @see Chaos\Relationship
  * @param array $config The relationship's configuration, which defines how the two models in
  *                      question are bound. The available options are:
  *                      - `'junction'` _boolean_ : Indicates whether the relation is a junction table or not.
  *                                                 If `true`, associative entities are removed when unsetted.
  *                                                 All `hasMany` relations used aby an `hasManyThrough` relation will
  *                                                 have their junction attribute set to `true`. Default to `false`.
  */
 public function __construct($config = [])
 {
     $defaults = ['junction' => false];
     $config += $defaults;
     parent::__construct($config);
     $this->_junction = $config['junction'];
 }
Example #2
0
 /**
  * Constructs an object that represents a relationship between two model classes.
  *
  * @see Chaos\Relationship
  */
 public function __construct($config = [])
 {
     $keys = isset($config['keys']);
     parent::__construct($config);
     if (!$keys) {
         $key = $this->_conventions->apply('key');
         $this->_keys = [$this->_conventions->apply('reference', $config['from']) => $key];
     }
 }
Example #3
0
 /**
  * Constructs an object that represents a relationship between two model classes.
  *
  * @see chaos\Relationship
  */
 public function __construct($config = [])
 {
     $keys = isset($config['keys']);
     parent::__construct($config);
     if (!$keys) {
         $primaryKey = $this->_conventions->apply('primaryKey');
         $this->_keys = [$this->_conventions->apply('foreignKey', $config['from']) => $primaryKey];
     }
 }