public function viewContentTypeAction($contentTypeId, $languageCode = null) { $languageCode = $languageCode ?: $this->prioritizedLanguages[0]; $contentType = $this->contentTypeService->loadContentType($contentTypeId); $countQuery = new Query(['filter' => new Query\Criterion\ContentTypeId($contentTypeId), 'limit' => 0]); $contentCount = $this->searchService->findContent($countQuery, [], false)->totalCount; $deleteForm = $this->createForm(new ContentTypeDeleteType(), ['contentTypeId' => $contentTypeId]); return $this->render('eZPlatformUIBundle:ContentType:view_content_type.html.twig', ['language_code' => $languageCode, 'content_type' => $contentType, 'content_count' => $contentCount, 'modifier' => $this->userService->loadUser($contentType->modifierId), 'delete_form' => $deleteForm->createView(), 'can_edit' => $this->isGranted(new Attribute('class', 'update')), 'can_delete' => $this->isGranted(new Attribute('class', 'delete')) && !$this->contentTypeService->isContentTypeUsed($contentType)]); }
/** * Returns true if the given content type $contentType has content instances. * * @since 6.0.1 * * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType * * @return bool */ public function isContentTypeUsed(ContentType $contentType) { return $this->service->isContentTypeUsed($contentType); }