Completed
Push — master ( 3b83d2...39a0ee )
by Aimeos
03:34
created

Index::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016
6
 * @package Admin
7
 * @subpackage JQAdm
8
 */
9
10
11
namespace Aimeos\Admin\JQAdm\Common\Decorator;
12
13
14
/**
15
 * Index rebuild decorator for JQAdm clients
16
 *
17
 * @package Admin
18
 * @subpackage JQAdm
19
 */
20
class Index extends Base
21
{
22
	/**
23
	 * Updates the index after deleting the item
24
	 *
25
	 * @return string|null admin output to display or null for redirecting to the list
26
	 */
27
	public function delete()
28
	{
29
		$result = $this->getClient()->delete();
30
31
		$ids = (array) $this->getView()->param( 'id' );
32
		\Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->deleteItems( $ids );
33
34
		return $result;
35
	}
36
37
38
	/**
39
	 * Rebuilds the index after saving the item
40
	 *
41
	 * @return string|null admin output to display or null for redirecting to the list
42
	 */
43
	public function save()
44
	{
45
		$result = $this->getClient()->save();
46
		$item = $this->getView()->item;
47
48
		if( $item->getId() !== null ) {
49
			\Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->saveItem( $item );
50
		}
51
52
		return $result;
53
	}
54
}
55