/**
  * @param \LeanMapper\Entity $entity
  * @return mixed|void
  * @throws \movi\InvalidArgumentException
  */
 public function persist(\LeanMapper\Entity $entity)
 {
     if (!$entity instanceof TranslatableEntity) {
         throw new InvalidArgumentException('Only translatable entities can be persisted.');
     }
     parent::persist($entity);
 }
 /**
  * @param Form $form
  */
 public function processValues(Form $form)
 {
     $values = $form->getValues();
     $properties = $this->entity->getReflection()->getEntityProperties();
     $modified = $this->entity->getModifiedRowData();
     foreach ($values as $key => $value) {
         if ($value instanceof FileUpload || $value instanceof \Traversable) {
             continue;
         }
         if (array_key_exists($key, $properties)) {
             $property = $properties[$key];
             if ($property->hasRelationship() === false && $property->isBasicType() && !array_key_exists($key, $modified)) {
                 $this->entity->{$key} = $value;
             }
         }
     }
     if ($this->entity->isModified()) {
         $this->repository->persist($this->entity);
     }
 }
Exemple #3
0
 /**
  * @param Repository $repository
  * @return $this
  */
 public function setRepository(Repository $repository)
 {
     $this->repository = $repository;
     $this->setItems($repository->findAll());
     return $this;
 }
 public function __construct(Repository $repository)
 {
     $this->repository = $repository;
     $this->statement = $repository->getStatement();
 }