Conditions | 3 |
Paths | 3 |
Total Lines | 25 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
18 | 4 | public function execute($style_id) |
|
19 | { |
||
20 | 4 | $block_id = $this->request->variable('id', 0); |
|
21 | 4 | $field = $this->request->variable('field', 'icon'); |
|
22 | |||
23 | $allowed_fields = array( |
||
24 | 4 | 'title' => $this->request->variable('title', '', true), |
|
25 | 4 | 'icon' => $this->request->variable('icon', ''), |
|
26 | 4 | ); |
|
27 | |||
28 | 4 | $block_mapper = $this->mapper_factory->create('blocks'); |
|
29 | |||
30 | 4 | if (($entity = $block_mapper->load(array('bid', '=', $block_id))) === null) |
|
31 | 4 | { |
|
32 | 1 | throw new \blitze\sitemaker\exception\out_of_bounds('bid'); |
|
33 | } |
||
34 | |||
35 | 3 | if (isset($allowed_fields[$field])) |
|
36 | 3 | { |
|
37 | 2 | $mutator = 'set_' . $field; |
|
38 | 2 | $entity->$mutator($allowed_fields[$field]); |
|
39 | 2 | $entity = $block_mapper->save($entity); |
|
40 | 2 | } |
|
41 | |||
42 | 3 | return $this->render_block($entity); |
|
43 | } |
||
45 |