forked from ezsystems/ezpublish-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UrlWildcardHandler.php
105 lines (94 loc) · 2.69 KB
/
UrlWildcardHandler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* File containing the UrlWildcard Handler implementation
*
* @copyright Copyright (C) 1999-2014 eZ Systems AS. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
* @version //autogentag//
*/
namespace eZ\Publish\Core\Persistence\InMemory;
use eZ\Publish\SPI\Persistence\Content\UrlWildcard\Handler as UrlWildcardHandlerInterface;
/**
* @see eZ\Publish\SPI\Persistence\Content\UrlWildcard\Handler
*/
class UrlWildcardHandler implements UrlWildcardHandlerInterface
{
/**
* @var Handler
*/
protected $handler;
/**
* @var Backend
*/
protected $backend;
/**
* Setups current handler instance with reference to Handler object that created it.
*
* @param Handler $handler
* @param Backend $backend The storage engine backend
*/
public function __construct( Handler $handler, Backend $backend )
{
$this->handler = $handler;
$this->backend = $backend;
}
/**
* Creates a new url wildcard
*
* @param string $sourceUrl
* @param string $destinationUrl
* @param boolean $forward
*
* @return \eZ\Publish\SPI\Persistence\Content\UrlWildcard
*/
public function create( $sourceUrl, $destinationUrl, $forward = false )
{
return $this->backend->create(
'Content\\UrlWildcard',
array(
'sourceUrl' => $sourceUrl,
'destinationUrl' => $destinationUrl,
'forward' => (bool)$forward
)
);
}
/**
* removes an url wildcard
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the url wild card was not found
*
* @param mixed $id
*/
public function remove( $id )
{
$this->backend->delete( 'Content\\UrlWildcard', $id );
}
/**
* Loads a url wild card
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the url wild card was not found
*
* @param mixed $id
*
* @return \eZ\Publish\SPI\Persistence\Content\UrlWildcard
*/
public function load( $id )
{
return $this->backend->load( 'Content\\UrlWildcard', $id );
}
/**
* Loads all url wild card (paged)
*
* @param int $offset
* @param int $limit
*
* @return \eZ\Publish\SPI\Persistence\Content\UrlWildcard[]
*/
public function loadAll( $offset = 0, $limit = -1 )
{
$list = $this->backend->find( 'Content\\UrlWildcard' );
if ( empty( $list ) || ( $offset === 0 && $limit === -1 ) )
return $list;
return array_slice( $list, $offset, ( $limit === -1 ? null : $limit ) );
}
}