コード例 #1
0
 /**
  * Modify an entity.
  *
  * @param BaseModel $entity
  * @return BaseModel
  */
 private function modifyEntity(BaseModel $entity)
 {
     if ($this->showOnly) {
         $attributes = $entity->getAttributes();
         $newHidden = array_diff(array_keys($attributes), $this->showOnly);
         $entity->setHidden($newHidden);
     }
     if ($this->makeVisible) {
         $hidden = $entity->getHidden();
         $newHidden = array_diff($hidden, $this->makeVisible);
         $entity->setHidden($newHidden);
     }
     if ($this->hide) {
         $hidden = $entity->getHidden();
         $newHidden = array_merge($hidden, $this->hide);
         $entity->setHidden($newHidden);
     }
     if ($this->customizations) {
         foreach ($this->customizations as $key => $value) {
             $entity->{$key} = $value;
         }
     }
     if (!empty($this->appends)) {
         foreach ($this->appends as $appendKey => $appendValue) {
             $entity->{$appendKey} = $appendValue;
         }
     }
     return $entity;
 }