Code Duplication    Length = 17-19 lines in 2 locations

eZ/Publish/Core/Repository/URLWildcardService.php 1 location

@@ 140-156 (lines=17) @@
137
     *
138
     * @param \eZ\Publish\API\Repository\Values\Content\UrlWildcard $urlWildcard the url wildcard to remove
139
     */
140
    public function remove(URLWildcard $urlWildcard)
141
    {
142
        if (!$this->repository->canUser('content', 'urltranslator', $urlWildcard)) {
143
            throw new UnauthorizedException('content', 'urltranslator');
144
        }
145
146
        $this->repository->beginTransaction();
147
        try {
148
            $this->urlWildcardHandler->remove(
149
                $urlWildcard->id
150
            );
151
            $this->repository->commit();
152
        } catch (Exception $e) {
153
            $this->repository->rollback();
154
            throw $e;
155
        }
156
    }
157
158
    /**
159
     * Loads a url wild card.

eZ/Publish/Core/Repository/TrashService.php 1 location

@@ 232-250 (lines=19) @@
229
     *
230
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to empty the trash
231
     */
232
    public function emptyTrash()
233
    {
234
        // Will throw if you have Role assignment limitation where you have content/cleantrash permission.
235
        // This is by design and means you can only delete one and one trash item, or you'll need to change how
236
        // permissions is assigned to be on separate role with no Role assignment limitation.
237
        if ($this->repository->hasAccess('content', 'cleantrash') !== true) {
238
            throw new UnauthorizedException('content', 'cleantrash');
239
        }
240
241
        $this->repository->beginTransaction();
242
        try {
243
            // Persistence layer takes care of deleting content objects
244
            $this->persistenceHandler->trashHandler()->emptyTrash();
245
            $this->repository->commit();
246
        } catch (Exception $e) {
247
            $this->repository->rollback();
248
            throw $e;
249
        }
250
    }
251
252
    /**
253
     * Deletes a trash item.