Completed
Branch 0.2.1 (e70612)
by Anton
09:15
created

Page::implement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 8
rs 9.4286
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Modules\Entitizer\Entity {
4
5
	use Modules\Entitizer, Modules\Settings;
6
7
	class Page extends Entitizer\Utils\Entity {
8
9
		use Entitizer\Common\Page;
10
11
		# Get slug
12
13
		private function getSlug() {
14
15
			return implode('/', array_column($this->data['path'], 'name'));
16
		}
17
18
		# Get link
19
20
		private function getLink() {
21
22
			if (0 === $this->id) return '';
23
24
			return (INSTALL_PATH . '/' . $this->data['slug']);
25
		}
26
27
		# Get canonical
28
29
		private function getCanonical() {
30
31
			if (0 === $this->id) return '';
32
33
			return (Settings::get('system_url') . (($this->id !== 1) ? ('/' . $this->data['slug']) : ''));
34
		}
35
36
		# Implement entity
37
38
		protected function implement() {
39
40
			$this->data['slug'] = $this->getSlug();
41
42
			$this->data['link'] = $this->getLink();
43
44
			$this->data['canonical'] = $this->getCanonical();
45
		}
46
	}
47
}
48