Standard::getSubClientNames()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
nc 1
nop 0
dl 0
loc 36
c 1
b 0
f 0
cc 1
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021
6
 * @package Admin
7
 * @subpackage JQAdm
8
 */
9
10
11
namespace Aimeos\Admin\JQAdm\Cms\Content;
12
13
sprintf( 'content' ); // for translation
14
15
16
/**
17
 * Default implementation of cms SEO JQAdm client.
18
 *
19
 * @package Admin
20
 * @subpackage JQAdm
21
 */
22
class Standard
23
	extends \Aimeos\Admin\JQAdm\Common\Admin\Factory\Base
24
	implements \Aimeos\Admin\JQAdm\Common\Admin\Factory\Iface
25
{
26
	/** admin/jqadm/cms/content/name
27
	 * Name of the SEO subpart used by the JQAdm cms implementation
28
	 *
29
	 * Use "Myname" if your class is named "\Aimeos\Admin\Jqadm\Cms\Text\Myname".
30
	 * The name is case-sensitive and you should avoid camel case names like "MyName".
31
	 *
32
	 * @param string Last part of the JQAdm class name
33
	 * @since 2020.10
34
	 * @category Developer
35
	 */
36
37
38
	/**
39
	 * Copies a resource
40
	 *
41
	 * @return string|null HTML output
42
	 */
43
	public function copy() : ?string
44
	{
45
		$view = $this->getObject()->addData( $this->getView() );
46
		$view->contentData = $this->toArray( $view->item, true );
47
		$view->contentBody = parent::copy();
48
49
		return $this->render( $view );
50
	}
51
52
53
	/**
54
	 * Creates a new resource
55
	 *
56
	 * @return string|null HTML output
57
	 */
58
	public function create() : ?string
59
	{
60
		$view = $this->getObject()->addData( $this->getView() );
61
		$siteid = $this->getContext()->getLocale()->getSiteId();
62
		$data = $view->param( 'content', [] );
63
64
		foreach( $data as $idx => $entry )
65
		{
66
			$data[$idx]['cms.lists.siteid'] = $siteid;
67
			$data[$idx]['text.siteid'] = $siteid;
68
		}
69
70
		$view->contentData = $data;
71
		$view->contentBody = parent::create();
72
73
		return $this->render( $view );
74
	}
75
76
77
	/**
78
	 * Deletes a resource
79
	 *
80
	 * @return string|null HTML output
81
	 */
82
	public function delete() : ?string
83
	{
84
		parent::delete();
85
86
		$item = $this->getView()->item;
87
		$item->deleteListItems( $item->getListItems( 'text', null, 'content', false )->toArray(), true );
88
89
		return null;
90
	}
91
92
93
	/**
94
	 * Returns a single resource
95
	 *
96
	 * @return string|null HTML output
97
	 */
98
	public function get() : ?string
99
	{
100
		$view = $this->getObject()->addData( $this->getView() );
101
		$view->contentData = $this->toArray( $view->item );
102
		$view->contentBody = parent::get();
103
104
		return $this->render( $view );
105
	}
106
107
108
	/**
109
	 * Saves the data
110
	 *
111
	 * @return string|null HTML output
112
	 */
113
	public function save() : ?string
114
	{
115
		$view = $this->getView();
116
117
		$view->item = $this->fromArray( $view->item, $view->param( 'content', [] ) );
118
		$view->contentBody = parent::save();
119
120
		return null;
121
	}
122
123
124
	/**
125
	 * Returns the sub-client given by its name.
126
	 *
127
	 * @param string $type Name of the client type
128
	 * @param string|null $name Name of the sub-client (Default if null)
129
	 * @return \Aimeos\Admin\JQAdm\Iface Sub-client object
130
	 */
131
	public function getSubClient( string $type, string $name = null ) : \Aimeos\Admin\JQAdm\Iface
132
	{
133
		/** admin/jqadm/cms/content/decorators/excludes
134
		 * Excludes decorators added by the "common" option from the cms JQAdm client
135
		 *
136
		 * Decorators extend the functionality of a class by adding new aspects
137
		 * (e.g. log what is currently done), executing the methods of the underlying
138
		 * class only in certain conditions (e.g. only for logged in users) or
139
		 * modify what is returned to the caller.
140
		 *
141
		 * This option allows you to remove a decorator added via
142
		 * "admin/jqadm/common/decorators/default" before they are wrapped
143
		 * around the JQAdm client.
144
		 *
145
		 *  admin/jqadm/cms/content/decorators/excludes = array( 'decorator1' )
146
		 *
147
		 * This would remove the decorator named "decorator1" from the list of
148
		 * common decorators ("\Aimeos\Admin\JQAdm\Common\Decorator\*") added via
149
		 * "admin/jqadm/common/decorators/default" to the JQAdm client.
150
		 *
151
		 * @param array List of decorator names
152
		 * @since 2020.10
153
		 * @category Developer
154
		 * @see admin/jqadm/common/decorators/default
155
		 * @see admin/jqadm/cms/content/decorators/global
156
		 * @see admin/jqadm/cms/content/decorators/local
157
		 */
158
159
		/** admin/jqadm/cms/content/decorators/global
160
		 * Adds a list of globally available decorators only to the cms JQAdm client
161
		 *
162
		 * Decorators extend the functionality of a class by adding new aspects
163
		 * (e.g. log what is currently done), executing the methods of the underlying
164
		 * class only in certain conditions (e.g. only for logged in users) or
165
		 * modify what is returned to the caller.
166
		 *
167
		 * This option allows you to wrap global decorators
168
		 * ("\Aimeos\Admin\JQAdm\Common\Decorator\*") around the JQAdm client.
169
		 *
170
		 *  admin/jqadm/cms/content/decorators/global = array( 'decorator1' )
171
		 *
172
		 * This would add the decorator named "decorator1" defined by
173
		 * "\Aimeos\Admin\JQAdm\Common\Decorator\Decorator1" only to the JQAdm client.
174
		 *
175
		 * @param array List of decorator names
176
		 * @since 2020.10
177
		 * @category Developer
178
		 * @see admin/jqadm/common/decorators/default
179
		 * @see admin/jqadm/cms/content/decorators/excludes
180
		 * @see admin/jqadm/cms/content/decorators/local
181
		 */
182
183
		/** admin/jqadm/cms/content/decorators/local
184
		 * Adds a list of local decorators only to the cms JQAdm client
185
		 *
186
		 * Decorators extend the functionality of a class by adding new aspects
187
		 * (e.g. log what is currently done), executing the methods of the underlying
188
		 * class only in certain conditions (e.g. only for logged in users) or
189
		 * modify what is returned to the caller.
190
		 *
191
		 * This option allows you to wrap local decorators
192
		 * ("\Aimeos\Admin\JQAdm\Cms\Decorator\*") around the JQAdm client.
193
		 *
194
		 *  admin/jqadm/cms/content/decorators/local = array( 'decorator2' )
195
		 *
196
		 * This would add the decorator named "decorator2" defined by
197
		 * "\Aimeos\Admin\JQAdm\Cms\Decorator\Decorator2" only to the JQAdm client.
198
		 *
199
		 * @param array List of decorator names
200
		 * @since 2020.10
201
		 * @category Developer
202
		 * @see admin/jqadm/common/decorators/default
203
		 * @see admin/jqadm/cms/content/decorators/excludes
204
		 * @see admin/jqadm/cms/content/decorators/global
205
		 */
206
		return $this->createSubClient( 'cms/content/' . $type, $name );
207
	}
208
209
210
	/**
211
	 * Returns the list of sub-client names configured for the client.
212
	 *
213
	 * @return array List of JQAdm client names
214
	 */
215
	protected function getSubClientNames() : array
216
	{
217
		/** admin/jqadm/cms/content/subparts
218
		 * List of JQAdm sub-clients rendered within the cms content section
219
		 *
220
		 * The output of the frontend is composed of the code generated by the JQAdm
221
		 * clients. Each JQAdm client can consist of serveral (or none) sub-clients
222
		 * that are responsible for rendering certain sub-parts of the output. The
223
		 * sub-clients can contain JQAdm clients themselves and therefore a
224
		 * hierarchical tree of JQAdm clients is composed. Each JQAdm client creates
225
		 * the output that is placed inside the container of its parent.
226
		 *
227
		 * At first, always the JQAdm code generated by the parent is printed, then
228
		 * the JQAdm code of its sub-clients. The order of the JQAdm sub-clients
229
		 * determines the order of the output of these sub-clients inside the parent
230
		 * container. If the configured list of clients is
231
		 *
232
		 *  array( "subclient1", "subclient2" )
233
		 *
234
		 * you can easily change the order of the output by reordering the subparts:
235
		 *
236
		 *  admin/jqadm/<clients>/subparts = array( "subclient1", "subclient2" )
237
		 *
238
		 * You can also remove one or more parts if they shouldn't be rendered:
239
		 *
240
		 *  admin/jqadm/<clients>/subparts = array( "subclient1" )
241
		 *
242
		 * As the clients only generates structural JQAdm, the layout defined via CSS
243
		 * should support adding, removing or reordering content by a fluid like
244
		 * design.
245
		 *
246
		 * @param array List of sub-client names
247
		 * @since 2020.10
248
		 * @category Developer
249
		 */
250
		return $this->getContext()->getConfig()->get( 'admin/jqadm/cms/content/subparts', [] );
251
	}
252
253
254
	/**
255
	 * Adds the required data used in the content template
256
	 *
257
	 * @param \Aimeos\MW\View\Iface $view View object
258
	 * @return \Aimeos\MW\View\Iface View object with assigned parameters
259
	 */
260
	public function addData( \Aimeos\MW\View\Iface $view ) : \Aimeos\MW\View\Iface
261
	{
262
		$media = [];
263
		$context = $this->getContext();
264
		$listTypeManager = \Aimeos\MShop::create( $context, 'cms/lists/type' );
265
266
		$listSearch = $listTypeManager->filter( true )->slice( 0, 10000 );
267
		$listSearch->setConditions( $listSearch->compare( '==', 'cms.lists.type.domain', 'text' ) );
268
		$listSearch->setSortations( [$listSearch->sort( '+', 'cms.lists.type.position' )] );
269
270
		$view->contentListTypes = $listTypeManager->search( $listSearch );
271
272
		foreach( $view->item->getRefItems( 'media' ) as $mediaItem )
273
		{
274
			$srcset = [];
275
276
			foreach( $mediaItem->getPreviews() as $width => $path ) {
277
				$srcset[] = $view->content( $path ) . ' ' . $width . 'w';
278
			}
279
280
			$media[] = [
281
				'name' => $mediaItem->getLabel(),
282
				'src' => $view->content( $mediaItem->getPreview( true ) ),
283
				'srcset' => join( ', ', $srcset ),
284
				'type' => 'image'
285
			];
286
		}
287
288
		return $view->set( 'contentMedia', $media );
289
	}
290
291
292
	/**
293
	 * Creates new and updates existing items using the data array
294
	 *
295
	 * @param \Aimeos\MShop\Cms\Item\Iface $item Cms item object without referenced domain items
296
	 * @param array $data Data array
297
	 * @return \Aimeos\MShop\Cms\Item\Iface Modified cms item
298
	 */
299
	protected function fromArray( \Aimeos\MShop\Cms\Item\Iface $item, array $data ) : \Aimeos\MShop\Cms\Item\Iface
300
	{
301
		$context = $this->getContext();
302
303
		$textManager = \Aimeos\MShop::create( $context, 'text' );
304
		$listManager = \Aimeos\MShop::create( $context, 'cms/lists' );
305
306
		$listItems = $item->getListItems( 'text', null, 'content', false );
307
308
		foreach( $data as $idx => $entry )
309
		{
310
			if( !( $content = trim( $this->getValue( $entry, 'text.content', '' ) ) ) ) {
311
				continue;
312
			}
313
314
			$config = \HTMLPurifier_Config::createDefault();
315
			$config->set( 'Attr.AllowedFrameTargets', ['_blank', '_self'] );
316
317
			$purifier = new \HTMLPurifier( $config );
318
			$entry['text.content'] = $purifier->purify( $content );
319
320
			$listType = $entry['cms.lists.type'] ?? 'default';
321
322
			if( ( $listItem = $item->getListItem( 'text', $listType, $entry['text.id'], false ) ) === null ) {
323
				$listItem = $listManager->create();
324
			}
325
326
			if( ( $refItem = $listItem->getRefItem() ) === null ) {
0 ignored issues
show
Bug introduced by
The method getRefItem() does not exist on Aimeos\MShop\Common\Item\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\MShop\Product\Item\Iface or Aimeos\MAdmin\Log\Item\Iface or Aimeos\MShop\Service\Item\Iface or Aimeos\MShop\Order\Item\Base\Product\Iface or Aimeos\MShop\Rule\Item\Iface or Aimeos\MShop\Locale\Item\Site\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Text\Item\Iface or Aimeos\MAdmin\Cache\Item\Iface or Aimeos\MShop\Common\Item\ListsRef\Iface or Aimeos\MShop\Order\Item\Base\Service\Iface or Aimeos\MShop\Customer\Item\Group\Iface or Aimeos\MShop\Stock\Item\Iface or Aimeos\MShop\Media\Item\Iface or Aimeos\MShop\Order\Item\Base\Coupon\Iface or Aimeos\MShop\Order\Item\Iface or Aimeos\MShop\Subscription\Item\Iface or Aimeos\MShop\Coupon\Item\Iface or Aimeos\MShop\Review\Item\Iface or Aimeos\MAdmin\Job\Item\Iface or Aimeos\MShop\Order\Item\Status\Iface or Aimeos\MShop\Price\Item\Iface or Aimeos\MShop\Locale\Item\Iface or Aimeos\MShop\Common\Item\PropertyRef\Iface or Aimeos\MShop\Tag\Item\Iface or Aimeos\MShop\Common\Item\Type\Iface or Aimeos\MShop\Attribute\Item\Iface or Aimeos\MShop\Order\Item\Base\Iface or Aimeos\MShop\Locale\Item\Language\Iface or Aimeos\MShop\Cms\Item\Iface or Aimeos\MShop\Order\Item\...Service\Attribute\Iface or Aimeos\MShop\Supplier\Item\Address\Iface or Aimeos\MShop\Common\Item\Address\Iface or Aimeos\MShop\Common\Item\Property\Iface or Aimeos\MShop\Catalog\Item\Iface or Aimeos\MShop\Order\Item\...Product\Attribute\Iface or Aimeos\MShop\Common\Item\AddressRef\Iface or Aimeos\MShop\Plugin\Item\Iface or Aimeos\MShop\Coupon\Item\Code\Iface or Aimeos\MShop\Supplier\Item\Iface or Aimeos\MShop\Locale\Item\Currency\Iface or Aimeos\MShop\Product\Item\Iface or Aimeos\MShop\Service\Item\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Text\Item\Iface or Aimeos\MShop\Media\Item\Iface or Aimeos\MShop\Price\Item\Iface or Aimeos\MShop\Attribute\Item\Iface or Aimeos\MShop\Cms\Item\Iface or Aimeos\MShop\Catalog\Item\Iface or Aimeos\MShop\Supplier\Item\Iface or Aimeos\MShop\Product\Item\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Media\Item\Iface or Aimeos\MShop\Price\Item\Iface or Aimeos\MShop\Attribute\Item\Iface or Aimeos\MShop\Order\Item\Base\Base or Aimeos\MShop\Order\Item\Base\Standard or Aimeos\MShop\Customer\Item\Address\Iface or Aimeos\MShop\Order\Item\Base\Address\Iface or Aimeos\MShop\Supplier\Item\Address\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Supplier\Item\Iface. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

326
			if( ( $refItem = $listItem->/** @scrutinizer ignore-call */ getRefItem() ) === null ) {
Loading history...
327
				$refItem = $textManager->create();
328
			}
329
330
			$refItem->fromArray( $entry, true )->setType( 'content' );
0 ignored issues
show
Bug introduced by
The method setType() does not exist on Aimeos\MShop\Common\Item\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\MAdmin\Log\Item\Iface or Aimeos\MShop\Locale\Item\Site\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MAdmin\Cache\Item\Iface or Aimeos\MShop\Common\Item\ListsRef\Iface or Aimeos\MShop\Customer\Item\Group\Iface or Aimeos\MShop\Order\Item\Base\Coupon\Iface or Aimeos\MShop\Subscription\Item\Iface or Aimeos\MShop\Coupon\Item\Iface or Aimeos\MShop\Review\Item\Iface or Aimeos\MAdmin\Job\Item\Iface or Aimeos\MShop\Locale\Item\Iface or Aimeos\MShop\Common\Item\PropertyRef\Iface or Aimeos\MShop\Common\Item\Type\Iface or Aimeos\MShop\Order\Item\Base\Iface or Aimeos\MShop\Locale\Item\Language\Iface or Aimeos\MShop\Cms\Item\Iface or Aimeos\MShop\Supplier\Item\Address\Iface or Aimeos\MShop\Common\Item\Address\Iface or Aimeos\MShop\Catalog\Item\Iface or Aimeos\MShop\Common\Item\AddressRef\Iface or Aimeos\MShop\Coupon\Item\Code\Iface or Aimeos\MShop\Supplier\Item\Iface or Aimeos\MShop\Locale\Item\Currency\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Cms\Item\Iface or Aimeos\MShop\Catalog\Item\Iface or Aimeos\MShop\Supplier\Item\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Order\Item\Base\Base or Aimeos\MShop\Order\Item\Base\Standard or Aimeos\MShop\Customer\Item\Address\Iface or Aimeos\MShop\Supplier\Item\Address\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Supplier\Item\Iface. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

330
			$refItem->fromArray( $entry, true )->/** @scrutinizer ignore-call */ setType( 'content' );
Loading history...
331
			$conf = [];
332
333
			foreach( (array) $this->getValue( $entry, 'config', [] ) as $cfg )
334
			{
335
				if( ( $key = trim( $cfg['key'] ?? '' ) ) !== '' ) {
336
					$conf[$key] = trim( $cfg['val'] ?? '' );
337
				}
338
			}
339
340
			$listItem->fromArray( $entry, true );
341
			$listItem->setPosition( $idx );
0 ignored issues
show
Bug introduced by
The method setPosition() does not exist on Aimeos\MShop\Common\Item\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\MShop\Product\Item\Iface or Aimeos\MAdmin\Log\Item\Iface or Aimeos\MShop\Locale\Item\Site\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Text\Item\Iface or Aimeos\MAdmin\Cache\Item\Iface or Aimeos\MShop\Common\Item\ListsRef\Iface or Aimeos\MShop\Customer\Item\Group\Iface or Aimeos\MShop\Stock\Item\Iface or Aimeos\MShop\Media\Item\Iface or Aimeos\MShop\Order\Item\Base\Coupon\Iface or Aimeos\MShop\Order\Item\Iface or Aimeos\MShop\Subscription\Item\Iface or Aimeos\MShop\Coupon\Item\Iface or Aimeos\MShop\Review\Item\Iface or Aimeos\MAdmin\Job\Item\Iface or Aimeos\MShop\Order\Item\Status\Iface or Aimeos\MShop\Price\Item\Iface or Aimeos\MShop\Common\Item\PropertyRef\Iface or Aimeos\MShop\Tag\Item\Iface or Aimeos\MShop\Order\Item\Base\Iface or Aimeos\MShop\Locale\Item\Language\Iface or Aimeos\MShop\Cms\Item\Iface or Aimeos\MShop\Order\Item\...Service\Attribute\Iface or Aimeos\MShop\Common\Item\Address\Iface or Aimeos\MShop\Common\Item\Property\Iface or Aimeos\MShop\Catalog\Item\Iface or Aimeos\MShop\Order\Item\...Product\Attribute\Iface or Aimeos\MShop\Common\Item\AddressRef\Iface or Aimeos\MShop\Coupon\Item\Code\Iface or Aimeos\MShop\Supplier\Item\Iface or Aimeos\MShop\Locale\Item\Currency\Iface or Aimeos\MShop\Product\Item\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Text\Item\Iface or Aimeos\MShop\Media\Item\Iface or Aimeos\MShop\Price\Item\Iface or Aimeos\MShop\Cms\Item\Iface or Aimeos\MShop\Catalog\Item\Iface or Aimeos\MShop\Supplier\Item\Iface or Aimeos\MShop\Product\Item\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Media\Item\Iface or Aimeos\MShop\Price\Item\Iface or Aimeos\MShop\Order\Item\Base\Base or Aimeos\MShop\Order\Item\Base\Standard or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Supplier\Item\Iface. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

341
			$listItem->/** @scrutinizer ignore-call */ 
342
              setPosition( $idx );
Loading history...
342
			$listItem->setConfig( $conf );
0 ignored issues
show
Bug introduced by
The method setConfig() does not exist on Aimeos\MShop\Common\Item\Iface. It seems like you code against a sub-type of said class. However, the method does not exist in Aimeos\MAdmin\Log\Item\Iface or Aimeos\MShop\Order\Item\Base\Product\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Text\Item\Iface or Aimeos\MAdmin\Cache\Item\Iface or Aimeos\MShop\Common\Item\ListsRef\Iface or Aimeos\MShop\Order\Item\Base\Service\Iface or Aimeos\MShop\Customer\Item\Group\Iface or Aimeos\MShop\Stock\Item\Iface or Aimeos\MShop\Media\Item\Iface or Aimeos\MShop\Order\Item\Base\Coupon\Iface or Aimeos\MShop\Order\Item\Iface or Aimeos\MShop\Subscription\Item\Iface or Aimeos\MShop\Review\Item\Iface or Aimeos\MAdmin\Job\Item\Iface or Aimeos\MShop\Order\Item\Status\Iface or Aimeos\MShop\Price\Item\Iface or Aimeos\MShop\Locale\Item\Iface or Aimeos\MShop\Common\Item\PropertyRef\Iface or Aimeos\MShop\Tag\Item\Iface or Aimeos\MShop\Common\Item\Type\Iface or Aimeos\MShop\Attribute\Item\Iface or Aimeos\MShop\Order\Item\Base\Iface or Aimeos\MShop\Locale\Item\Language\Iface or Aimeos\MShop\Cms\Item\Iface or Aimeos\MShop\Order\Item\...Service\Attribute\Iface or Aimeos\MShop\Supplier\Item\Address\Iface or Aimeos\MShop\Common\Item\Address\Iface or Aimeos\MShop\Common\Item\Property\Iface or Aimeos\MShop\Order\Item\...Product\Attribute\Iface or Aimeos\MShop\Common\Item\AddressRef\Iface or Aimeos\MShop\Coupon\Item\Code\Iface or Aimeos\MShop\Supplier\Item\Iface or Aimeos\MShop\Locale\Item\Currency\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Text\Item\Iface or Aimeos\MShop\Media\Item\Iface or Aimeos\MShop\Price\Item\Iface or Aimeos\MShop\Attribute\Item\Iface or Aimeos\MShop\Cms\Item\Iface or Aimeos\MShop\Supplier\Item\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Media\Item\Iface or Aimeos\MShop\Price\Item\Iface or Aimeos\MShop\Attribute\Item\Iface or Aimeos\MShop\Order\Item\Base\Base or Aimeos\MShop\Order\Item\Base\Standard or Aimeos\MShop\Customer\Item\Address\Iface or Aimeos\MShop\Order\Item\Base\Address\Iface or Aimeos\MShop\Supplier\Item\Address\Iface or Aimeos\MShop\Customer\Item\Iface or Aimeos\MShop\Supplier\Item\Iface. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

342
			$listItem->/** @scrutinizer ignore-call */ 
343
              setConfig( $conf );
Loading history...
343
344
			$item->addListItem( 'text', $listItem, $refItem );
345
346
			unset( $listItems[$listItem->getId()] );
347
		}
348
349
		return $item->deleteListItems( $listItems->toArray(), true );
350
	}
351
352
353
	/**
354
	 * Constructs the data array for the view from the given item
355
	 *
356
	 * @param \Aimeos\MShop\Cms\Item\Iface $item Cms item object including referenced domain items
357
	 * @param bool $copy True if items should be copied, false if not
358
	 * @return string[] Multi-dimensional associative list of item data
359
	 */
360
	protected function toArray( \Aimeos\MShop\Cms\Item\Iface $item, bool $copy = false ) : array
361
	{
362
		$data = [];
363
		$siteId = $this->getContext()->getLocale()->getSiteId();
364
365
		foreach( $item->getListItems( 'text', null, 'content', false ) as $listItem )
366
		{
367
			if( ( $refItem = $listItem->getRefItem() ) === null ) {
368
				continue;
369
			}
370
371
			$list = $listItem->toArray( true ) + $refItem->toArray( true );
372
373
			if( $copy === true )
374
			{
375
				$list['cms.lists.siteid'] = $siteId;
376
				$list['cms.lists.id'] = '';
377
				$list['text.siteid'] = $siteId;
378
				$list['text.id'] = null;
379
			}
380
381
			$list['cms.lists.datestart'] = str_replace( ' ', 'T', $list['cms.lists.datestart'] ?? '' );
382
			$list['cms.lists.dateend'] = str_replace( ' ', 'T', $list['cms.lists.dateend'] ?? '' );
383
			$list['config'] = [];
384
385
			foreach( $listItem->getConfig() as $key => $value ) {
386
				$list['config'][] = ['key' => $key, 'val' => $value];
387
			}
388
389
			$data[] = $list;
390
		}
391
392
		return $data;
393
	}
394
395
396
	/**
397
	 * Returns the rendered template including the view data
398
	 *
399
	 * @param \Aimeos\MW\View\Iface $view View object with data assigned
400
	 * @return string HTML output
401
	 */
402
	protected function render( \Aimeos\MW\View\Iface $view ) : string
403
	{
404
		/** admin/jqadm/cms/content/template-item
405
		 * Relative path to the HTML body template of the content subpart for cmss.
406
		 *
407
		 * The template file contains the HTML code and processing instructions
408
		 * to generate the result shown in the body of the frontend. The
409
		 * configuration string is the path to the template file relative
410
		 * to the templates directory (usually in admin/jqadm/templates).
411
		 *
412
		 * You can overwrite the template file configuration in extensions and
413
		 * provide alternative templates. These alternative templates should be
414
		 * named like the default one but with the string "default" replaced by
415
		 * an unique name. You may use the name of your project for this. If
416
		 * you've implemented an alternative client class as well, "default"
417
		 * should be replaced by the name of the new class.
418
		 *
419
		 * @param string Relative path to the template creating the HTML code
420
		 * @since 2020.10
421
		 * @category Developer
422
		 */
423
		$tplconf = 'admin/jqadm/cms/content/template-item';
424
		$default = 'cms/item-content-standard';
425
426
		return $view->render( $view->config( $tplconf, $default ) );
427
	}
428
}
429