@param Request $request
@param ContentNode $parent_node
@param $contentNode_type

@return \Symfony\Component\HttpFoundation\Response
189193
public function simpleNewChildAction(Request $request, ContentNode $parent_node, $contentNode_type)
    {
        return $this->newChildAction($request, $parent_node, $contentNode_type, true);
    }
780739
public function validateCanHaveParentOfType()
    {
        if (is_null($this->parent))
        {
            return;
        }

        $allowedNodeTypes = json_decode($this->parent->getNodeType()->allowed_children);

        if (empty($allowedNodeTypes) || in_array($this->getNodeTypeKey(), $allowedNodeTypes))
        {
            return;
        }

        throw new InvalidParentNodeTypeException('Parent does not allow node type of name "' . $this->getNodeTypeName() . '" as child.');
    }
754571
public static HttpResponse request(HttpRequest request, String body, String contentType) {
        return request.contentType(contentType).body(body).contentLength(body.length()).execute();
    }
471190
protected function createResponse($content, $contentType)
    {
        $resp = new HttpResponse();

        $resp->setStatusCode(200)
             ->setContent($content);
        $resp->getHeaders()->addHeaders(array(
            'Content-Length'    => strlen($content),
            'Content-Type'      => $contentType
        ));
        return $resp;
    }
1223760
public function cgetAction(Request $request, $parentId)
    {
        if ($request->get('flat') == 'true') {
            /** @var RestHelperInterface $restHelper */
            $restHelper = $this->get('sulu_core.doctrine_rest_helper');

            /** @var DoctrineListBuilderFactory $factory */
            $factory = $this->get('sulu_core.doctrine_list_builder_factory');

            $listBuilder = $factory->create(self::$entityName);

            $fieldDescriptors = $this->getProductVariantManager()->retrieveFieldDescriptors($this->getLocale($request));

            $restHelper->initializeListBuilder(
                $listBuilder,
                $fieldDescriptors
            );

            $listBuilder->where($fieldDescriptors['parent'], $parentId);
            $listBuilder->addGroupBy($fieldDescriptors['id']);

            // Only add group by id if categories are processed.
            $fieldsParam = $request->get('fields');
            $fields = explode(',', $fieldsParam);
            if (isset($filter['categories'])
                || !$fieldsParam
                || array_search('categories', $fields) !== false
            ) {
                $listBuilder->addGroupBy($fieldDescriptors['id']);
            }

            $list = new ListRepresentation(
                $listBuilder->execute(),
                self::$entityKey,
                'get_product_variants',
                array_merge(
                    $request->query->all(),
                    [
                        'parentId' => $parentId,
                    ]
                ),
                $listBuilder->getCurrentPage(),
                $listBuilder->getLimit(),
                $listBuilder->count()
            );
        } else {
            $list = new CollectionRepresentation(
                $this->getProductManager()->findAllByLocale($this->getLocale($request)),
                self::$entityKey
            );
        }

        $view = $this->view($list, 200);

        return $this->handleView($view);
    }
646505
public function createLocation($contentId, Request $request)
    {
        $locationCreateStruct = $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type')),
                $request->getContent()
            )
        );

        $contentInfo = $this->contentService->loadContentInfo($contentId);

        try {
            $createdLocation = $this->locationService->createLocation($contentInfo, $locationCreateStruct);
        } catch (InvalidArgumentException $e) {
            throw new ForbiddenException($e->getMessage());
        }

        return new Values\CreatedLocation(array('restLocation' => new Values\RestLocation($createdLocation, 0)));
    }
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;
        }
    }
1269002
private function isAcceptableContentType(ServerRequestInterface $request, string $contentType): bool
    {
        $acceptHeader = $request->getHeaderLine('Accept');

        if (strpos($acceptHeader, $contentType) !== false) {
            return true;
        }
        // special case for 'xxx+json' and 'xxx+xml' example : 'application/xhtml+xml'
        if (preg_match('/\+(json|xml)/', $acceptHeader, $matches)) {
            $mediaType = 'application/' . $matches[1];
            if ($mediaType === $contentType) {
                return true;
            }
        }
        // special case when accepting all subtypes of the mime 'mime/*'
        if (strpos($acceptHeader, strtok($contentType, '/') . '/*') !== false) {
            return true;
        }
        // special case when accepting all mimes '*/*'
        if (strpos($acceptHeader, '*/*') !== false) {
            return true;
        }

        return false;
    }
