Table::load_services()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
namespace phoponent\app\component\custom;
3
4
    use Exception;
5
    use phoponent\framework\loading\Auto;
6
    use phoponent\framework\service\translation;
7
8
	class Table extends \phoponent\app\component\core\Table {
9
10
        public static function load_services()
11
        {
12
            $dependies = Auto::dependencie('services');
13
            return [
14
                'translation' => $dependies['translation'],
15
                'json_reader' => $dependies['json_reader'],
16
            ];
17
        }
18
19
        /**
20
		 * @return string
21
		 * @throws Exception
22
		 */
23
		public function render():string {
24
			/**
25
			 * @var \phoponent\app\component\custom\Table\mvc\model\table $model
26
			 */
27
			$model = $this->get_model('table');
28
			$my_name = 'Nicolas';
29
			$json_datas = $model->get_datas_from_json($this->attribute('file'));
30
31
32
			$header_view = $model->genere_header(
33
				$json_datas,
34
				$this->get_view('tr'),
35
				$this->get_view('th')
36
			);
37
			$lines = $model->genere_body(
38
				$json_datas,
39
				$this->get_view('tr'),
40
				$this->get_view('td')
41
			);
42
            $table = $this->get_view('table')
43
						  ->set_vars([
44
						  	  'text_in_french' => translation::__($this->attribute('text_to_translate'), [$my_name], 'fr'),
45
						  	  'text_in_english' => translation::__($this->attribute('text_to_translate'), [$my_name]),
46
						 	  'header' => $header_view,
47
							  'lines' => $lines
48
						  ])->render();
49
50
            return $table;
51
        }
52
    }