Conditions | 8 |
Paths | 14 |
Total Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Tests | 18 |
CRAP Score | 8 |
Changes | 0 |
1 | <?php |
||
27 | 8 | public function process() : ?string |
|
28 | { |
||
29 | 8 | $settingModel = new Model\Setting(); |
|
30 | 8 | $lastTable = $this->_registry->get('lastTable'); |
|
31 | 8 | $lastId = $this->_registry->get('lastId'); |
|
32 | 8 | $useKeywords = $this->_registry->get('useKeywords'); |
|
33 | 8 | $settingKeywords = $settingModel->get('keywords'); |
|
34 | 8 | $keywords = null; |
|
35 | |||
36 | /* find keywords */ |
||
37 | |||
38 | 8 | if ($useKeywords) |
|
39 | { |
||
40 | 1 | $keywords = $useKeywords; |
|
41 | } |
||
42 | 7 | else if ($lastTable && $lastId) |
|
43 | { |
||
44 | 5 | $content = Db::forTablePrefix($lastTable)->whereIdIs($lastId)->whereNull('access')->findOne(); |
|
45 | 5 | $keywords = $content->keywords; |
|
46 | |||
47 | /* handle parent */ |
||
48 | |||
49 | 5 | if (!$keywords) |
|
50 | { |
||
51 | 3 | $parentId = $content->category ? : $content->parent; |
|
52 | 3 | if ($parentId) |
|
53 | { |
||
54 | 2 | $parent = Db::forTablePrefix('categories')->whereIdIs($parentId)->whereNull('access')->findOne(); |
|
55 | 2 | $keywords = $parent->keywords; |
|
56 | } |
||
57 | } |
||
58 | } |
||
59 | |||
60 | /* handle keywords */ |
||
61 | |||
62 | 8 | return $keywords ? : $settingKeywords; |
|
63 | } |
||
64 | } |
||
65 |