Select the type of content before actually creating a new content item.

@return Response|RedirectResponse
341569
public function selectLayoutTypeAction()
    {
        $contentTypes = $this->get('opifer.content.content_type_manager')->getRepository()->findAll();

        if (!$contentTypes) {
            return $this->redirectToRoute('opifer_cms_layout_create');
        }

        return $this->render($this->getParameter('opifer_content.content_select_layout_type'), [
            'content_types' => $contentTypes,
        ]);
    }
663758
public function add()
    {
        $this->loadModel('Content.ContentTypes');
        $this->loadModel('User.Roles');
        $type = $this->ContentTypes->newEntity();

        if ($this->request->data()) {
            $type = $this->ContentTypes->patchEntity($type, $this->request->data());
            $errors = $type->errors();
            $success = empty($errors);

            if ($success) {
                $success = $this->ContentTypes->save($type);
                if ($success) {
                    $this->Flash->success(__d('content', 'Content type created, now attach some fields.'));
                    $this->redirect(['plugin' => 'Content', 'controller' => 'fields', 'type' => $type->slug]);
                }
            }

            if (!$success) {
                $this->Flash->danger(__d('content', 'Content type could not be created, check your information.'));
            }
        }

        $roles = $this->Roles->find('list');
        $this->title(__d('content', 'Define New Content Type'));
        $this->set(compact('type', 'roles'));
        $this->set('languages', LocaleToolbox::languagesList());
        $this->Breadcrumb
            ->push('/admin/content/manage')
            ->push(__d('content', 'Content Types'), '/admin/content/types')
            ->push(__d('content', 'Creating Content Type'), '#');
    }
4067
function content()
    {
        if ( $this->Content === null )
        {
            $eventType = $this->eventType();
            $this->Content = $eventType->eventContent( $this );
        }
        return $this->Content;
    }
887685
function getContentItemSelection()
    {
        $this->json->{self::CONTENT_ITEMS} = $this->items;
        unset($this->json->{self::DATA_CLAIM});
        if ( isset($this->claim->data) ) {
            $this->json->{self::DATA_CLAIM} = $this->claim->data;
        }
        return $this->json;
    }
909318
public function canGenerateContentAction()
    {
        if ($this->manager->isValidUrl($this->request->get('url'))) {

            $graph = $this->manager->getGraph($this->request->get('url'));

            if (isset($graph['type'])) {
                return $this->render(
                    'ClarolineCoreBundle:Home/graph:'.$graph['type'].'.html.twig',
                    array('content' => $graph),
                    true
                );
            }
        }

        return new Response('false'); //in case is not valid URL
    }
1148767
public function create($type, Request $request)
    {
        if ($type && $product = $this->productManager->findByNamespace($type)) {
            $categories = $this->category->all()->nest()->listsFlattened('name');
            $shops = $this->shop->all();
            $optionTypes = $this->optionManager->all();

            return view('product::admin.products.create', compact('product', 'categories', 'shops', 'optionTypes'));
        }

        // If type is not exists, default type will be set
        $first = $this->productManager->first();

        return redirect()->route($request->route()->getName(), ['type' => $first->getEntityNamespace()]);
    }
316236
public function defaultAction()
    {
        $lng = \Cmf\Language\Factory::get($this);
        HelperFactory::getMeta()->clear();
        HelperFactory::getJS()->clear();
        HelperFactory::getStyle()->clear();
        HelperFactory::getTitle()->setTitle('Redirect');
        if ($path = urldecode(Application::getRequest()->get('path'))) {
            HelperFactory::getMeta()->addTag('refresh', '0; url=' . $path);
            $response = ['path' => $path];
        } else {
            $response = ['error' => $lng['error_badPath']];
        }

        return $response;
    }
729699
public function editAction()
    {
        // Load entity
        $entity = $this->getMapper()->findById($this->params('id'));
        if (!$entity) {
            // Add failure message
            $this->flashMessenger()
                    ->addMessage(
                            'That ' . strtolower($this->getEntityName())
                            . ' does not exist.'
            );
            return $this->redirect()->toRoute($this->indexRoute);
        }

        // Load form
        $form = $this->getForm('Edit' . $this->getEntityName());
        $form->bind($entity);

        // Implement Post/Redirect/Get pattern
        $prg = $this->prg();
        if ($prg instanceof Response) {
            return $prg;
        } else if (false !== $prg) {

            // Set form data
            $form->setData($prg);

            // Edit entity
            $result = $this->getService()->edit();
            if ($result) {
                return $this->redirect()->toRoute($this->indexRoute);
            }
        }

        // Set up view model
        $viewModel = new ViewModel(array(
            'entityName' => $this->getEntityName(),
            'form'       => $form,
        ));
        $viewModel->setTemplate('infinity-base/crud/edit');

        return $viewModel;
    }
489879
protected function createAction()
    {
        if (strtolower($this->option('type')) == 'regular' || $this->option('type') == null) {
            return $this->createView();
        }
        if (strtolower($this->option('type')) == 'controller') {
            return $this->createController();
        }
        return $this->createResourceController();
    }
1247519
protected function getRenderType()
    {
        $headers = $this->request->getHeaders();
        
        if (isset($headers['X-Requested-With'])) {
            return 'json';
        }
        
        if ($this->input('get.ajax')) {
            return 'json';
        }
        
        $contentType = $this->request->detectContentType();
        
        if (strpos($contentType, 'json')) {
            return 'json';
        } elseif (strpos($contentType, 'xml')) {
            return 'xml';
        } elseif (strpos($contentType, 'html')) {
            return 'html';
        } elseif (strpos($contentType, 'plain')) {
            return 'text';
        }
        
        return 'html';
    }
