Ejemplo n.º 1
0
 public function entityLanguageSwitchAction($bundle, $entity, $id)
 {
     $locales = $this->getParameter('locales');
     $Entity = new \ITF\AdminBundle\Admin\Entity($entity, $this);
     $request = Request::createFromGlobals();
     $current_locale = $request->get('locale');
     if (empty($current_locale)) {
         $current_locale = $this->getDefaultLocale();
     }
     $items = array();
     foreach ($locales as $locale) {
         $items[] = array('label' => strtoupper($locale), 'active' => $locale == $current_locale, 'url' => $this->generateUrl('admin_edit', array('bundle' => $bundle, 'entity' => $Entity->getName('strtolower'), 'id' => $id, 'locale' => $locale)));
     }
     return $this->render('@ITFAdmin/Admin/helper/bs.btn-groups.html.twig', array('items' => $items));
 }
Ejemplo n.º 2
0
 /**
  * @param Entity $entity
  * @param $type
  *
  * @return \Symfony\Component\Form\Form
  */
 private function createActionForm($entity, $type, $entity_locale = NULL)
 {
     $ah = $this->get('itf.admin_helper');
     $type_class = $entity->getFormTypeClass();
     switch ($type) {
         default:
         case 'add':
             $method = 'POST';
             $action = $this->generateUrl('admin_create', array('bundle' => $ah->getBundleNameShort(), 'entity' => $entity->getName('strtolower')));
             $submit_label = 'Create';
             break;
         case 'edit':
             $method = 'PUT';
             $infoArray = array('bundle' => $ah->getBundleNameShort(), 'entity' => $entity->getName('strtolower'), 'id' => $entity->getEntity()->getId());
             if (!empty($entity_locale)) {
                 $infoArray['locale'] = $entity_locale;
             }
             $action = $this->generateUrl('admin_update', $infoArray);
             $submit_label = 'Update';
             break;
     }
     // create form
     $form = $this->createForm(new $type_class($this->container), $entity->getEntity(), array('action' => $action, 'method' => $method, 'attr' => array('type' => $type)));
     // if tree add root
     /*if ($this->get('itf.admin.annotation_reader')->isGedmoTree($entity->getEntity())) {
     			$repo = $ah->getEntityRepositoryReference($entity->getName());
     
     			$this->get('itf.admin.gedmo.tree.form')->handleFormNew($form, $repo, $entity->getFQClassName());
     		}*/
     $form->add('submit_stay', 'submit', array('label' => $submit_label, 'attr' => array('class' => 'btn btn-success')));
     $form->add('submit', 'submit', array('label' => $submit_label . ' & back', 'attr' => array('class' => 'btn btn-success')));
     return $form;
 }