diff --git a/bundle/API/Repository/TagsService.php b/bundle/API/Repository/TagsService.php index 90706f05..d7baaeb1 100644 --- a/bundle/API/Repository/TagsService.php +++ b/bundle/API/Repository/TagsService.php @@ -6,6 +6,7 @@ use Netgen\TagsBundle\API\Repository\Values\Tags\Tag; use Netgen\TagsBundle\API\Repository\Values\Tags\TagCreateStruct; use Netgen\TagsBundle\API\Repository\Values\Tags\TagUpdateStruct; +use Closure; interface TagsService { @@ -314,4 +315,27 @@ public function newSynonymCreateStruct($mainTagId, $mainLanguageCode); * @return \Netgen\TagsBundle\API\Repository\Values\Tags\TagUpdateStruct */ public function newTagUpdateStruct(); + + /** + * Allows tags API execution to be performed with full access sand-boxed. + * + * The closure sandbox will do a catch all on exceptions and rethrow after + * re-setting the sudo flag. + * + * Example use: + * $tag = $tagsService->sudo( + * function (TagsService $tagsService) use ($tagId) { + * return $tagsService->loadTag($tagId); + * } + * ); + * + * @param \Closure $callback + * @param \Netgen\TagsBundle\API\Repository\TagsService $outerTagsService + * + * @throws \RuntimeException Thrown on recursive sudo() use + * @throws \Exception Re throws exceptions thrown inside $callback + * + * @return mixed + */ + public function sudo(Closure $callback, TagsService $outerTagsService = null); } diff --git a/bundle/Core/Repository/TagsService.php b/bundle/Core/Repository/TagsService.php index 8751aa31..d1fedf4a 100644 --- a/bundle/Core/Repository/TagsService.php +++ b/bundle/Core/Repository/TagsService.php @@ -1011,27 +1011,6 @@ public function newTagUpdateStruct() return new TagUpdateStruct(); } - /** - * Allows tags API execution to be performed with full access sand-boxed. - * - * The closure sandbox will do a catch all on exceptions and rethrow after - * re-setting the sudo flag. - * - * Example use: - * $tag = $tagsService->sudo( - * function (TagsService $tagsService) use ($tagId) { - * return $tagsService->loadTag($tagId); - * } - * ); - * - * @param \Closure $callback - * @param \Netgen\TagsBundle\API\Repository\TagsService $outerTagsService - * - * @throws \RuntimeException Thrown on recursive sudo() use - * @throws \Exception Re throws exceptions thrown inside $callback - * - * @return mixed - */ public function sudo(Closure $callback, TagsServiceInterface $outerTagsService = null) { ++$this->sudoNestingLevel; diff --git a/bundle/Core/SignalSlot/TagsService.php b/bundle/Core/SignalSlot/TagsService.php index 46fcde07..94fd6056 100644 --- a/bundle/Core/SignalSlot/TagsService.php +++ b/bundle/Core/SignalSlot/TagsService.php @@ -506,29 +506,8 @@ public function newTagUpdateStruct() return $this->service->newTagUpdateStruct(); } - /** - * Allows tags API execution to be performed with full access sand-boxed. - * - * The closure sandbox will do a catch all on exceptions and rethrow after - * re-setting the sudo flag. - * - * Example use: - * $tag = $tagsService->sudo( - * function ( TagsService $tagsService ) use ( $tagId ) - * { - * return $tagsService->loadTag( $tagId ); - * } - * ); - * - * @param \Closure $callback - * - * @throws \RuntimeException Thrown on recursive sudo() use - * @throws \Exception Re throws exceptions thrown inside $callback - * - * @return mixed - */ - public function sudo(Closure $callback) + public function sudo(Closure $callback, TagsServiceInterface $outerTagsService = null) { - return $this->service->sudo($callback, $this); + return $this->service->sudo($callback, $outerTagsService !== null ? $outerTagsService : $this); } }