471360
public static function create(Request $request)
	{

		if ($request->hasParameter('classUri')) {
			$classUri = tao_helpers_Uri::decode($request->getParameter('classUri'));
			$class = new core_kernel_classes_Class($classUri);
			$hideNode = true;
		} elseif ($request->hasParameter('rootNode')) {
			$class = new core_kernel_classes_Class($request->getParameter('rootNode'));
			$hideNode = false;
		} else {
			throw new common_Exception('Missing node information for ' . __FUNCTION__);
		}

		$openNodes = array($class->getUri());
		$openNodesParameter = $request->getParameter('openNodes');
		$openParentNodesParameter = $request->getParameter('openParentNodes');

		if ($request->hasParameter('openNodes') && is_array($openNodesParameter)) {
			$openNodes = array_merge($openNodes, $openNodesParameter);
		} else if ($request->hasParameter('openParentNodes') && is_array($openParentNodesParameter)) {
			$childNodes = $openParentNodesParameter;
			$openNodes = TreeHelper::getNodesToOpen($childNodes, $class);
		}

		$limit = $request->hasParameter('limit') ? $request->getParameter('limit') : self::DEFAULT_LIMIT;
		$offset = $request->hasParameter('offset') ? $request->getParameter('offset') : 0;
		$showInstance = $request->hasParameter('hideInstances') ? !$request->getParameter('hideInstances') : true;
		$orderProp = $request->hasParameter('order') ? $request->getParameter('order') : OntologyRdfs::RDFS_LABEL;
		$orderDir = $request->hasParameter('orderdir') ? $request->getParameter('orderdir') : self::DEFAULT_ORDERDIR;

        $filterProperties = [];
		if ($request->hasParameter('filterProperties')) {
		    $filterProperties = $request->getParameter('filterProperties');
		    if (!is_array($filterProperties)) {
		        $filterProperties = [];
            }
        }

		return new self(
		    $class,
            $limit,
            $offset,
            $showInstance,
            $hideNode,
            $openNodes,
            [],
            [
                'order' => [
                    $orderProp => $orderDir
                ]
            ],
            $filterProperties
        );
	}
419046
public function post($url, $data, $contentType = 'application/json')
    {
        $uri = $this->buildUrl($url);

        $request = $this->requestFactory->createRequest('POST', $uri);
        if (!is_null($contentType)) {
            $request = $request->withHeader('Content-Type', $contentType);
            $request = $request->withHeader('Accept', $contentType);
        }
        $request = $request->withBody(stream_for($data));

        $response = $this->request($request);

        return strval($response->getBody());
    }
704107
public function create(Request $request)
    {
        try {
            $parentId = $request->input('parentId');
            $contentTypeId = $request->input('contentTypeId');
            $content = $this->content->createStub($parentId, $contentTypeId);

            if ($request->input('folder') == true) {
                $content->fillDefaults()->fill([
                    'name'           => $request->input('name'),
                    'is_sluggable'   => false,
                    'is_folder'      => true,
                    'is_publishable' => false,
                ])->save();

                if ($parentId) {
                    return redirect()->route('soda.content.show', $parentId)->with('success', trans('soda::messages.created', ['object' => trans('soda::terminology.content')]));
                }

                return redirect()->route('soda.content.index')->with('success', trans('soda::messages.created', ['object' => trans('soda::terminology.content')]));
            }
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.create', ['object' => trans('soda::terminology.content')]));
        }

        if ($parentId) {
            $contentFolder = $this->content->findById($parentId);
            $this->buildBreadcrumbTree($contentFolder, $contentFolder->real_depth > 0);
        }

        if ($content->type) {
            app('soda.interface')->setHeading('New '.$content->type->name);
        } else {
            app('soda.interface')->setHeading('New '.ucfirst(trans('soda::terminology.content')));
        }

        return view($content->edit_action, compact('content'));
    }
964898
public function simpleUpdateAction(Request $request, ContentNode $contentNode)
    {
        return $this->updateAction($request, $contentNode, true);
    }
1165357
public function loadContentTypeDraftFieldDefinition($contentTypeId, $fieldDefinitionId, Request $request)
    {
        $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId);

        foreach ($contentTypeDraft->getFieldDefinitions() as $fieldDefinition) {
            if ($fieldDefinition->id == $fieldDefinitionId) {
                return new Values\RestFieldDefinition(
                    $contentTypeDraft,
                    $fieldDefinition
                );
            }
        }

        throw new Exceptions\NotFoundException("Field definition not found: '{$request->getPathInfo()}'.");
    }
