Creates a form to create a GalleryItem entity.

@param GalleryItem $entity The entity

@return \Symfony\Component\Form\Form The 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;
    }
24415
public function subCreateAction(Request $request, $folderId)
    {
        /** @var EntityManager $em */
        $em = $this->getDoctrine()->getManager();

        /* @var Folder $parent */
        $parent = $em->getRepository('KunstmaanMediaBundle:Folder')->getFolder($folderId);
        $folder = new Folder();
        $folder->setParent($parent);
        $form = $this->createForm(FolderType::class, $folder);
        if ($request->isMethod('POST')) {
            $form->handleRequest($request);
            if ($form->isSubmitted() && $form->isValid()) {
                $em->getRepository('KunstmaanMediaBundle:Folder')->save($folder);
                $this->addFlash(
                    FlashTypes::SUCCESS,
                    $this->get('translator')->trans('media.folder.addsub.success.text', array(
                        '%folder%' => $folder->getName(),
                    ))
                );
                if (strpos($request->server->get('HTTP_REFERER', ''), 'chooser') !== false) {
                    $redirect = 'KunstmaanMediaBundle_chooser_show_folder';
                } else {
                    $redirect = 'KunstmaanMediaBundle_folder_show';
                }

                $type = $request->get('type');

                return new RedirectResponse(
                    $this->generateUrl($redirect,
                        array(
                            'folderId' => $folder->getId(),
                            'type' => $type,
                        )
                    )
                );
            }
        }

        $galleries = $em->getRepository('KunstmaanMediaBundle:Folder')->getAllFolders();

        return $this->render(
            'KunstmaanMediaBundle:Folder:addsub-modal.html.twig',
            array(
                'subform' => $form->createView(),
                'galleries' => $galleries,
                'folder' => $folder,
                'parent' => $parent,
            )
        );
    }
339384
public function add($entity, $quantity)
    {
        if ($this->itemExists($entity)) {
            $cartItemIndex = $this->items->search($this->cartItemsCheck($entity));

            return $this->incrementQuantityAt($cartItemIndex, $quantity);
        }

        $this->items->push(CartItem::createFrom($entity, $quantity));

        event(new CartItemAdded($entity));

        return $this->cartUpdates($isNewItem = true);
    }
649483
protected function storeEntity($entity)
    {
        $this->checkEntityType($entity);

        $store = new Store($this->aggregate($entity), $this->newQueryBuilder());

        return $store->execute();
    }
601649
public function getCreateForm ($requestOrDataArray, array $options=array(), $entity=false)
    {
        $formBuilder = $this->Core->getFormFactory();
        if (false === $entity) {
            $newEntity = new $this->entityClass();
        } else {
            $newEntity = $entity;
        }
        $createForm  = $formBuilder->create(new $this->createFormClass(), $newEntity, $options);

        // Bind request data to form
        if (is_array($requestOrDataArray)) {
            $createForm->submit($requestOrDataArray);
        } else {
            $createForm->handleRequest($requestOrDataArray);
        }

        return $createForm;
    }
866565
public function newAction(Request $request, MenuItem $menuItemId)
    {
        $entity = new MenuItem();
        $form   = $this->createForm('CoreExtraBundle\Form\SubMenuItemType', $entity);
        $form->handleRequest($request);
        
        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $entity->getParentMenuItem($menuItemId);
            $em->persist($entity);
            $em->flush();
            
            //images
            $image = $form->getNormData()->getImage();
            if ($image instanceof Image) {
                $this->get('core_manager')->uploadMenuImage($entity);
            }
            
            $this->get('session')->getFlashBag()->add('success', 'menu.created');

            return $this->redirectToRoute('coreextra_menuitem_show', array('id' => $entity->getId()));
        }
        
        return array(
            'entity' => $entity,
            'menuitem' => $menuItemId,
            'form'   => $form->createView(),
        );
    }
1331008
private function createEditForm(Episode $entity)
    {
        $form = $this->createForm(
            new EpisodeType(),
            $entity,
            [
                'action' => $this->generateUrl(
                    'oktolab_episode_update',
                    ['id' => $entity->getId()]
                ),
                'method' => 'POST'
            ]
        );

        $form->add(
            'submit',
            'submit',
            ['label' => 'oktolab_media.edit_episode_button']
        );

        return $form;
    }
1279985
public function deleteGalleryItemAction(Request $request, GalleryItem $entity)
    {
        $form = $this->createDeleteForm($entity->getId());
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();

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

            $em->remove($entity);
            $em->flush();
        }

        return $this->redirect($this->generateUrl('admin_product'));
    }
934906
public function formList($entity)
    {
        if ($entity = Entity::fromYamlFile($entity)) {
            $list = new FormList($entity);

            return $list->view();
        } else {
            abort(404);
        }
    }
539655
protected function createFromModel($entity, $quantity)
    {
        $this->modelType = get_class($entity);
        $this->modelId = $entity->{$entity->getKeyName()};
        $this->setName($entity);
        $this->setPrice($entity);
        $this->setImage($entity);
        $this->quantity = $quantity;

        return $this;
    }
443718
private function createEditForm(Role $entity)
    {
        $form = $this->createForm('sam_role', $entity, array(
            'action' => $this->generateUrl('sam_role_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));

        return $form;
    }
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;
    }
156066
protected function createAbility($ability, $entity, $attributes)
    {
        return Models::ability()->createForModel($entity, $attributes + [
            'name' => $ability,
        ]);
    }
164687
public function getOrCreatePersistAction($entity) {
		$this->removeActionPool->removeAction($entity);
		return $this->persistActionPool->getOrCreateAction($entity);
	}
647089
protected function createOptionsBody(Entity $entity)
    {
        $descriptor = $entity->getDescriptor();
        $values     = [];
        $lines      = [];

        $options    = $descriptor->getOptions();
        $extensions = $options->extensions();

        $lines[] = '$options = \google\protobuf\MessageOptions::fromArray([';
        $lines   = array_merge($lines, $this->generateArrayLines($values));
        $lines[] = ']);';
        $lines[] = null;

        for ($extensions->rewind(); $extensions->valid(); $extensions->next()) {
            $extension = $extensions->current();
            $info      = $extensions->getInfo();

            $method = '\\' . $extension->getMethod();
            $value  = var_export($info, true);
            $name   = $extension->getName();

            if (is_object($info)) {
                $value = '\\' . $value;
            }

            $lines[] = '$options->extensions()->add(' . $method . '(), ' . $value . ');';
        }

        return $lines;
    }
358921
public function setGallery(\Amulen\MediaBundle\Entity\Gallery $gallery = null)
    {
        $this->gallery = $gallery;

        return $this;
    }
846372
private function createCreateForm(Collection $entity)
    {
        $form = $this->createForm($this->get('amulen.classification.form.collection'), $entity, array(
            'action' => $this->generateUrl('admin_collection_create'),
            'method' => 'POST',
        ));

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

        return $form;
    }