|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ubiquity\scaffolding\creators; |
|
4
|
|
|
|
|
5
|
|
|
use Ubiquity\utils\base\UString; |
|
6
|
|
|
use Ubiquity\scaffolding\ScaffoldController; |
|
7
|
|
|
use Ubiquity\controllers\Startup; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Base class for class creation in scaffolding. |
|
11
|
|
|
* Ubiquity\scaffolding\creators$BaseControllerCreator |
|
12
|
|
|
* This class is part of Ubiquity |
|
13
|
|
|
* |
|
14
|
|
|
* @author jcheron <[email protected]> |
|
15
|
|
|
* @version 1.0.2 |
|
16
|
|
|
* |
|
17
|
|
|
*/ |
|
18
|
|
|
abstract class BaseControllerCreator { |
|
19
|
|
|
protected $controllerName; |
|
20
|
|
|
protected $routePath; |
|
21
|
|
|
protected $views; |
|
22
|
|
|
protected $controllerNS; |
|
23
|
|
|
protected $templateName; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* |
|
27
|
|
|
* @var ScaffoldController |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $scaffoldController; |
|
30
|
|
|
|
|
31
|
2 |
|
public function __construct($controllerName, $routePath, $views) { |
|
32
|
2 |
|
$this->controllerName = $controllerName; |
|
33
|
2 |
|
$this->routePath = $routePath; |
|
34
|
2 |
|
$this->views = $views; |
|
35
|
2 |
|
$this->controllerNS = Startup::getNS ( "controllers" ); |
|
36
|
2 |
|
} |
|
37
|
|
|
|
|
38
|
3 |
|
protected function addRoute(&$routePath) { |
|
39
|
3 |
|
if (! UString::startswith ( $routePath, "/" )) { |
|
40
|
2 |
|
$routePath = "/" . $routePath; |
|
41
|
|
|
} |
|
42
|
3 |
|
$routeName = $routePath; |
|
43
|
3 |
|
$routePath = "\n * @route(\"{$routePath}\",\"inherited\"=>true,\"automated\"=>true)"; |
|
44
|
3 |
|
return $routeName; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
abstract public function create(ScaffoldController $scaffoldController); |
|
48
|
|
|
|
|
49
|
|
|
abstract protected function addViews(&$uses, &$messages, &$classContent); |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* |
|
53
|
|
|
* @return mixed |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getTemplateName() { |
|
56
|
|
|
return $this->templateName; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* |
|
61
|
|
|
* @param mixed $templateName |
|
62
|
|
|
*/ |
|
63
|
|
|
public function setTemplateName($templateName) { |
|
64
|
|
|
$this->templateName = $templateName; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
|