Completed
Push — develop ( de7659...415144 )
by Daniel
09:44
created

load_items::execute()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 6
Bugs 1 Features 1
Metric Value
c 6
b 1
f 1
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 9.0856
cc 3
eloc 10
nc 3
nop 0
crap 3
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2013 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\sitemaker\services\menus\action;
11
12
class load_items extends base_action
13
{
14
	/**
15
	 * {@inheritdoc}
16
	 * @throws \blitze\sitemaker\exception\out_of_bounds
17
	 */
18 4
	public function execute()
19
	{
20 4
		$menu_id = $this->request->variable('menu_id', 0);
21
22
		if ($menu_id)
23 4
		{
24 3
			$menu_mapper = $this->mapper_factory->create('menus', 'menus');
25
26
			/** @type \blitze\sitemaker\model\menus\entity\menu $entity */
27 3
			if (($entity = $menu_mapper->load(array('menu_id', '=', $menu_id))) === null)
28 3
			{
29 1
				throw new \blitze\sitemaker\exception\out_of_bounds('MENU_NOT_FOUND');
30
			}
31
32 2
			$collection = $entity->get_items();
33
34 2
			return $this->get_items($collection);
35
		}
36
37
		return array(
38 1
			'items' => array()
39 1
		);
40
	}
41
}
42