1 | <?php |
||
34 | class RegistryProcessor implements RegistryProcessorInterface |
||
35 | { |
||
36 | |||
37 | /** |
||
38 | * The cache adapter instance. |
||
39 | * |
||
40 | * @var \TechDivision\Import\Cache\CacheAdapterInterface |
||
41 | */ |
||
42 | protected $cacheAdapter; |
||
43 | |||
44 | /** |
||
45 | * Initialize the repository with the passed connection and utility class name. |
||
46 | * |
||
47 | * @param \TechDivision\Import\Cache\CacheAdapterInterface $cacheAdapter The cache adapter instance |
||
48 | */ |
||
49 | public function __construct(CacheAdapterInterface $cacheAdapter) |
||
53 | |||
54 | /** |
||
55 | * Register the passed attribute under the specified key in the registry. |
||
56 | * |
||
57 | * @param string $key The cache key to use |
||
58 | * @param mixed $value The value that has to be cached |
||
59 | * @param array $references An array with references to add |
||
60 | * @param array $tags An array with tags to add |
||
61 | * @param boolean $override Flag that allows to override an exising cache entry |
||
62 | * |
||
63 | * @return void |
||
64 | * @throws \Exception Is thrown, if the key has already been used |
||
65 | */ |
||
66 | public function setAttribute($key, $value, array $references = array(), array $tags = array(), $override = false) |
||
70 | |||
71 | /** |
||
72 | * Return's the attribute with the passed key from the registry. |
||
73 | * |
||
74 | * @param mixed $key The key to return the attribute for |
||
75 | * |
||
76 | * @return mixed The requested attribute |
||
77 | */ |
||
78 | public function getAttribute($key) |
||
82 | |||
83 | /** |
||
84 | * Query whether or not an attribute with the passed key has already been registered. |
||
85 | * |
||
86 | * @param mixed $key The key to query for |
||
87 | * |
||
88 | * @return boolean TRUE if the attribute has already been registered, else FALSE |
||
89 | */ |
||
90 | public function hasAttribute($key) |
||
94 | |||
95 | /** |
||
96 | * Remove the attribute with the passed key from the registry. |
||
97 | * |
||
98 | * @param mixed $key The key of the attribute to return |
||
99 | * |
||
100 | * @return void |
||
101 | */ |
||
102 | public function removeAttribute($key) |
||
106 | |||
107 | /** |
||
108 | * Flush the cache. |
||
109 | * |
||
110 | * @return void |
||
111 | */ |
||
112 | public function flushCache() |
||
116 | |||
117 | /** |
||
118 | * Raises the value for the attribute with the passed key by one. |
||
119 | * |
||
120 | * @param mixed $key The key of the attribute to raise the value for |
||
121 | * @param mixed $counterName The name of the counter to raise |
||
122 | * |
||
123 | * @return integer The counter's new value |
||
124 | */ |
||
125 | public function raiseCounter($key, $counterName) |
||
129 | |||
130 | /** |
||
131 | * Lowers the value for the attribute with the passed key by one. |
||
132 | * |
||
133 | * @param mixed $key The key of the attribute to lower the value for |
||
134 | * @param mixed $counterName The name of the counter to lower |
||
135 | * |
||
136 | * @return integer The counter's new value |
||
137 | */ |
||
138 | public function lowerCounter($key, $counterName) |
||
142 | |||
143 | /** |
||
144 | * This method merges the passed attributes with an array that |
||
145 | * has already been added under the passed key. |
||
146 | * |
||
147 | * If no value will be found under the passed key, the attributes |
||
148 | * will simply be registered. |
||
149 | * |
||
150 | * @param mixed $key The key of the attributes that has to be merged with the passed ones |
||
151 | * @param array $attributes The attributes that has to be merged with the exising ones |
||
152 | * |
||
153 | * @return void |
||
154 | * @throws \Exception Is thrown, if the already registered value is no array |
||
155 | * @link http://php.net/array_replace_recursive |
||
156 | */ |
||
157 | public function mergeAttributesRecursive($key, array $attributes) |
||
161 | |||
162 | /** |
||
163 | * Load's the data with the passed key from the registry. |
||
164 | * |
||
165 | * @param string $key The key of the data to load |
||
166 | * @param string $delimiter The delimiter to explode the key with |
||
167 | * |
||
168 | * @return mixed The data |
||
169 | */ |
||
170 | public function load($key, $delimiter = '.') |
||
191 | } |
||
192 |