@param Request $request
@param string  $type

@return HasNodeInterface
357059
private function createNewPage(Request $request, $type)
    {
        /* @var HasNodeInterface $newPage */
        $newPage = new $type();

        $title = $request->get('title');
        if (is_string($title) && !empty($title)) {
            $newPage->setTitle($title);
        } else {
            $newPage->setTitle($this->get('translator')->trans('kuma_node.admin.new_page.title.default'));
        }
        $this->em->persist($newPage);
        $this->em->flush();

        return $newPage;
    }
28354
public function createAction(Request $request, $type = 0)
    {
        /** @var ContentManager $manager */
        $manager = $this->get('opifer.content.content_manager');

        if ($type) {
            $contentType = $this->get('opifer.content.content_type_manager')->getRepository()->find($type);
            $content = $this->get('opifer.eav.eav_manager')->initializeEntity($contentType->getSchema());
            $content->setContentType($contentType);
        } else {
            $content = $manager->initialize();
        }

        $form = $this->createForm(ContentType::class, $content);
        $form->handleRequest($request);

        if ($form->isValid()) {
            // Create a new document
            $blockManager = $this->get('opifer.content.block_manager');
            $document = new DocumentBlock();
            $document->setPublish(true);
            $blockManager->save($document);

            $content->setBlock($document);
            $manager->save($content);

            return $this->redirectToRoute('opifer_content_contenteditor_design', [
                'type'    => 'content',
                'id'      => $content->getId(),
                'rootVersion' => 0,
            ]);
        }

        return $this->render($this->getParameter('opifer_content.content_new_view'), [
            'form' => $form->createView(),
        ]);
    }
1074729
protected function getFilters(Request $request)
    {
        $type = $this->getFilterType($request);

        if (!$type) {
            return $request->query->get('search')['value'];
        }

        $filter = new $type();

        $param = $filter->getBlockPrefix();

        return $request->query->get($param);
    }
1314713
public function setNode($class, Request $request, $type = 'store')
    {
        if ( ! $request->has('position')) {
            $model = $class::findOrFail($request->input('parent'));
            $this->makeChildOf($model);
            return;
        }

        $input = $type === 'store' ? 'parent' : 'related';
        switch($request->input('position')) {
            case 'firstChild':
                $model = $class::findOrFail($request->input($input));
                $this->makeFirstChildOf($model);
                break;
            case 'lastChild':
                $model = $class::findOrFail($request->input($input));
                $this->makeChildOf($model);
                break;
            case 'before':
                $model = $class::findOrFail($request->input('related'));
                $this->moveToLeftOf($model);
                break;
            case 'after':
                $model = $class::findOrFail($request->input('related'));
                $this->moveToRightOf($model);
                break;
        }
    }
1241512
public function typesAction(Request $request)
    {
        $component = $request->request->get('component');

        $taskTypes = $this->get('phlexible_task.types');

        $types = [];
        foreach ($taskTypes->all() as $type) {
            /* @var $type TypeInterface */
            if ($component && $type->getComponent() !== $component) {
                continue;
            }

            $types[] = [
                'id' => $type->getName(),
                'name' => $type->getName(),
            ];
        }

        return new JsonResponse(['types' => $types]);
    }
72717
public function dispatch(Request $request)
    {
        /** @var DispatcherInterface $dispatcher */
        $dispatcher = $this->make(DispatcherInterface::class);

        return $dispatcher->dispatch($request);
    }
580410
public function store(Request $request, $type = null)
    {
        return $this->library->upload($request->file('file'), [
            'public_id' => basename(
                $request->file('file')->getClientOriginalName(),
                '.'.$request->file('file')->getClientOriginalExtension()
            ),
        ]);
    }
258192
public function addFromRequest(AttributeType $type, Request $request)
    {
        $key = $this->createAttributeKey();
        $loader = $this->getRequestLoader();
        $loader->load($key, $request);

        $controller = $type->getController();

        $this->entityManager->persist($key);
        $this->entityManager->flush();

        $controller->setAttributeKey($key);
        $settings = $controller->saveKey($request->request->all());
        if (!is_object($settings)) {
            $settings = $controller->getAttributeKeySettings();
        }

        return $this->add($type, $key, $settings);
    }
1040439
public function makeSharedAction(Request $request, $type, $typeId, $ownerId)
    {
        $this->getDoctrine()->getManager()->getFilters()->disable('draftversion');

        /** @var BlockManager $manager */
        $manager = $this->get('opifer.content.block_manager');

        $response = new JsonResponse;
        $id       = (int)$request->request->get('id');

        try {
            /** @var PointerBlock $pointerBlock */
            $pointerBlock = $manager->makeBlockShared($id);

            $response->setStatusCode(200);
            $response->setData(['state' => 'created', 'id' => $pointerBlock->getId()]);
            $response->headers->add(['Location' => $this->generateUrl('opifer_content_api_contenteditor_view_block', ['type' => $type, 'typeId' => $typeId, 'id' => $pointerBlock->getId()])]);
        } catch (\Exception $e) {
            $response->setStatusCode(500, 'Exception');
            $response->setData(['error' => $e->getMessage()]);
        }

        return $response;
    }
118266
protected function modelHasBeenSaved($saved, $type, $request)
    {
        if (!$saved) {
            return response()->json(['message' => 'Failed to '.$type.' resource', 'code' => 422], 422);
        }
        $status = $request->ajax() ? 202 : 200;
        if ($request->ajax()) {
            return response()->json(['message' => 'Successfully '.$type.' resource', 'code' => $status], $status);
        }
        if ($request->has('_redirect')) {
            // Remove the base part of the url, and just grab the tail end of the desired redirect, that way the
            // User can't be redirected away from your website.
            return $this->returnRedirect('Successfully '.$type.' resource', $request);
        }

        return redirect()->back()->with(['message' => 'Successfully '.$type.' resource']);
    }
