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);
     }
 }
Ejemplo n.º 3
0
 public function onSave(FieldEvent $event)
 {
     if ($event->getValue()) {
         $findAttachment = $this->objectManager->getRepository('BigfishMediaBundle:ImageInstance')->find($event->getValue());
         $content = $event->getContent();
         if ($findAttachment) {
             $content = $event->getContent();
             $content->setImageInstance($findAttachment);
             $content->setVarchar($findAttachment->getId());
             $this->objectManager->persist($content);
             $this->objectManager->flush();
         } else {
             $this->objectManager->remove($content);
             $this->objectManager->flush();
         }
     }
 }