Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Core/SignalSlot/TrashService.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\SignalSlot;
8
9 use eZ\Publish\API\Repository\TrashService as TrashServiceInterface;
10 use eZ\Publish\API\Repository\Values\Content\TrashItem;
11 use eZ\Publish\API\Repository\Values\Content\Location;
12 use eZ\Publish\API\Repository\Values\Content\Query;
13 use eZ\Publish\Core\SignalSlot\Signal\TrashService\TrashSignal;
14 use eZ\Publish\Core\SignalSlot\Signal\TrashService\RecoverSignal;
15 use eZ\Publish\Core\SignalSlot\Signal\TrashService\EmptyTrashSignal;
16 use eZ\Publish\Core\SignalSlot\Signal\TrashService\DeleteTrashItemSignal;
17
21 class TrashService implements TrashServiceInterface
22 {
28 protected $service;
29
35 protected $signalDispatcher;
36
46 public function __construct(TrashServiceInterface $service, SignalDispatcher $signalDispatcher)
47 {
48 $this->service = $service;
49 $this->signalDispatcher = $signalDispatcher;
50 }
51
64 public function loadTrashItem($trashItemId)
65 {
66 return $this->service->loadTrashItem($trashItemId);
67 }
68
81 public function trash(Location $location)
82 {
83 $returnValue = $this->service->trash($location);
84 $this->signalDispatcher->emit(
85 new TrashSignal(
86 [
87 'locationId' => $location->id,
88 'parentLocationId' => $location->parentLocationId,
89 'contentId' => $location->contentId,
90 'contentTrashed' => $returnValue instanceof TrashItem,
91 ]
92 )
93 );
94
95 return $returnValue;
96 }
97
110 public function recover(TrashItem $trashItem, Location $newParentLocation = null)
111 {
112 $newLocation = $this->service->recover($trashItem, $newParentLocation);
113 $this->signalDispatcher->emit(
114 new RecoverSignal(
115 [
116 'trashItemId' => $trashItem->id,
117 'contentId' => $trashItem->contentId,
118 'newParentLocationId' => $newLocation->parentLocationId,
119 'newLocationId' => $newLocation->id,
120 ]
121 )
122 );
123
124 return $newLocation;
125 }
126
135 public function emptyTrash()
136 {
137 $returnValue = $this->service->emptyTrash();
138
139 $signal = new EmptyTrashSignal();
140 $signal->trashItemDeleteResultList = $returnValue;
141
142 $this->signalDispatcher->emit($signal);
143
144 return $returnValue;
145 }
146
156 public function deleteTrashItem(TrashItem $trashItem)
157 {
158 $returnValue = $this->service->deleteTrashItem($trashItem);
159 $this->signalDispatcher->emit(
160 new DeleteTrashItemSignal(
161 [
162 'trashItemId' => $trashItem->id,
163 'trashItemDeleteResult' => $returnValue,
164 ]
165 )
166 );
167
168 return $returnValue;
169 }
170
180 public function findTrashItems(Query $query)
181 {
182 return $this->service->findTrashItems($query);
183 }
184 }
eZ\Publish\API\Repository\Values\Content\Location
Definition: API/Repository/Values/Content/Location.php:32
eZ\Publish\API\Repository\Values\Content\Query
This class is used to perform a Content query.
Definition: API/Repository/Values/Content/Query.php:15
eZ\Publish\API\Repository\Values\Content\TrashItem
this class represents a trash item, which is actually a trashed location.
Definition: API/Repository/Values/Content/TrashItem.php:13
eZ\Publish\Core\SignalSlot\SignalDispatcher
Dispatches Signals to their assigned Slots.
Definition: SignalDispatcher.php:20
eZ\Publish\Core\SignalSlot\Signal\TrashService\DeleteTrashItemSignal
DeleteTrashItemSignal class.
Definition: DeleteTrashItemSignal.php:15
eZ\Publish\Core\SignalSlot\Signal\TrashService\EmptyTrashSignal
EmptyTrashSignal class.
Definition: EmptyTrashSignal.php:15
eZ\Publish\Core\SignalSlot\Signal\TrashService\RecoverSignal
RecoverSignal class.
Definition: RecoverSignal.php:15
eZ\Publish\Core\SignalSlot\Signal\TrashService\TrashSignal
TrashSignal class.
Definition: TrashSignal.php:15
eZ\Publish\Core\SignalSlot\TrashService
TrashService class.
Definition: Core/SignalSlot/TrashService.php:22
eZ\Publish\Core\SignalSlot\TrashService\emptyTrash
emptyTrash()
Empties trash.
Definition: Core/SignalSlot/TrashService.php:135
eZ\Publish\Core\SignalSlot\TrashService\findTrashItems
findTrashItems(Query $query)
Returns a collection of Trashed locations contained in the trash, which are readable by the current u...
Definition: Core/SignalSlot/TrashService.php:180
eZ\Publish\Core\SignalSlot\TrashService\$service
$service
Definition: Core/SignalSlot/TrashService.php:28
eZ\Publish\Core\SignalSlot\TrashService\trash
trash(Location $location)
Sends $location and all its children to trash and returns the corresponding trash item.
Definition: Core/SignalSlot/TrashService.php:81
eZ\Publish\Core\SignalSlot\TrashService\$signalDispatcher
$signalDispatcher
Definition: Core/SignalSlot/TrashService.php:35
eZ\Publish\Core\SignalSlot\TrashService\recover
recover(TrashItem $trashItem, Location $newParentLocation=null)
Recovers the $trashedLocation at its original place if possible.
Definition: Core/SignalSlot/TrashService.php:110
eZ\Publish\Core\SignalSlot\TrashService\deleteTrashItem
deleteTrashItem(TrashItem $trashItem)
Deletes a trash item.
Definition: Core/SignalSlot/TrashService.php:156
eZ\Publish\Core\SignalSlot\TrashService\loadTrashItem
loadTrashItem($trashItemId)
Loads a trashed location object from its $id.
Definition: Core/SignalSlot/TrashService.php:64
eZ\Publish\Core\SignalSlot\TrashService\__construct
__construct(TrashServiceInterface $service, SignalDispatcher $signalDispatcher)
Constructor.
Definition: Core/SignalSlot/TrashService.php:46
eZ\Publish\API\Repository\TrashService
Trash service, used for managing trashed content.
Definition: API/Repository/TrashService.php:17
eZ\Publish\Core\SignalSlot
Definition: Core/SignalSlot/BookmarkService.php:9
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.