Beispiel #1
0
 public function initialize(Jam_Meta $meta, $name)
 {
     parent::initialize($meta, $name);
     if (!$this->vocabulary_foreign_key) {
         $this->vocabulary_foreign_key = Jam::meta($this->foreign_model)->association('vocabulary')->foreign_key;
     }
 }
Beispiel #2
0
 /**
  * Initialize foreign_key, as, and polymorphic_key with default values
  *
  * @param   string  $model
  * @param   string  $name
  */
 public function initialize(Jam_Meta $meta, $name)
 {
     parent::initialize($meta, $name);
     if (!$this->foreign_key) {
         $this->foreign_key = $this->model . '_id';
     }
     // Polymorphic associations
     if ($this->as) {
         $this->foreign_key = $this->as . '_id';
         if (!$this->polymorphic_key) {
             $this->polymorphic_key = $this->as . '_model';
         }
     }
 }
Beispiel #3
0
 /**
  * Automatically sets foreign to sensible defaults.
  *
  * @param   string  $model
  * @param   string  $name
  * @return  void
  */
 public function initialize(Jam_Meta $meta, $name)
 {
     parent::initialize($meta, $name);
     if (!$this->join_table) {
         $this->join_table = Jam_Association_Collection::guess_through_table($this->foreign_model, $this->model);
     }
     if (!$this->foreign_key) {
         $this->foreign_key = $this->model . '_id';
     }
     if ($this->join_table_paranoid === TRUE) {
         $this->join_table_paranoid = 'is_deleted';
     }
     if (!$this->association_foreign_key) {
         $this->association_foreign_key = $this->foreign_model . '_id';
     }
 }
Beispiel #4
0
 /**
  * Remove items from this association (withought deleteing it) and persist the data in the database
  * @param  Jam_Validated                $model
  * @param  Jam_Array_Association $collection
  */
 public function clear(Jam_Validated $model, Jam_Array_Association $collection)
 {
     foreach ($collection as $item) {
         $item->{$this->foreign_key} = NULL;
     }
     parent::clear($model, $collection);
 }