eZ\Publish\Core\SignalSlot\Repository::sudo PHP Метод

sudo() публичный Метод

The closure sandbox will do a catch all on exceptions and rethrow after re-setting the sudo flag. Example use: $location = $repository->sudo( function ( Repository $repo ) use ( $locationId ) { return $repo->getLocationService()->loadLocation( $locationId ) } );
public sudo ( Closure $callback ) : mixed
$callback Closure
Результат mixed
    public function sudo(\Closure $callback)
    {
        return $this->repository->sudo($callback, $this);
    }

Usage Example

 /**
  * Returns ContentType identifier based on $contentId.
  *
  * @param int|mixed $contentId
  *
  * @return string
  */
 private function getContentTypeIdentifier($contentId)
 {
     $contentTypeService = $this->repository->getContentTypeService();
     $contentService = $this->repository->getContentService();
     $contentType = $this->repository->sudo(function () use($contentId, $contentTypeService, $contentService) {
         $contentType = $contentTypeService->loadContentType($contentService->loadContent($contentId)->contentInfo->contentTypeId);
         return $contentType;
     });
     return $contentType->identifier;
 }