Page::init()   B
last analyzed

Complexity

Conditions 5
Paths 1

Size

Total Lines 21
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 8.7624
c 0
b 0
f 0
cc 5
eloc 9
nc 1
nop 0
1
<?php
2
3
/**
4
 * @package Cadmium\System\Modules\Entitizer
5
 * @author Anton Romanov
6
 * @copyright Copyright (c) 2015-2017, Anton Romanov
7
 * @link http://cadmium-cms.com
8
 */
9
10
namespace Modules\Entitizer\Dataset {
11
12
	use Modules\Entitizer, Modules\Settings;
13
14
	class Page extends Entitizer\Utils\Dataset {
15
16
		use Entitizer\Common\Page;
17
18
		/**
19
		 * Initialize the dataset
20
		 */
21
22
		protected function init() {
23
24
			$this->addVirtual('active', function (array $data) {
25
26
				return (($data['visibility'] === VISIBILITY_PUBLISHED) && !$data['locked']);
27
			});
28
29
			$this->addVirtual('link', function (array $data) {
30
31
				if ('' === $data['slug']) return '';
32
33
				return (INSTALL_PATH . '/' . $data['slug']);
34
			});
35
36
			$this->addVirtual('canonical', function (array $data) {
37
38
				if ('' === $data['slug']) return '';
39
40
				return (Settings::get('system_url') . (($data['id'] !== 1) ? ('/' . $data['slug']) : ''));
41
			});
42
		}
43
	}
44
}
45