Create a form from an object.

@param  string|object $entity
@return \CmsCommon\Form\FormInterface
1644
public function createForm($entity)
    {
        $formSpec = ArrayUtils::iteratorToArray($this->getFormSpecification($entity));
        if (!isset($formSpec['options']['merge_input_filter'])) {
            $formSpec['options']['merge_input_filter'] = true;
        }

        return $this->getFormFactory()->createForm($formSpec);
    }
853406
private function createEditForm(MediaType $entity)
    {
        $form = $this->createForm(new MediaTypeType(), $entity, array(
            'action' => $this->generateUrl('mediatype_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));

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

        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;
    }
59031
private function createDeleteForm(Parameter $entity)
    {
        return $this->createFormBuilder()
            ->setAction($this->generateUrl('core_parameter_delete', array('id' => $entity->getId())))
            ->setMethod('DELETE')
            ->getForm()
        ;
    }
783985
public function getDescriptorFor($entity)
    {
        return $this->descriptors->containsKey($entity)
            ? $this->descriptors->get($entity)
            : $this->createDescriptor($entity);
    }
770939
public function simpleUpdate($entity){
        $simpleUpdate = new SimpleUpdate($entity,$this->getConfig());
        return $this->update($simpleUpdate);
    }
670176
private function createEditForm(Category $entity)
    {
        $form = $this->createForm($this->get("amulen.classification.form.category"), $entity, array(
            'action' => $this->generateUrl('admin_category_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));

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

        return $form;
    }
444824
public function withInitialValuesFrom($object) : FormWithBinding
    {
        $form = $this->binding->getForm($object);

        return new self(
            $form->getSections(),
            $form->getProcessors(),
            $this->binding->getObjectType(),
            $this->binding->getFieldBindings()
        );
    }
878160
protected function generateMethod(Entity $entity)
    {
        $lines   = $this->generateBody($entity);
        $body    = implode(PHP_EOL, $lines);
        $method  = MethodGenerator::fromArray([
            'name'       => 'fromArray',
            'body'       => $body,
            'static'     => true,
            'parameters' => [
                [
                    'name'          => 'values',
                    'type'          => 'array',
                ]
            ],
            'docblock'   => [
                'shortDescription' => "{@inheritdoc}"
            ]
        ]);

        return $method;
    }
451967
public function createForm($entity, $options = [])
    {
        $options = array_merge($this->type()['formFields']['_create'], $options);

        return $this->Form->create($entity, $options);
    }
967742
public function simpleInsert($entity){
        $simpleInsert = new SimpleInsert($entity,$this->getConfig());
        return $this->insert($simpleInsert);
    }
274098
protected function registerEntity($entity)
    {
        Orm::getRepository($this->getParentEntity())
            ->getIdentityMap()
            ->set($entity);

        return $entity;
    }
376935
public static function save($entity): ResultInterface
    {
        $className = \get_class($entity);
        list($table, , , $fields) = self::getFields($entity, 1);
        $instance = self::getInstance($className);

        $fields = $fields ?? [];
        $query  = Query::table($table)->selectInstance($instance);
        // Set Primary Id to Entity
        $query->addDecorator(function ($primaryId) use ($entity, $className) {
            list(, , $idColumn) = self::getTable($className);
            // When Primary Id is auto increment
            $getter = 'get' . StringHelper::camel($idColumn, false);
            $setter = 'set' . StringHelper::camel($idColumn, false);
            if (method_exists($entity, $getter) && method_exists($entity, $setter)) {
                if ($entity->$getter() === null) {
                    $entity->$setter($primaryId);
                } else {
                    $primaryId = $entity->$getter();
                }
            }
            return $primaryId;
        });
        return $query->insert($fields);
    }
60734
public function createCopyForm($entity, $entityClass)
    {
        return $this->createIdForm($entity, 'copy_', $this->adminRouter->generate($entity, $entityClass, AdminRouter::TYPE_COPY));
    }
48421
public static function delete($entity): ResultInterface
    {
        $className = \get_class($entity);
        list($table, , , $fields) = self::getFields($entity, 3);
        $instance = self::getInstance($className);

        $query = Query::table($table)->selectInstance($instance);
        foreach ($fields ?? [] as $column => $value) {
            $query->where($column, $value);
        }

        return $query->delete();
    }
1029817
private function createEditForm(Contract $entity)
    {
        $form = $this->createForm(new ContractType(), $entity, array(
            'action' => $this->generateUrl('ecommerce_contract_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));

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

        return $form;
    }
728846
public function create(Entity $entity)
    {
        $result = $this->events->shouldExecute($entity, 'before', 'create');
        if (!$result) {
            return false;
        }
        $result = $this->doCreate($entity);
        $this->events->shouldExecute($entity, 'after', 'create');
        return $result;
    }