Ejemplo n.º 1
0
 public function toModel(Model $model, $fields = null, $ignore = null)
 {
     $model->Permissions = array();
     if (!empty($this->controller->request->data['permission_id'])) {
         $permissionIds = $this->controller->request->data['permission_id'];
         foreach ($permissionIds as $permissionId) {
             $model->Permissions[] = new Permission($permissionId);
         }
     }
     return parent::toModel($model, $fields, $ignore);
 }
Ejemplo n.º 2
0
 public function toModel(Model $model, $fields = null, $ignore = null)
 {
     if ($model->behaviors->hasBehavior('Flagable')) {
         if ($this->hasField('allowComments')) {
             $model->setFlag(NodeFlag::ALLOW_COMMENTS, $this->allowComments->value());
         }
         if ($this->hasField('allowRSS')) {
             $model->setFlag(NodeFlag::ALLOW_RSS, $this->allowRSS->value());
         }
     }
     return parent::toModel($model, $fields, $ignore);
 }
Ejemplo n.º 3
0
 public function toModel(Model $model, $fields = null, $ignore = null)
 {
     if ($model->behaviors->hasBehavior('Flagable')) {
         if ($this->hasField('allowComments')) {
             $model->setFlag(BlogPostFlag::ALLOW_COMMENTS, $this->allowComments->value());
         }
         if ($this->hasField('sticky')) {
             $model->setFlag(BlogPostFlag::STICKY, $this->sticky->value());
         }
     }
     // saving tags
     $this->Tags = new IndexedArray();
     $tags = array_filter(array_unique(preg_split('/\\s+/i', $this->tags->value())));
     foreach ($tags as $tag) {
         $Tag = new Tag(array('name' => $tag, 'model' => DBQuery::quote($model->name)));
         $Tag->set('BlogPostTag', array('model' => DBQuery::quote($model->name)));
         $model->Tags[] = $Tag;
     }
     return parent::toModel($model, $fields, $ignore);
 }