public function createAction(Request $request)
    {
        $contentTypeManager = $this->get('opifer.content.content_type_manager');

        $contentType = $contentTypeManager->create();

        $form = $this->createForm(ContentTypeType::class, $contentType);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            foreach ($form->getData()->getSchema()->getAttributes() as $attribute) {
                $attribute->setSchema($contentType->getSchema());

                foreach ($attribute->getOptions() as $option) {
                    $option->setAttribute($attribute);
                }
            }

            $contentTypeManager->save($contentType);

            $this->addFlash('success', 'Content type has been created successfully');

            return $this->redirectToRoute('opifer_content_contenttype_edit', ['id' => $contentType->getId()]);
        }

        return $this->render($this->getParameter('opifer_content.content_type_create_view'), [
            'content_type' => $contentType,
            'form' => $form->createView(),
        ]);
    }
public function createAction(Request $request)
    {
        $contentTypeManager = $this->get('opifer.content.content_type_manager');

        $contentType = $contentTypeManager->create();

        $form = $this->createForm(ContentTypeType::class, $contentType);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            foreach ($form->getData()->getSchema()->getAttributes() as $attribute) {
                $attribute->setSchema($contentType->getSchema());

                foreach ($attribute->getOptions() as $option) {
                    $option->setAttribute($attribute);
                }
            }

            $contentTypeManager->save($contentType);

            $this->addFlash('success', 'Content type has been created successfully');

            return $this->redirectToRoute('opifer_content_contenttype_edit', ['id' => $contentType->getId()]);
        }

        return $this->render($this->getParameter('opifer_content.content_type_create_view'), [
            'content_type' => $contentType,
            'form' => $form->createView(),
        ]);
    }
public function createAction ( Request $ request ) { $ contentTypeManager = $ this -> get ( 'opifer.content.content_type_manager' ) ; $ contentType = $ contentTypeManager -> create ( ) ; $ form = $ this -> createForm ( ContentTypeType :: class , $ contentType ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { foreach ( $ form -> getData ( ) -> getSchema ( ) -> getAttributes ( ) as $ attribute ) { $ attribute -> setSchema ( $ contentType -> getSchema ( ) ) ; foreach ( $ attribute -> getOptions ( ) as $ option ) { $ option -> setAttribute ( $ attribute ) ; } } $ contentTypeManager -> save ( $ contentType ) ; $ this -> addFlash ( 'success' , 'Content type has been created successfully' ) ; return $ this -> redirectToRoute ( 'opifer_content_contenttype_edit' , [ 'id' => $ contentType -> getId ( ) ] ) ; } return $ this -> render ( $ this -> getParameter ( 'opifer_content.content_type_create_view' ) , [ 'content_type' => $ contentType , 'form' => $ form -> createView ( ) , ] ) ; }
Create a ContentType.

@param Request $request

@return RedirectResponse|Response
Create a ContentType .