eZ\Publish\Core\SignalSlot\Repository::getContentService PHP Method

getContentService() public method

Get service object to perform operations on Content objects and it's aggregate members.
public getContentService ( ) : eZ\Publish\API\Repository\ContentService
return eZ\Publish\API\Repository\ContentService
    public function getContentService()
    {
        if ($this->contentService !== null) {
            return $this->contentService;
        }
        $this->contentService = new ContentService($this->repository->getContentService(), $this->signalDispatcher);
        return $this->contentService;
    }

Usage Example

 /**
  * Gets ContentType ID based on $contentId.
  *
  * @param mixed $contentId
  *
  * @return int|null
  */
 protected function getContentTypeId($contentId)
 {
     $contentService = $this->repository->getContentService();
     $contentTypeId = null;
     try {
         $contentTypeId = $contentService->loadContentInfo($contentId)->contentTypeId;
     } catch (Exception $e) {
     }
     return $contentTypeId;
 }