@param string $contentTypeIdList
@param Request $request

@return JsonResponse

@throws ExportInProgressException
503509
public function runExportAction($contentTypeIdList, Request $request)
    {
        $response = new JsonResponse();

        if (!$this->authenticator->authenticate()) {
            return $response->setStatusCode(Response::HTTP_UNAUTHORIZED);
        }

        if ($this->fileSystem->isLocked()) {
            $this->logger->warning('Export is running.');
            throw new ExportInProgressException('Export is running');
        }

        $options = $this->parseRequest($request);
        $options['contentTypeIdList'] = $contentTypeIdList;

        $this->exportProcessRunner->run($options);

        return $response->setData([sprintf(
            'Export started at %s',
            date('Y-m-d H:i:s')
        )]);
    }
1321294
public function removeContentTypeTranslation(int $contentTypeId, string $languageCode): Type
    {
        $type = $this->load($contentTypeId, Type::STATUS_DRAFT);

        unset($type->name[$languageCode]);
        unset($type->description[$languageCode]);

        foreach ($type->fieldDefinitions as $fieldDefinition) {
            $this->contentTypeGateway->removeFieldDefinitionTranslation(
                $fieldDefinition->id,
                $languageCode,
                Type::STATUS_DRAFT
            );

            //Refresh FieldDefinition object after removing translation data.
            $fieldDefinition = $this->getFieldDefinition(
                $fieldDefinition->id,
                Type::STATUS_DRAFT
            );
            unset($fieldDefinition->name[$languageCode]);
            unset($fieldDefinition->description[$languageCode]);
            $storageFieldDefinition = new StorageFieldDefinition();
            $this->mapper->toStorageFieldDefinition($fieldDefinition, $storageFieldDefinition);
            $this->contentTypeGateway->updateFieldDefinition(
                $contentTypeId,
                Type::STATUS_DRAFT,
                $fieldDefinition,
                $storageFieldDefinition
            );
        }

        $updateStruct = $this->mapper->createUpdateStructFromType($type);

        return $this->update($type->id, Type::STATUS_DRAFT, $updateStruct);
    }
825679
public function updateAction(Request $request, ContentNode $contentNode, $isSimpleForm = false)
    {
        $em = $this->getDoctrine()->getManager();
        $repository = $this->getDoctrine()->getRepository('MMCmfNodeBundle:Node');

        $rootNode = null;

        if ((int)$request->get('root_node')) {
            $rootNode = $repository->find((int)$request->get('root_node'));
        }

        //check if node need "simple" validation
        if ($isSimpleForm)
            $editForm = $this->createSimpleEditForm($contentNode, $rootNode);
        else
            $editForm = $this->createEditForm($contentNode, $rootNode);

        $editForm->handleRequest($request);

        if ($editForm->isValid()) {
            $em->flush();

            $markup = $this->get('mm_cmf_content.mm_cmf_parse_twig_extension')->cmfParse(
                $this->get('twig'),
                $contentNode
            );
            return new JsonResponse(array(
                    'success' => true,
                    'data' => array(
                        'id' => $contentNode->getId(),
                        'markup' => $markup
                    ))
            );
        }

        return new JsonResponse(array('success' => false));
    }
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(),
        ]);
    }
587289
public function delete($contentTypeId, $status)
    {
        if (Type::STATUS_DEFINED === $status && $this->contentTypeGateway->countInstancesOfType($contentTypeId)) {
            throw new BadStateException(
                '$contentTypeId',
                "ContentType with given id still has content instances and therefore can't be deleted"
            );
        }

        $this->contentTypeGateway->delete($contentTypeId, $status);

        // @todo FIXME: Return true only if deletion happened
        return true;
    }
400474
public function searchAction(Request $request, $contentId)
    {
        $this->denyAccessUnlessGranted('ez:infocollector:read');

        $content = $this->contentService->loadContent($contentId);

        $query = new Query([
            'contentId' => $contentId,
            'searchText' => $request->query->get('searchText'),
        ]);
        $adapter = new InformationCollectionCollectionListSearchAdapter($this->service, $query);
        $pager = $this->getPager($adapter, (int)$request->query->get('page'));

        return $this->render("NetgenInformationCollectionBundle:admin:collection_list.html.twig",
            [
                'objects' => $pager,
                'content' => $content,
            ]
        );
    }
991376
public function loadContentTypeGroupList(Request $request)
    {
        if ($request->query->has('identifier')) {
            $contentTypeGroup = $this->contentTypeService->loadContentTypeGroupByIdentifier(
                $request->query->get('identifier')
            );

            return new Values\TemporaryRedirect(
                $this->router->generate(
                    'ezpublish_rest_loadContentTypeGroup',
                    array(
                        'contentTypeGroupId' => $contentTypeGroup->id,
                    )
                )
            );
        }

        return new Values\ContentTypeGroupList(
            $this->contentTypeService->loadContentTypeGroups(Language::ALL)
        );
    }
1059923
private function getContentTypesNumbers(array $contentTypes): array
    {
        $contentTypesNumbers = array_column($contentTypes, 'id');

        return array_combine($contentTypesNumbers, array_fill_keys($contentTypesNumbers, false));
    }
