Completed
Push — master ( 73e535...085f89 )
by Aimeos
07:50
created

lib/mshoplib/src/MAdmin/Cache/Manager/None.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2014
6
 * @copyright Aimeos (aimeos.org), 2015-2017
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
0 ignored issues
show
Expected 0 spaces between "Base" and comma; 1 found
Loading history...
23
	implements \Aimeos\MAdmin\Cache\Manager\Iface
24
{
25
	private $searchConfig = array(
26
		'cache.id' => array(
27
			'code' => 'cache.id',
28
			'internalcode' => '"id"',
29
			'label' => 'ID',
30
			'type' => 'string',
31
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
32
		),
33
	);
34
35
36
	/**
37
	 * Returns the cache object
38
	 *
39
	 * @return \Aimeos\MW\Cache\Iface Cache object
40
	 */
41
	public function getCache()
42
	{
43
		return \Aimeos\MW\Cache\Factory::createManager( 'None', [], null );
44
	}
45
46
47
	/**
48
	 * Create new cache item object.
49
	 *
50
	 * @return \Aimeos\MAdmin\Cache\Item\Iface
51
	 */
52
	public function createItem()
53
	{
54
		$values = array( 'siteid' => $this->getContext()->getLocale()->getSiteId() );
55
56
		return new \Aimeos\MAdmin\Cache\Item\Standard( $values );
57
	}
58
59
60
	/**
61
	 * Adds a new cache to the storage.
62
	 *
63
	 * @param \Aimeos\MAdmin\Cache\Item\Iface $item Cache item that should be saved to the storage
64
	 * @param boolean $fetch True if the new ID should be returned in the item
65
	 * @return \Aimeos\MShop\Common\Item\Iface $item Updated item including the generated ID
66
	 */
67
	public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true )
68
	{
69
		return $item;
70
	}
71
72
73
	/**
74
	 * Removes multiple items specified by ids in the array.
75
	 *
76
	 * @param array $ids List of IDs
77
	 */
78
	public function deleteItems( array $ids )
79
	{
80
	}
81
82
83
	/**
84
	 * Creates the cache object for the given cache id.
85
	 *
86
	 * @param integer $id Cache ID to fetch cache object for
87
	 * @param array $ref List of domains to fetch list items and referenced items for
88
	 * @param boolean $default Add default criteria
89
	 * @return \Aimeos\MAdmin\Cache\Item\Iface Returns the cache item of the given id
90
	 * @throws \Aimeos\MAdmin\Cache\Exception If item couldn't be found
91
	 */
92
	public function getItem( $id, array $ref = [], $default = false )
93
	{
94
		throw new \Aimeos\MAdmin\Cache\Exception( sprintf( 'Operation not supported' ) );
95
	}
96
97
98
	/**
99
	 * Search for cache entries based on the given criteria.
100
	 *
101
	 * @param \Aimeos\MW\Criteria\Iface $search Search object containing the conditions
102
	 * @param integer &$total Number of items that are available in total
103
	 *
104
	 * @return array List of cache items implementing \Aimeos\MAdmin\Cache\Item\Iface
105
	 */
106
	public function searchItems( \Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null )
107
	{
108
		return [];
109
	}
110
111
112
	/**
113
	 * Returns the available manager types
114
	 *
115
	 * @param boolean $withsub Return also the resource type of sub-managers if true
116
	 * @return array Type of the manager and submanagers, subtypes are separated by slashes
117
	 */
118
	public function getResourceType( $withsub = true )
119
	{
120
		$path = 'madmin/cache/manager/submanagers';
121
122
		return $this->getResourceTypeBase( 'cache', $path, [], $withsub );
123
	}
124
125
126
	/**
127
	 * Returns the attributes that can be used for searching.
128
	 *
129
	 * @param boolean $withsub Return also attributes of sub-managers if true
130
	 * @return array Returns a list of attribtes implementing \Aimeos\MW\Criteria\Attribute\Iface
131
	 */
132
	public function getSearchAttributes( $withsub = true )
133
	{
134
		$path = 'madmin/cache/manager/submanagers';
135
136
		return $this->getSearchAttributesBase( $this->searchConfig, $path, [], $withsub );
137
	}
138
139
140
	/**
141
	 * Returns a new manager for cache extensions
142
	 *
143
	 * @param string $manager Name of the sub manager type in lower case
144
	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
145
	 * @return \Aimeos\MShop\Common\Manager\Iface Manager for different extensions, e.g stock, tags, locations, etc.
146
	 */
147
	public function getSubManager( $manager, $name = null )
148
	{
149
		return $this->getSubManagerBase( 'cache', $manager, $name );
150
	}
151
}
152