479993
private function createDummyContent()
    {
        $this->info("Creating default roles...");
        UserGroup::createDefaultRoles();
        $this->advanceBar();

        $this->info("Creating admin user...");
        $this->createAdminUser();
        $this->advanceBar();

        // Create Default Language
        $this->info("Creating default language...");
        factory(\App\Models\Language::class)->create(
            [
            'name' => $this->PRIMARY_LANGUAGE->name,
            'nativeName' => $this->PRIMARY_LANGUAGE->nativeName,
            'slug' => $this->PRIMARY_LANGUAGE->slug,
            'isDefault' => true
            ]
        );
        $this->advanceBar();

        $this->info("Creating default post types...");
        (new \PostTypeSeeder())->createDefaultPostTypes();
        $this->advanceBar();

        // Create tags example
        $this->info("Creating example tags...");
        (new \TagSeeder())->run(20, null, true);
        $this->advanceBar();

        // Create a category
        $this->info("Creating an example category...");
        $categoryObj = new \CategorySeeder();
        $categoryObj->exampleTitles = true;
        $categoryObj->run(3, null);
        $this->advanceBar();

        $this->info("Creating example posts...");
        (new \PostSeeder())->run(0, 5, '', 0, 0, 0, false);
        $this->advanceBar();

        // Create default permalinks
        $this->info("Creating default permalinks...");
        (new \PermalinksTableSeeder())->run();
        $this->advanceBar();

        // Creating settings
        $this->info("Saving settings...");
        $this->setSettings();
        $this->advanceBar();

        // Create Primary Menu
        $this->info("Creating primary Menu...");
        $menuSeeder = new \MenuSeeder();
        $menu = $menuSeeder->createPrimaryMenu();
        $menuSeeder->addHomepageToPrimaryMenu($menu);
        $menuSeeder->addAboutToPrimaryMenu($menu);
        $menuSeeder->addCategoryToMenu($menu);
        $this->advanceBar();

        return $this;
    }
931182
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(),
        ]);
    }
459330
public function create()
	{
		$arrNodes = false;

		if ($this->insideRoot)
		{
			$objContent = \ContentModel::findById($this->data->pid);

			$rootId = Controller::getRootPageId($objContent->ptable, $objContent->pid);

			if (null !== $rootId)
			{
				$objPage = \PageModel::findWithDetails($rootId);

				if ($this->insideLang || empty($objPage->domain))
				{
					$arrNodes = array($rootId);
				}
				else
				{
					$arrNodes = (array) \PageModel::findByDns($objPage->domain)->fetchEach('id');
				}
			}
		}
		
		if ($this->multiArticle)
		{
			$this->generateDCA('multiArticle', array
			(
				'inputType' => 'articleTree',
				'label'		=> array($this->label, $this->description),
				'eval'		=> array
				(
					'multiple'		=>	true,				
					'fieldType'		=>	'checkbox', 
					'orderField'	=>	$this->virtualFieldName('orderArticle'),
					'mandatory'		=> ($this->mandatory) ? true : false, 
					'rootNodes'		=>	$arrNodes,
					'tl_class'		=> 'clr'
				),
				'load_callback'		=> array
				(
					array('tl_content_contentblocks', 'prepareOrderPageValue'),
				),
				'save_callback'		=> array
				(
					array('tl_content_contentblocks', 'saveOrderPageValue'),
				),
			));
		}
		else
		{
			$this->generateDCA('singleArticle', array
			(
				'inputType' => 'articleTree',
				'label'		=> array($this->label, $this->description),
				'eval'		=> array
				(
					'fieldType'		=>	'radio', 
					'mandatory'		=> ($this->mandatory) ? true : false, 
					'rootNodes'		=>	$arrNodes,
					'tl_class'		=> 'clr'
				),
			));
		}
	}
167302
public function createAction()
	{
		$cntl = $this->createAdmin();

		if( ( $html = $cntl->create() ) == '' ) {
			return $this->setPsrResponse( $cntl->getView()->response() );
		}

		$this->view->assign( 'content', $html );
	}
1350127
public function newAction(Request $request)
    {
        $redirectionClass = $this->getParameter('open_orchestra_model.document.redirection.class');
        /** @var RedirectionInterface $redirection */
        $redirection = new $redirectionClass();
        $redirection->setSiteId($this->get('open_orchestra_backoffice.context_backoffice_manager')->getSiteId());
        $this->denyAccessUnlessGranted(ContributionActionInterface::CREATE, $redirection);

        $form = $this->createForm('oo_redirection', $redirection, array(
            'action'     => $this->generateUrl('open_orchestra_backoffice_redirection_new'),
            'method'     => 'POST',
            'new_button' => true
        ));

        $form->handleRequest($request);
        $message = $this->get('translator')->trans('open_orchestra_backoffice.form.redirection.new.success');

        if ($this->handleForm($form, $message, $redirection)) {
            $this->dispatchEvent(RedirectionEvents::REDIRECTION_CREATE, new RedirectionEvent($redirection));
            $response = new Response(
                '',
                Response::HTTP_CREATED,
                array(
                    'Content-type' => 'text/html; charset=utf-8',
                    'redirectionId' => $redirection->getId(),
                )
            );

            return $response;
        }

        return $this->renderAdminForm($form);
    }
341698
function collect()
    {
        // TODO: Implement collect() method.
        if($this->response)
        {
            return array(
                'contentType' => $this->response->getContentType(),
                'responseCode' => $this->response->getResponseCode(),
                'redirection' => $this->response->getRedirection()
            );
        }
    }
500940
def choose_type(cls, content_type):
        """"""
        return cls.type_cls.SUBDIR if content_type in cls.subdir_types \
            else cls.type_cls.FILE