예제 #1
0
 public function __construct($options = [])
 {
     parent::__construct($options);
     if (!$this->class_name) {
         $this->setInferredClassName();
     }
     //infer from class_name
     if (!$this->foreign_key) {
         $this->foreign_key = [Inflector::instance()->keyify($this->class_name)];
     }
 }
예제 #2
0
 /**
  * Constructs a {@link HasMany} relationship.
  *
  * @param array $options Options for the association
  * @return HasMany
  */
 public function __construct($options = [])
 {
     parent::__construct($options);
     if (isset($this->options['through'])) {
         $this->through = $this->options['through'];
         if (isset($this->options['source'])) {
             $this->setClassName($this->options['source']);
         }
     }
     if (!$this->primary_key && isset($this->options['primary_key'])) {
         $this->primary_key = \is_array($this->options['primary_key']) ? $this->options['primary_key'] : [$this->options['primary_key']];
     }
     if (!$this->class_name) {
         $this->setInferredClassName();
     }
 }