Exemple #1
0
 public function contributeToClass($field, $model)
 {
     parent::contributeToClass($field, $model);
     assert(!$model->meta->hasAutoField, sprintf("The Model '%s' more than one AutoField, which is not allowed.", $this->scopeModel->meta->modelName));
     $this->scopeModel->meta->hasAutoField = true;
     $this->scopeModel->meta->autoField = $this;
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function contributeToClass($fieldName, $modelObject)
 {
     parent::contributeToClass($fieldName, $modelObject);
     $callback = function ($kwargs) {
         /* @var $field RelatedField */
         /** @var $related Model */
         $related = $kwargs['relatedModel'];
         $field = $kwargs['fromField'];
         $field->relation->toModel = $related;
         $field->doRelatedClass($related, $kwargs['scopeModel']);
     };
     Tools::lazyRelatedOperation($callback, $this->scopeModel, $this->relation->toModel, ['fromField' => $this]);
 }