Passed
Push — master ( 801396...a2dd86 )
by Aimeos
19:04
created

None::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2014
6
 * @copyright Aimeos (aimeos.org), 2015-2024
7
 * @package MAdmin
8
 * @subpackage Cache
9
 */
10
11
12
namespace Aimeos\MAdmin\Cache\Manager;
13
14
15
/**
16
 * Null cache manager implementation.
17
 *
18
 * @package MAdmin
19
 * @subpackage Cache
20
 */
21
class None
22
	extends \Aimeos\MAdmin\Common\Manager\Base
23
	implements \Aimeos\MAdmin\Cache\Manager\Iface, \Aimeos\MShop\Common\Manager\Factory\Iface
24
{
25
	private array $searchConfig = array(
26
		'cache.id' => array(
27
			'code' => 'cache.id',
28
			'internalcode' => '"id"',
29
			'label' => 'ID',
30
		),
31
	);
32
33
34
	/**
35
	 * Returns the cache object
36
	 *
37
	 * @return \Aimeos\Base\Cache\Iface Cache object
38
	 */
39
	public function getCache() : \Aimeos\Base\Cache\Iface
40
	{
41
		return \Aimeos\Base\Cache\Factory::create( 'None', [], null );
42
	}
43
44
45
	/**
46
	 * Removes old entries from the storage.
47
	 *
48
	 * @param iterable $siteids List of IDs for sites whose entries should be deleted
49
	 * @return \Aimeos\MAdmin\Cache\Manager\Iface Manager object for chaining method calls
50
	 */
51
	public function clear( iterable $siteids ) : \Aimeos\MShop\Common\Manager\Iface
52
	{
53
		return $this;
54
	}
55
56
57
	/**
58
	 * Creates a new empty item instance
59
	 *
60
	 * @param array $values Values the item should be initialized with
61
	 * @return \Aimeos\MAdmin\Cache\Item\Iface New cache item object
62
	 */
63
	public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface
64
	{
65
		$values['siteid'] = $values['siteid'] ?? $this->context()->locale()->getSiteId();
66
		return new \Aimeos\MAdmin\Cache\Item\Standard( $values );
67
	}
68
69
70
	/**
71
	 * Adds a new cache to the storage.
72
	 *
73
	 * @param \Aimeos\MAdmin\Cache\Item\Iface $item Cache item that should be saved to the storage
74
	 * @param bool $fetch True if the new ID should be returned in the item
75
	 * @return \Aimeos\MAdmin\Cache\Item\Iface Updated item including the generated ID
76
	 */
77
	protected function saveItem( \Aimeos\MAdmin\Cache\Item\Iface $item, bool $fetch = true ) : \Aimeos\MAdmin\Cache\Item\Iface
78
	{
79
		return $item;
80
	}
81
82
83
	/**
84
	 * Removes multiple items.
85
	 *
86
	 * @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
87
	 * @return \Aimeos\MAdmin\Cache\Manager\Iface Manager object for chaining method calls
88
	 */
89
	public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
90
	{
91
		return $this;
92
	}
93
94
95
	/**
96
	 * Creates the cache object for the given cache id.
97
	 *
98
	 * @param string $id Cache ID to fetch cache object for
99
	 * @param string[] $ref List of domains to fetch list items and referenced items for
100
	 * @param bool|null $default Add default criteria or NULL for relaxed default criteria
101
	 * @return \Aimeos\MAdmin\Cache\Item\Iface Returns the cache item of the given id
102
	 * @throws \Aimeos\MAdmin\Cache\Exception If item couldn't be found
103
	 */
104
	public function get( string $id, array $ref = [], ?bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
105
	{
106
		$msg = $this->context()->translate( 'mshop', 'Operation not supported' );
107
		throw new \Aimeos\MAdmin\Cache\Exception( $msg );
108
	}
109
110
111
	/**
112
	 * Search for cache entries based on the given criteria.
113
	 *
114
	 * @param \Aimeos\Base\Criteria\Iface $search Search object containing the conditions
115
	 * @param string[] $ref List of domains to fetch list items and referenced items for
116
	 * @param int &$total Number of items that are available in total
117
	 * @return \Aimeos\Map List of items implementing \Aimeos\MAdmin\Cache\Item\Iface with ids as keys
118
	 */
119
	public function search( \Aimeos\Base\Criteria\Iface $search, array $ref = [], int &$total = null ) : \Aimeos\Map
120
	{
121
		return map();
122
	}
123
124
125
	/**
126
	 * Returns the available manager types
127
	 *
128
	 * @param bool $withsub Return also the resource type of sub-managers if true
129
	 * @return string[] Type of the manager and submanagers, subtypes are separated by slashes
130
	 */
131
	public function getResourceType( bool $withsub = true ) : array
132
	{
133
		$path = 'madmin/cache/manager/submanagers';
134
		return $this->getResourceTypeBase( 'cache', $path, [], $withsub );
135
	}
136
137
138
	/**
139
	 * Returns the attributes that can be used for searching.
140
	 *
141
	 * @param bool $withsub Return also attributes of sub-managers if true
142
	 * @return \Aimeos\Base\Criteria\Attribute\Iface[] Returns a list of search attributes
143
	 */
144
	public function getSearchAttributes( bool $withsub = true ) : array
145
	{
146
		$path = 'madmin/cache/manager/submanagers';
147
148
		return $this->getSearchAttributesBase( $this->searchConfig, $path, [], $withsub );
149
	}
150
151
152
	/**
153
	 * Returns a new manager for cache extensions
154
	 *
155
	 * @param string $manager Name of the sub manager type in lower case
156
	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
157
	 * @return \Aimeos\MShop\Common\Manager\Iface Manager for different extensions, e.g stock, tags, locations, etc.
158
	 */
159
	public function getSubManager( string $manager, string $name = null ) : \Aimeos\MShop\Common\Manager\Iface
160
	{
161
		return $this->getSubManagerBase( 'cache', $manager, $name );
162
	}
163
}
164