Creates a form to edit a MenuItem entity.

@param MenuItem $entity The entity

@return Form The form
170104
private function createMenuItemEditForm(MenuItem $entity)
    {
        $form = $this->createForm(new MenuItemType(), $entity, array(
            'action' => $this->generateUrl('admin_menu_item_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));

        $form->add('submit', 'submit', array('label' => 'Update'));

        return $form;
    }
19642
private function createEditForm(Country $entity)
    {
        $form = $this->createForm(new CountryType($this->get('doctrine.orm.entity_manager')->getRepository('OrkestroLocaleBundle:Locale')), $entity, array(
            'action' => $this->generateUrl('orkestro_backend_country_update', array('iso_code' => $entity->getIsoCode())),
            'method' => 'PUT',
        ));

        $form->add('submit', 'submit', array('label' => 'Update'));

        return $form;
    }
471432
public function createFromMenuItem(MenuItem $menuItem)
    {
        if ($path = $menuItem->getPath()) {
            $uri = $this->request->getBaseUrl().$path;
        } elseif ($menuItem->getRedirectUrl()) {
            $uri = $menuItem->getRedirectUrl();
        } elseif ($menuItem->getInternalUrl()) {
            $uri = $this->request->getBaseUrl().$menuItem->getInternalUrl();
        } elseif ($contentRoute = $menuItem->getContentRoute()) {
            $route = ContentRouteManager::generateRoute($contentRoute, $contentRoute->getPath(), '');
            $uri = $this->request->getBaseUrl().$route->getPath();
        } else {
            $uri = '#';
        }

        $options = [
            'uri' => $uri,
            'label' => $menuItem->getName(),
            'attributes' => [],
            'linkAttributes' => $menuItem->getLinkAttributes(),
            'childrenAttributes' => [],
            'labelAttributes' => [],
            'extras' => [],
            'display' => true,
            'displayChildren' => true,

        ];
        $item = $this->factory->createItem($menuItem->getId(), $options);

        if ($menuItem->isHidden()) {
            $item->setDisplay(false);
        }

        return $item;
    }
937148
private function createEditForm(GalleryItem $entity)
    {
        $form = $this->createForm(new GalleryItemType(), $entity, array(
            'action' => $this->generateUrl('admin_galleryitem_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));

        $form->add('submit', 'submit', array('label' => 'Update'));

        return $form;
    }
626046
public function removeItem(\Wucdbm\Bundle\MenuBuilderBundle\Entity\MenuItem $item) {
        $this->items->removeElement($item);
    }
700320
public function editAction()
    {
        $form = $this->getEditForm();
        $entity = $form->getObject();
        if ($this->getRequest()->isPost()) {
            $data = $this->getRequest()->getPost()->toArray();
            $entityManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
            $hydrator = new DoctrineHydrator($entityManager);
            $hydrator->hydrate($data, $entity);

            if ($form->isValid()) {
                $objectManager = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
                $objectManager->persist($entity);
                $objectManager->flush();
                $controller = explode('/', $this->getRequest()->getUri()->getPath())[2];
                if (!$this->getRequest()->isXmlHttpRequest()) {
                    return $this->redirect()->toRoute(null, ['controller' => $controller]);
                }
                return;
            } else {
                $this->getResponse()->setStatusCode(400);
            }
        }
        $viewModel = $this->getViewModel();
        $viewModel->setTerminal($this->getRequest()->isXmlHttpRequest());

        return $viewModel->setVariables(['form' => $form]);
    }
1067136
public function subMenu($key = null, $menuItem = null)
    {
        if (null === $menuItem) {
            return $this->subMenu;
        }

        if (is_callable($menuItem)) {
            $menu = new AdminMenu($menuItem);
            $this->subMenu[$key] = $menu;
        } else {
            $this->subMenu[$key] = $menuItem;
        }

        return $this;
    }
1207977
private function createMapper($entity)
    {
        $mapper = new EntityMapper();
        $mapper->setAdapter(
            $this->adapters->get(
                $this->getAdapterAlias($entity)
            )
        )
            ->setEntityClassName($entity);
        $this->mappers->set($entity, $mapper);
        return $mapper;
    }
205737
private function createCreateForm(MessageType $entity)
    {
        $form = $this->createForm(MessageTypeType::class, $entity, array(
            'action' => $this->generateUrl('messagetype_create'),
            'method' => 'POST',
        ));
        $this->_addFunctionsToForm($form);

        $form->add('create_group', CheckboxType::class, array('label' => "This is a new group.", 'mapped' => false, 'required' => false));
        $form->add('submit', SubmitType::class, array('label' => 'Create'));

        return $form;
    }
1074759
public function save($entity)
    {
        if ($this->idProperty->getValue($entity) === null) {
            return $this->insert($entity);
        } else {
            return $this->update($entity);
        }

    }
1284859
public function editMenuItemAction(MenuItem $menuItem)
    {
        $em = $this->getDoctrine()->getManager();

        if (!$menuItem) {
            throw $this->createNotFoundException('Unable to find MenuItem entity.');
        }

        $editForm = $this->createMenuItemEditForm($menuItem);
        $deleteForm = $this->createMenuItemDeleteForm($menuItem->getId());

        return array(
            'entity' => $menuItem,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
915386
public function editGalleryItemAction(GalleryItem $entity, Product $product, Request $request)
    {
        if (!$entity) {
            throw $this->createNotFoundException('Unable to find GalleryItem entity.');
        }

        $editForm = $this->createEditGalleryItemForm($entity, $product);
        $deleteForm = $this->createDeleteGalleryItemForm($entity->getId());

        return array(
            'entity' => $entity,
            'product' => $product,
            'edit_form' => $editForm->createView(),
            'delete_form' => $deleteForm->createView(),
        );
    }
1296497
public function fakeEntity($entity = null)
    {
        if ($entity === null) {
            throw new MissingRequiredOptionException('entity to fake');
        }
        $entityFiller = new EntityFiller($entity, $this);

        return $entityFiller->fill();
    }
1203011
public function newMenuItemAction(Menu $menu)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = new MenuItem();
        $entity->setMenu($menu);
        $form = $this->createMenuItemCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
277842
public function createMenuItemAction(Request $request, Menu $menu)
    {
        $entity = new MenuItem();
        $entity->setMenu($menu);
        $form = $this->createMenuItemCreateForm($entity);
        $form->handleRequest($request);
        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            if($entity->getPage()){
                $entity->setPageSlug($entity->getPage());
            }

            $em->persist($entity);

            $this->get('amulen.page.service.menu')->reorder($menu);
            $em->flush();

            $availableLangs = $this->container->getParameter('flowcode_page.available_languages');
            foreach ($availableLangs as $key => $value) {
                $menuItemLabel = new MenuItemLabel();
                $menuItemLabel->setLang($key);
                $menuItemLabel->setContent($entity->getName());
                $menuItemLabel->setMenuItem($entity);
                $em->persist($menuItemLabel);
            }
            $em->flush();

            return $this->redirect($this->generateUrl('admin_menu_items', array('id' => $menu->getId())));
        }

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
1090816
private function createCreateForm(UserGroup $entity)
    {
        $options = array ('action' => $this->generateUrl('admin_usergroup_create'),
                          'method' => 'POST'
                         );

        $form = $this->createForm(new UserGroupType(), $entity, $options);

        return $form;
    }
766289
private function createCreateForm(GalleryItem $entity)
    {
        $form = $this->createForm(new GalleryItemType(), $entity, array(
            'action' => $this->generateUrl('admin_galleryitem_create'),
            'method' => 'POST',
        ));

        $form->add('submit', 'submit', array('label' => 'Create'));

        return $form;
    }