Ejemplo n.º 1
0
 /**
  * @param FieldEvent $event
  * @DI\Observe("resource.event.field.slug")
  */
 public function onSave(FieldEvent $event)
 {
     $container = $event->getContainer();
     if ($container->getResource()) {
         $resource = $container->getResource();
         $resourceTranslation = $this->loadModel($resource, $this->languageManager->getObject());
         $resourceTranslation->setSlug($event->getValue());
         $this->objectManager->persist($resourceTranslation);
         $this->objectManager->flush();
     }
 }
 /**
  * @param FieldEvent $resourceEvent
  */
 public function onSave(FieldEvent $resourceEvent)
 {
     $container = $resourceEvent->getContainer();
     $field = $resourceEvent->getField();
     $formValue = $resourceEvent->getValue();
     $value = $formValue['containerTo'];
     if ($formValue && $field) {
         //remove containers
         $this->objectManager->getRepository('BigfishEavBundle:Container')->removeRelatedContainers($container, $field);
         //save related containers
         $this->objectManager->getRepository('BigfishEavBundle:Container')->saveRelatedContainers($container, $field, $value);
     }
 }