1069888
public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
	{
		return $this->dispatch(Request::createFromBase($request));
	}
360971
public function preview(Request $request, $contenttypeslug)
    {
        if (!$request->isMethod('POST')) {
            throw new MethodNotAllowedHttpException(['POST'], 'This route only accepts POST requests.');
        }

        $contenttype = $this->getContentType($contenttypeslug);
        $formValues = $request->request->all();

        $storage = $this->storage();
        if ($storage instanceof EntityManager) {
            /** @var EntityManager $storage */
            /** @var Content $content */
            $content = $storage->create($contenttypeslug, $formValues);

            /** @var Collection\Relations $related */
            $related = $storage->createCollection(Relations::class);
            $related->setFromPost($formValues, $content);
            $content->setRelation($related);

            /** @var Collection\Taxonomy $taxonomies */
            $taxonomies = $storage->createCollection(Taxonomy::class);
            $taxonomies->setFromPost($formValues, $content);
            $content->setTaxonomy($taxonomies);

        } else {
            $content = $storage->getContentObject($contenttypeslug, [], false);
            $content->setFromPost($formValues, $contenttype);
        }

        $this->fixBlockFieldsForPreview($content);
        $this->fixHTMLFieldsForPreview($content);

        $liveEditor = $request->get('_live-editor-preview');
        if (!empty($liveEditor)) {
            $jsFile = (new JavaScript('js/ckeditor/ckeditor.js', 'bolt'))
                ->setPriority(1)
                ->setLate(false);
            $cssFile = (new Stylesheet('css/liveeditor.css', 'bolt'))
                ->setPriority(5)
                ->setLate(false);
            $snippet = (new Snippet())
                ->setCallback('<script>window.boltIsEditing = true;</script>')
                ->setLocation(Target::BEFORE_HEAD_JS);

            $this->app['asset.queue.snippet']->add($snippet);
            $this->app['asset.queue.file']->add($jsFile);
            $this->app['asset.queue.file']->add($cssFile);
        }

        // Then, select which template to use, based on our 'cascading templates rules'
        $template = $this->templateChooser()->record($content);

        // Make sure we can also access it as {{ page.title }} for pages, etc. We set these in the global scope,
        // So that they're also available in menu's and templates rendered by extensions.
        $globals = [
            'record'                      => $content,
            $contenttype['singular_slug'] => $content,
        ];

        return $this->render($template, [], $globals);
    }
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()]);
    }
564623
public function types(Request $request, array $types)
    {
        foreach ($types as $type) {
            $field = new $type($request);
            $this->type($field->singularLabel(), $type::$model, $field->fields($request));
        }

        return $this;
    }
1220887
public static function requestHandler($type)
    {
        if (! self::validateRequest($type)) {
            return false;
        }

        App::setCurrentID(self::$config['app']);

        self::loadRemoteComplements();

        switch (self::$config['request']) {
            case 'load-complements':
                self::complementsLoadRequest();
                break;
            case 'change-state':
                self::changeStateRequest();
                break;
            case 'install':
                self::installRequest();
                break;
            case 'update':
                self::installRequest(true);
                break;
            case 'uninstall':
                self::uninstallRequest();
                break;
            default:
                self::$errors[] = [
                    'message' => 'Unknown request: ' . self::$config['request'],
                ];
                echo json_encode(['errors' => self::$errors]);
                break;
        }

        if (empty(App::getOption('development-environment'))) {
            die;
        }
    }
858302
protected function handleRequest(Request $request, $type)
    {
        $this->request = $request;
        $this->requestStack->push($request);

        if (false === $this->booted) {
            $this->boot();

            // Only fire this when handling a request
            $event = new PostBootEvent($this, $this->request, self::MASTER_REQUEST);
            $this->getDispatcher()->dispatch(KernelEvents::BOOT, $event);
        }

        // Attach the current application session to the current request
        $this->request->setSession($this->getSession());

        $event = new InterceptResponseEvent($this, $request, $type);
        $this->getDispatcher()->dispatch(KernelEvents::POSTBOOT, $event);

        if ($event->hasResponse()) {
            return $event->getResponse();
        }

        $event = new FilterRequestEvent($this, $request, $type);
        $this->getDispatcher()->dispatch(KernelEvents::REQUEST, $event);

        // Match the route to a controller
        $matched  = $this->matchRoute($request, $type);
        $resolver = $this->container->get('controller_resolver');

        $controller = $resolver->getController($request, $matched);
        $arguments  = $resolver->getArguments($request, $controller, $matched);

        $event = new FilterControllerEvent($this, $request, $type);
        $event->setController($controller);
        $event->setArguments($arguments);
        $this->getDispatcher()->dispatch(KernelEvents::CONTROLLER, $event);

        // Attempt to get a response from the controller
        $response = call_user_func_array($controller, $arguments);

        if ( ! $response instanceof Response) {
            $message = sprintf('The controller must return a valid Response (%s given).', $this->varToString($response));

            if (null === $response) {
                $message .= ' Did you forget to add a return statement somewhere in your controller?';
            }

            throw new \LogicException($message);
        }

        return $this->filterResponse($response, $request, $type);
    }
863534
public function deleteAction($id, Request $request, $type = null)
    {
        $this->type = $type;

        return parent::deleteAction($id, $request);
    }