예제 #1
0
파일: Container.php 프로젝트: ytnuk/shop
 public function setValues($values, $erase = FALSE) : Ytnuk\Orm\Form\Container
 {
     $container = parent::setValues($values, $erase);
     $link = $this->entity->menu->link;
     $link->module = 'Shop:Category';
     if (!$link->parameters->get()->getBy(['key' => $key = current($this->repository->getEntityMetadata()->getPrimaryKey())])) {
         $linkParameter = new Ytnuk\Link\Parameter\Entity();
         $linkParameter->key = $key;
         $linkParameter->value = $this->entity->getPersistedId() ?: $this->repository->persist($this->entity)->getPersistedId();
         $link->parameters->add($linkParameter);
     }
     return $container;
 }
예제 #2
0
 public function setValues($values, $erase = FALSE) : parent
 {
     $translates = iterator_to_array($this['translates']->getComponents());
     array_walk($translates, function (Ytnuk\Translation\Translate\Form\Container $container, string $locale) use(&$values) {
         if (!$container->values->value) {
             $this['translates']->removeComponent($container);
             $container->removeEntity();
             unset($values['translates'][$locale]);
         }
     });
     $container = parent::setValues($values, $erase);
     $parent = $this->lookup(parent::class, FALSE);
     if ($parent instanceof parent && !(array) $values['translates']) {
         $this->removeEntity();
         if ($parent->getMetadata()->getProperty($this->getName())->isNullable) {
             $parent->removeEntity();
         }
     }
     return $container;
 }