eZ\Bundle\EzPublishCoreBundle\Features\Context\ContentTypeContext::loadContentTypeByIdentifier PHP Method

loadContentTypeByIdentifier() protected method

Load and return a content type by its identifier.
protected loadContentTypeByIdentifier ( string $identifier, boolean $throwIfNotFound = true ) : eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup | null
$identifier string content type identifier
$throwIfNotFound boolean if true, throws an exception if it is not found.
return eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup | null
    protected function loadContentTypeByIdentifier($identifier, $throwIfNotFound = true)
    {
        $contentType = null;
        try {
            $contentType = $this->contentTypeService->loadContentTypeByIdentifier($identifier);
        } catch (ApiExceptions\NotFoundException $e) {
            $notFoundException = $e;
        }
        if (!$contentType && $throwIfNotFound) {
            throw $notFoundException;
        }
        return $contentType;
    }