Ejemplo n.º 1
0
 protected function updateBaseTranslation(Blog $blog)
 {
     $blog->setTranslatableLocale($this->getRequest()->getLocale());
     foreach ($blog->getTranslations() as $translation) {
         /** @var BlogTranslation $translation */
         $translation->updateParentFields();
     }
 }
Ejemplo n.º 2
0
 /**
  * @ORM\PrePersist
  */
 public function updateParentFields()
 {
     if ($this->object->getLocale() == $this->locale) {
         $method = 'set' . ucfirst($this->field);
         if (method_exists($this->object, $method)) {
             $this->object->{$method}($this->getContent());
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @Method("POST")
  */
 public function orderImagesAction(Blog $blog)
 {
     $order = $this->getRequest()->get('images', array());
     $images = $blog->getImages();
     $em = $this->getDoctrine()->getManager();
     $i = 1;
     foreach ($order as $id) {
         foreach ($images as $image) {
             /** @var BlogImage $image */
             if ($image->getId() == $id) {
                 $image->setStackOrder($i++) && $em->persist($image);
             }
         }
     }
     $em->flush();
     return new Response('ok');
 }