473386
public function addChildAction(ServerRequestInterface $request, Tree $tree): ResponseInterface
    {
        $xref = $request->get('xref', '');

        $family = Family::getInstance($xref, $tree);

        Auth::checkFamilyAccess($family, true);

        $PEDI      = $request->get('PEDI', '');
        $keep_chan = (bool) $request->get('keep_chan');

        $this->glevels = $request->get('glevels', []);
        $this->tag     = $request->get('tag', []);
        $this->text    = $request->get('text', []);
        $this->islink  = $request->get('islink', []);

        $this->splitSource();
        $gedrec = '0 @@ INDI';
        $gedrec .= $this->addNewName($request, $tree);
        $gedrec .= $this->addNewSex($request);
        if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) {
            foreach ($matches[1] as $match) {
                $gedrec .= $this->addNewFact($request, $tree, $match);
            }
        }
        $gedrec .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $xref);
        if ((bool) $request->get('SOUR_INDI')) {
            $gedrec = $this->handleUpdates($gedrec);
        } else {
            $gedrec = $this->updateRest($gedrec);
        }

        // Create the new child
        $new_child = $tree->createIndividual($gedrec);

        // Insert new child at the right place
        $done = false;
        foreach ($family->facts(['CHIL']) as $fact) {
            $old_child = $fact->target();
            if ($old_child instanceof Individual && Date::compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) {
                // Insert before this child
                $family->updateFact($fact->id(), '1 CHIL @' . $new_child->xref() . "@\n" . $fact->gedcom(), !$keep_chan);
                $done = true;
                break;
            }
        }
        if (!$done) {
            // Append child at end
            $family->createFact('1 CHIL @' . $new_child->xref() . '@', !$keep_chan);
        }

        if ($request->get('goto') === 'new') {
            return redirect($new_child->url());
        }

        return redirect($family->url());
    }
500839
public function attach(Request $request, $contentTypeId)
    {
        try {
            $this->content->attach($contentTypeId, $request->input('fieldable_id'), $request->only('show_in_table'));
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.attach', ['object' => trans('soda::terminology.field')]));
        }

        return redirect()->route('soda.content-types.edit', [$contentTypeId, 'tab' => 'fields'])->with('success', trans('soda::messages.attached', ['object' => trans('soda::terminology.field')]));
    }
274864
public function updateAction(Request $request, ContentTypeGroup $group): Response
    {
        $this->denyAccessUnlessGranted(new Attribute('class', 'update'));
        $form = $this->formFactory->updateContentTypeGroup(
            new ContentTypeGroupUpdateData($group)
        );
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $result = $this->submitHandler->handle($form, function (ContentTypeGroupUpdateData $data) {
                $group = $data->getContentTypeGroup();
                $updateStruct = $this->contentTypeService->newContentTypeGroupUpdateStruct();
                $updateStruct->identifier = $data->getIdentifier();

                $this->contentTypeService->updateContentTypeGroup($group, $updateStruct);

                $this->notificationHandler->success(
                    $this->translator->trans(
                        /** @Desc("Content type group '%name%' updated.") */
                        'content_type_group.update.success',
                        ['%name%' => $group->identifier],
                        'content_type'
                    )
                );

                return new RedirectResponse($this->generateUrl('ezplatform.content_type_group.view', [
                    'contentTypeGroupId' => $group->id,
                ]));
            });

            if ($result instanceof Response) {
                return $result;
            }
        }

        return $this->render('@ezdesign/admin/content_type_group/edit.html.twig', [
            'content_type_group' => $group,
            'form' => $form->createView(),
        ]);
    }
864528
public function createSimpleEditForm(ContentNode $contentNode, Node $rootNode = null)
    {
        $contentNodeClassName = get_class($contentNode);

        $contentNodeParser = $this->get('mm_cmf_content.content_parser');

        $simpleFormData = $contentNodeParser->getSimpleForm($contentNodeClassName);
        //set FormType
        if (isset($simpleFormData['type']) && class_exists($simpleFormData['type'])) {
            $simpleFormType = $simpleFormData['type'];
        } else
            $simpleFormType = ContentNodeType::class;


        //get fields to hide
        $hiddenFields = $contentNodeParser->getHiddenFields($contentNodeClassName);

        $templateVars = array(
            'hiddenFields' => $hiddenFields,
            'action' => $this->get('router')->generate('mm_cmf_content_node_simple_update', array(
                'id' => $contentNode->getId()
            ))
        );

        if ($rootNode)
            $templateVars['root_node'] = $rootNode;

        return $this->createForm(
            $simpleFormType,
            $contentNode,
            $templateVars
        );
    }