1288120
public function typeAction($contentDocument, $_format, Request $request)
    {
        if (!$contentDocument || ! $contentDocument instanceof Page) {
            throw new NotFoundHttpException('Content not found');
        }
        if ($this->container->has('profiler')) {
        	$this->container->get('profiler')->disable();
        }
        $isAdminUi = $request->query->get('admin', false) && $this->container->get('security.context')->isGranted('ROLE_ADMIN');

        $data = $params = $this->formatter->format($contentDocument);
		if("html" == $_format) {
	        $params = array(
	            'cmfMainContent' => $contentDocument,
	        	'jsData' => $data,
	        	'settings' => array("currentPath"=>"/","urlBase"=>"/"),
	        	'isAdminUI' => $isAdminUi,
	        	'serializationContext' => $this->getSerializerContext(array('front'))
	        );
		}

        return $this->renderResponse('ApplicationToguApplicationModelsBundle:Default:index.html.twig', $params);
    }
268608
private function getContentItems($contentTypeId, array $options)
    {
        $offset = $options['page'] * $options['pageSize'] - $options['pageSize'];
        $criteria = $this->generateCriteria($contentTypeId, $options);

        $query = new Query();
        $query->query = new Criterion\LogicalAnd($criteria);
        $query->limit = (int)$options['pageSize'];
        $query->offset = $offset;

        return $this->searchService->findContent(
            $query,
            (!empty($options['lang']) ? array('languages' => array($options['lang'])) : array())
        )->searchHits;
    }
828037
public function applyUpdates($contentTypeId, array $actions)
    {
        if (empty($actions)) {
            return;
        }

        foreach ($this->getContentIdsByContentTypeId($contentTypeId) as $contentId) {
            foreach ($actions as $action) {
                $action->apply($contentId);
            }
        }
    }
792161
public function updateContentMetadata($contentId, Request $request)
    {
        $updateStruct = $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type')),
                $request->getContent()
            )
        );

        $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);

        // update section
        if ($updateStruct->sectionId !== null) {
            $section = $this->repository->getSectionService()->loadSection($updateStruct->sectionId);
            $this->repository->getSectionService()->assignSection($contentInfo, $section);
            $updateStruct->sectionId = null;
        }

        // @todo Consider refactoring! ContentService::updateContentMetadata throws the same exception
        // in case the updateStruct is empty and if remoteId already exists. Since REST version of update struct
        // includes section ID in addition to other fields, we cannot throw exception if only sectionId property
        // is set, so we must skip updating content in that case instead of allowing propagation of the exception.
        foreach ($updateStruct as $propertyName => $propertyValue) {
            if ($propertyName !== 'sectionId' && $propertyValue !== null) {
                // update content
                $this->repository->getContentService()->updateContentMetadata($contentInfo, $updateStruct);
                $contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);
                break;
            }
        }

        try {
            $locationInfo = $this->repository->getLocationService()->loadLocation($contentInfo->mainLocationId);
        } catch (NotFoundException $e) {
            $locationInfo = null;
        }

        return new Values\RestContent(
            $contentInfo,
            $locationInfo
        );
    }
309473
public function it_writes_tags_on_rest_content_type_group_list(
        GetResponseForControllerResultEvent $event,
        Request $request,
        ParameterBag $attributes,
         $restValue,
        ContentTypeGroup $contentTypeGroup,
        TagHandler $tagHandler
    ) {
        $request->isMethodCacheable()->willReturn(true);
        $attributes->get('is_rest_request')->willReturn(true);

        $contentTypeGroup->beConstructedWith([['id' => 2]]);
        $restValue->contentTypeGroups = [$contentTypeGroup];
        $event->getControllerResult()->willReturn($restValue);

        $tagHandler->addTags(['type-group-2'])->shouldBecalled();
        $event->setControllerResult(new TypeToken(CachedValue::class))->shouldBecalled();

        $this->tagUIRestResult($event);
    }
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)));
    }
489646
private function getRecords($contentTypeName, MutableBag $exportData, MutableBag $responseBag)
    {
        /** @var ContentRepository $repo */
        $repo = $this->em->getRepository($contentTypeName);
        $metadata = $repo->getClassMetadata();
        // Get all the records for the ContentType
        $entities = $this->query->getContent($contentTypeName);
        $contentTypeBag = $exportData->get($contentTypeName);

        foreach ($entities as $key => $entity) {
            $this->addRecord($contentTypeBag, $metadata, $entity);
        }

        /** @var MutableBag $success */
        $success = $responseBag->get('success');
        $success->add(sprintf('%s: %s records', $contentTypeName, count($entities)));
    }
246618
public function getContentIdsByContentTypeId($contentTypeId)
    {
        $query = $this->dbHandler->createSelectQuery();
        $query
            ->select($this->dbHandler->quoteColumn('id'))
            ->from($this->dbHandler->quoteTable('ezcontentobject'))
            ->where(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('contentclass_id'),
                    $query->bindValue($contentTypeId, null, PDO::PARAM_INT)
                )
            );

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetchAll(PDO::FETCH_COLUMN);
    }
1125167
public function getChangeLogEntryQuery($contentType, $contentId, $id, $cmpOp)
    {
        $alias = $this->getAlias();
        $contentTypeTableName = $this->em->getRepository($contentType)->getTableName();

        // Build base query
        $qb = $this->createQueryBuilder();
        $qb->select("$alias.*")
            ->leftJoin($alias, $contentTypeTableName, 'content', "content.id = $alias.contentid")
            ->where("$alias.id $cmpOp :logid")
            ->andWhere("$alias.contentid = :contentid")
            ->andWhere('contenttype = :contenttype')
            ->setParameters([
                ':logid'       => $id,
                ':contentid'   => $contentId,
                ':contenttype' => $contentType,
            ]);

        // Set ORDER BY
        if ($cmpOp === '<') {
            $qb->orderBy('date', 'DESC');
        } elseif ($cmpOp === '>') {
            $qb->orderBy('date');
        }

        return $qb;
    }