Exemple #1
0
 /**
  * @param \Mindy\Form\BaseForm|ModelForm $owner
  * @param array $attributes
  * @throws Exception
  * @return array
  */
 public function beforeSetAttributes($owner, array $attributes)
 {
     $model = $owner->getModel();
     $ownerModel = $owner->getParentForm()->getInstance();
     if (!isset($ownerModel->metaConfig)) {
         throw new Exception("metaConfig doesn't exists in model: " . $model->className());
     }
     $meta = $ownerModel->metaConfig;
     if (empty($attributes['is_custom'])) {
         $attributes = array_merge($attributes, ['title' => $ownerModel->{$meta['title']}, 'keywords' => MetaGenerator::generateKeywords($ownerModel->{$meta['keywords']}), 'description' => MetaGenerator::generateDescription($ownerModel->{$meta['description']})]);
     }
     return parent::beforeSetAttributes($owner, $attributes);
 }