Пример #1
0
 public function set(AfterCommandInterface $command)
 {
     $result = $command->extractResult();
     if (null === $result) {
         return null;
     }
     if ($result instanceof Collection) {
         $items = clone $result;
         $items->map(function ($entity) {
             return $this->setEntityExisting($entity);
         });
         return $items;
     } else {
         return $this->setEntityExisting($result);
     }
 }
 public function translate(AfterCommandInterface $command)
 {
     $result = $command->extractResult();
     if (null === $result) {
         return null;
     }
     $class = $command->hasClass() ? $command->getClass() : EntityOperatedCommandInterface::DEFAULT_CLASS;
     if ($result instanceof Collection) {
         $items = clone $result;
         $items->map(function ($itemData) use($class) {
             $entity = $this->toEntity($itemData, $class);
             return $entity;
         });
         return $items;
     } else {
         return $this->toEntity($result, $class);
     }
 }
Пример #3
0
 public function toId(AfterCommandInterface $command)
 {
     $result = $command->extractResult();
     $command = new CreateUuidCommand($result);
     return $this->delegate($command);
 }