Completed
Push — ezp28048_trash_move_when_cant_... ( 55080c...c86600 )
by
unknown
13:03
created

TrashService::getDateTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the eZ\Publish\Core\Repository\TrashService class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Repository;
10
11
use eZ\Publish\API\Repository\TrashService as TrashServiceInterface;
12
use eZ\Publish\API\Repository\Repository as RepositoryInterface;
13
use eZ\Publish\SPI\Persistence\Handler;
14
use eZ\Publish\API\Repository\Values\Content\Location;
15
use eZ\Publish\Core\Repository\Values\Content\TrashItem;
16
use eZ\Publish\API\Repository\Values\Content\TrashItem as APITrashItem;
17
use eZ\Publish\API\Repository\Values\Content\Query;
18
use eZ\Publish\SPI\Persistence\Content\Location\Trashed;
19
use eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue;
20
use eZ\Publish\Core\Base\Exceptions\UnauthorizedException;
21
use eZ\Publish\API\Repository\Values\Content\SearchResult;
22
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
23
use eZ\Publish\API\Repository\Values\Content\Query\SortClause;
24
use DateTime;
25
use Exception;
26
27
/**
28
 * Trash service, used for managing trashed content.
29
 */
30
class TrashService implements TrashServiceInterface
31
{
32
    /**
33
     * @var \eZ\Publish\API\Repository\Repository|\eZ\Publish\Core\Repository\Repository
34
     */
35
    protected $repository;
36
37
    /**
38
     * @var \eZ\Publish\SPI\Persistence\Handler
39
     */
40
    protected $persistenceHandler;
41
42
    /**
43
     * @var array
44
     */
45
    protected $settings;
46
47
    /**
48
     * @var \eZ\Publish\Core\Repository\Helper\NameSchemaService
49
     */
50
    protected $nameSchemaService;
51
52
    /**
53
     * Setups service with reference to repository object that created it & corresponding handler.
54
     *
55
     * @param \eZ\Publish\API\Repository\Repository $repository
56
     * @param \eZ\Publish\SPI\Persistence\Handler $handler
57
     * @param \eZ\Publish\Core\Repository\Helper\NameSchemaService $nameSchemaService
58
     * @param array $settings
59
     */
60
    public function __construct(
61
        RepositoryInterface $repository,
62
        Handler $handler,
63
        Helper\NameSchemaService $nameSchemaService,
64
        array $settings = array()
65
    ) {
66
        $this->repository = $repository;
67
        $this->persistenceHandler = $handler;
68
        $this->nameSchemaService = $nameSchemaService;
69
        // Union makes sure default settings are ignored if provided in argument
70
        $this->settings = $settings + array(
71
            //'defaultSetting' => array(),
72
        );
73
    }
74
75
    /**
76
     * Loads a trashed location object from its $id.
77
     *
78
     * Note that $id is identical to original location, which has been previously trashed
79
     *
80
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the trashed location
81
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the location with the given id does not exist
82
     *
83
     * @param mixed $trashItemId
84
     *
85
     * @return \eZ\Publish\API\Repository\Values\Content\TrashItem
86
     */
87
    public function loadTrashItem($trashItemId)
88
    {
89
        if ($this->repository->hasAccess('content', 'restore') !== true) {
90
            throw new UnauthorizedException('content', 'restore');
91
        }
92
93
        $spiTrashItem = $this->persistenceHandler->trashHandler()->loadTrashItem($trashItemId);
94
        $trash = $this->buildDomainTrashItemObject($spiTrashItem);
95
        if (!$this->repository->canUser('content', 'read', $trash->getContentInfo())) {
96
            throw new UnauthorizedException('content', 'read');
97
        }
98
99
        return $trash;
100
    }
101
102
    /**
103
     * Sends $location and all its children to trash and returns the corresponding trash item.
104
     *
105
     * Content is left untouched.
106
     *
107
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to trash the given location
108
     *
109
     * @param \eZ\Publish\API\Repository\Values\Content\Location $location
110
     *
111
     * @return null|\eZ\Publish\API\Repository\Values\Content\TrashItem null if location was deleted, otherwise TrashItem
112
     */
113
    public function trash(Location $location)
114
    {
115
        if (!is_numeric($location->id)) {
116
            throw new InvalidArgumentValue('id', $location->id, 'Location');
117
        }
118
119
        if ($this->repository->canUser('content', 'manage_locations', $location->getContentInfo(), $location) !== true) {
120
            throw new UnauthorizedException('content', 'manage_locations');
121
        }
122
123
        $this->repository->beginTransaction();
124
        try {
125
            $spiTrashItem = $this->persistenceHandler->trashHandler()->trashSubtree($location->id);
126
            $this->persistenceHandler->urlAliasHandler()->locationDeleted($location->id);
127
            $this->repository->commit();
128
        } catch (Exception $e) {
129
            $this->repository->rollback();
130
            throw $e;
131
        }
132
133
        // Use sudo as we want a trash item regardless of user access to the trash.
134
        try {
135
            return isset($spiTrashItem)
136
                ? $this->repository->sudo(
137
                    function () use ($spiTrashItem) {
138
                        return $this->buildDomainTrashItemObject($spiTrashItem);
139
                    }
140
                )
141
                : null;
142
        } catch (Exception $e) {
143
            return null;
144
        }
145
    }
146
147
    /**
148
     * Recovers the $trashedLocation at its original place if possible.
149
     *
150
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to recover the trash item at the parent location location
151
     *
152
     * If $newParentLocation is provided, $trashedLocation will be restored under it.
153
     *
154
     * @param \eZ\Publish\API\Repository\Values\Content\TrashItem $trashItem
155
     * @param \eZ\Publish\API\Repository\Values\Content\Location $newParentLocation
156
     *
157
     * @return \eZ\Publish\API\Repository\Values\Content\Location the newly created or recovered location
158
     */
159
    public function recover(APITrashItem $trashItem, Location $newParentLocation = null)
160
    {
161
        if (!is_numeric($trashItem->id)) {
0 ignored issues
show
Documentation introduced by
The property $id is declared protected in eZ\Publish\API\Repository\Values\Content\Location. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
162
            throw new InvalidArgumentValue('id', $trashItem->id, 'TrashItem');
0 ignored issues
show
Documentation introduced by
The property $id is declared protected in eZ\Publish\API\Repository\Values\Content\Location. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
163
        }
164
165
        if ($newParentLocation === null && !is_numeric($trashItem->parentLocationId)) {
0 ignored issues
show
Documentation introduced by
The property $parentLocationId is declared protected in eZ\Publish\API\Repository\Values\Content\Location. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
166
            throw new InvalidArgumentValue('parentLocationId', $trashItem->parentLocationId, 'TrashItem');
0 ignored issues
show
Documentation introduced by
The property $parentLocationId is declared protected in eZ\Publish\API\Repository\Values\Content\Location. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
167
        }
168
169
        if ($newParentLocation !== null && !is_numeric($newParentLocation->id)) {
170
            throw new InvalidArgumentValue('parentLocationId', $newParentLocation->id, 'Location');
171
        }
172
173
        if ($this->repository->hasAccess('content', 'restore') !== true) {
174
            throw new UnauthorizedException('content', 'restore');
175
        }
176
177
        $this->repository->beginTransaction();
178
        try {
179
            $newParentLocationId = $newParentLocation ? $newParentLocation->id : $trashItem->parentLocationId;
0 ignored issues
show
Documentation introduced by
The property $parentLocationId is declared protected in eZ\Publish\API\Repository\Values\Content\Location. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
180
            $newLocationId = $this->persistenceHandler->trashHandler()->recover(
181
                $trashItem->id,
0 ignored issues
show
Documentation introduced by
The property $id is declared protected in eZ\Publish\API\Repository\Values\Content\Location. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
182
                $newParentLocationId
183
            );
184
185
            $content = $this->repository->getContentService()->loadContent($trashItem->contentId);
186
            $urlAliasNames = $this->nameSchemaService->resolveUrlAliasSchema($content);
187
188
            // Publish URL aliases for recovered location
189
            foreach ($urlAliasNames as $languageCode => $name) {
190
                $this->persistenceHandler->urlAliasHandler()->publishUrlAliasForLocation(
191
                    $newLocationId,
192
                    $newParentLocationId,
193
                    $name,
194
                    $languageCode,
195
                    $content->contentInfo->alwaysAvailable
196
                );
197
            }
198
199
            $this->repository->commit();
200
        } catch (Exception $e) {
201
            $this->repository->rollback();
202
            throw $e;
203
        }
204
205
        return $this->repository->getLocationService()->loadLocation($newLocationId);
206
    }
207
208
    /**
209
     * Empties trash.
210
     *
211
     * All locations contained in the trash will be removed. Content objects will be removed
212
     * if all locations of the content are gone.
213
     *
214
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to empty the trash
215
     */
216 View Code Duplication
    public function emptyTrash()
217
    {
218
        if ($this->repository->hasAccess('content', 'cleantrash') !== true) {
219
            throw new UnauthorizedException('content', 'cleantrash');
220
        }
221
222
        $this->repository->beginTransaction();
223
        try {
224
            // Persistence layer takes care of deleting content objects
225
            $this->persistenceHandler->trashHandler()->emptyTrash();
226
            $this->repository->commit();
227
        } catch (Exception $e) {
228
            $this->repository->rollback();
229
            throw $e;
230
        }
231
    }
232
233
    /**
234
     * Deletes a trash item.
235
     *
236
     * The corresponding content object will be removed
237
     *
238
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to delete this trash item
239
     *
240
     * @param \eZ\Publish\API\Repository\Values\Content\TrashItem $trashItem
241
     */
242 View Code Duplication
    public function deleteTrashItem(APITrashItem $trashItem)
243
    {
244
        if ($this->repository->hasAccess('content', 'cleantrash') !== true) {
245
            throw new UnauthorizedException('content', 'cleantrash');
246
        }
247
248
        if (!is_numeric($trashItem->id)) {
0 ignored issues
show
Documentation introduced by
The property $id is declared protected in eZ\Publish\API\Repository\Values\Content\Location. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
249
            throw new InvalidArgumentValue('id', $trashItem->id, 'TrashItem');
0 ignored issues
show
Documentation introduced by
The property $id is declared protected in eZ\Publish\API\Repository\Values\Content\Location. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
250
        }
251
252
        $this->repository->beginTransaction();
253
        try {
254
            $this->persistenceHandler->trashHandler()->deleteTrashItem($trashItem->id);
0 ignored issues
show
Documentation introduced by
The property $id is declared protected in eZ\Publish\API\Repository\Values\Content\Location. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
255
            $this->repository->commit();
256
        } catch (Exception $e) {
257
            $this->repository->rollback();
258
            throw $e;
259
        }
260
    }
261
262
    /**
263
     * Returns a collection of Trashed locations contained in the trash.
264
     *
265
     * $query allows to filter/sort the elements to be contained in the collection.
266
     *
267
     * @param \eZ\Publish\API\Repository\Values\Content\Query $query
268
     *
269
     * @return \eZ\Publish\API\Repository\Values\Content\SearchResult
270
     */
271
    public function findTrashItems(Query $query)
272
    {
273
        if ($query->filter !== null && !$query->filter instanceof Criterion) {
274
            throw new InvalidArgumentValue('query->filter', $query->filter, 'Query');
275
        }
276
277
        if ($query->sortClauses !== null) {
278
            if (!is_array($query->sortClauses)) {
279
                throw new InvalidArgumentValue('query->sortClauses', $query->sortClauses, 'Query');
280
            }
281
282
            foreach ($query->sortClauses as $sortClause) {
283
                if (!$sortClause instanceof SortClause) {
284
                    throw new InvalidArgumentValue('query->sortClauses', 'only instances of SortClause class are allowed');
285
                }
286
            }
287
        }
288
289
        if ($query->offset !== null && !is_numeric($query->offset)) {
290
            throw new InvalidArgumentValue('query->offset', $query->offset, 'Query');
291
        }
292
293
        if ($query->limit !== null && !is_numeric($query->limit)) {
294
            throw new InvalidArgumentValue('query->limit', $query->limit, 'Query');
295
        }
296
297
        $spiTrashItems = $this->persistenceHandler->trashHandler()->findTrashItems(
298
            $query->filter !== null ? $query->filter : null,
299
            $query->offset !== null && $query->offset > 0 ? (int)$query->offset : 0,
300
            $query->limit !== null && $query->limit >= 1 ? (int)$query->limit : null,
301
            $query->sortClauses !== null ? $query->sortClauses : null
0 ignored issues
show
Bug introduced by
It seems like $query->sortClauses !== ...ery->sortClauses : null can also be of type array; however, eZ\Publish\SPI\Persisten...ndler::findTrashItems() does only seem to accept null|array<integer,objec...tent\Query\SortClause>>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
302
        );
303
304
        $trashItems = array();
305
        foreach ($spiTrashItems as $spiTrashItem) {
306
            $trashItems[] = $this->buildDomainTrashItemObject($spiTrashItem);
307
        }
308
309
        $searchResult = new SearchResult();
0 ignored issues
show
Deprecated Code introduced by
The class eZ\Publish\API\Repositor...es\Content\SearchResult has been deprecated with message: This class is returned by find methods providing a result of a search.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
310
        $searchResult->count = count($trashItems);
311
        $searchResult->items = $trashItems;
312
        $searchResult->query = $query;
313
314
        return $searchResult;
315
    }
316
317
    /**
318
     * Builds the domain TrashItem object from provided persistence trash item.
319
     *
320
     * @param \eZ\Publish\SPI\Persistence\Content\Location\Trashed $spiTrashItem
321
     *
322
     * @return \eZ\Publish\API\Repository\Values\Content\TrashItem
323
     */
324 View Code Duplication
    protected function buildDomainTrashItemObject(Trashed $spiTrashItem)
325
    {
326
        return new TrashItem(
327
            array(
328
                'contentInfo' => $this->repository->getContentService()->loadContentInfo($spiTrashItem->contentId),
329
                'id' => $spiTrashItem->id,
330
                'priority' => $spiTrashItem->priority,
331
                'hidden' => $spiTrashItem->hidden,
332
                'invisible' => $spiTrashItem->invisible,
333
                'remoteId' => $spiTrashItem->remoteId,
334
                'parentLocationId' => $spiTrashItem->parentId,
335
                'pathString' => $spiTrashItem->pathString,
336
                'depth' => $spiTrashItem->depth,
337
                'sortField' => $spiTrashItem->sortField,
338
                'sortOrder' => $spiTrashItem->sortOrder,
339
            )
340
        );
341
    }
342
343
    /**
344
     * @param int $timestamp
345
     *
346
     * @return \DateTime
347
     */
348
    protected function getDateTime($timestamp)
349
    {
350
        $dateTime = new DateTime();
351
        $dateTime->setTimestamp($timestamp);
352
353
        return $dateTime;
354
    }
355
}
356