Passed
Push — 0.3.0 ( 0d73f1...9a02d7 )
by Anton
04:10
created

Page::init()   B

Complexity

Conditions 5
Paths 1

Size

Total Lines 21
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 21
rs 8.7624
cc 5
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace Modules\Entitizer\Dataset {
4
5
	use Modules\Entitizer, Modules\Settings;
6
7
	class Page extends Entitizer\Utils\Dataset {
8
9
		use Entitizer\Common\Page;
10
11
		# Init dataset
12
13
		protected function init() {
14
15
			$this->addHandler('active', function (array $data) {
16
17
				return (($data['visibility'] === VISIBILITY_PUBLISHED) && !$data['locked']);
18
			});
19
20
			$this->addHandler('link', function (array $data) {
21
22
				if ('' === $data['slug']) return '';
23
24
				return (INSTALL_PATH . '/' . $data['slug']);
25
			});
26
27
			$this->addHandler('canonical', function (array $data) {
28
29
				if ('' === $data['slug']) return '';
30
31
				return (Settings::get('system_url') . (($data['id'] !== 1) ? ('/' . $data['slug']) : ''));
32
			});
33
		}
34
	}
35
}
36