-
Notifications
You must be signed in to change notification settings - Fork 390
/
ExtensionQueryInheritanceBuilder.php
145 lines (129 loc) · 3.67 KB
/
ExtensionQueryInheritanceBuilder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/**
* This file is part of the Propel package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
namespace Propel\Generator\Builder\Om;
use Propel\Generator\Model\Inheritance;
use Propel\Generator\Exception\BuildException;
/**
* Generates the empty PHP5 stub query class for use with single table inheritance.
*
* This class produces the empty stub class that can be customized with
* application business logic, custom behavior, etc.
*
* @author François Zaninotto
*/
class ExtensionQueryInheritanceBuilder extends AbstractOMBuilder
{
/**
* The current child "object" we are operating on.
*
*/
protected $child;
/**
* Returns the name of the current class being built.
*
* @return string
*/
public function getUnprefixedClassName()
{
return $this->getChild()->getClassName() . 'Query';
}
/**
* Gets the package for the [base] object classes.
*
* @return string
*/
public function getPackage()
{
return ($this->getChild()->getPackage() ? $this->getChild()->getPackage() : parent::getPackage());
}
/**
* Set the child object that we're operating on currently.
*
* @param Inheritance $child Inheritance
*/
public function setChild(Inheritance $child)
{
$this->child = $child;
}
/**
* Returns the child object we're operating on currently.
*
* @return Inheritance
* @throws BuildException
*/
public function getChild()
{
if (!$this->child) {
throw new BuildException("The MultiExtendObjectBuilder needs to be told which child class to build (via setChild() method) before it can build the stub class.");
}
return $this->child;
}
/**
* Adds class phpdoc comment and opening of class.
*
* @param string $script
*/
protected function addClassOpen(&$script)
{
$table = $this->getTable();
$tableName = $table->getName();
$tableDesc = $table->getDescription();
$baseBuilder = $this->getNewQueryInheritanceBuilder($this->getChild());
$baseClassName = $this->getClassNameFromBuilder($baseBuilder);
if ($this->getBuildProperty('generator.objectModel.addClassLevelComment')) {
$script .= "
/**
* Skeleton subclass for representing a query for one of the subclasses of the '$tableName' table.
*
* $tableDesc
*";
if ($this->getBuildProperty('generator.objectModel.addTimeStamp')) {
$now = strftime('%c');
$script .= "
* This class was autogenerated by Propel " . $this->getBuildProperty('general.version') . " on:
*
* $now
*";
}
$script .= "
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/";
}
$script .= "
class " .$this->getUnqualifiedClassName() . " extends " . $baseClassName . "
{
";
}
/**
* Specifies the methods that are added as part of the stub object class.
*
* By default there are no methods for the empty stub classes; override this method
* if you want to change that behavior.
*
* @param string $script
* @see ObjectBuilder::addClassBody()
*/
protected function addClassBody(&$script)
{
}
/**
* Closes class.
*
* @param string $script
*/
protected function addClassClose(&$script)
{
$script .= "
} // " . $this->getUnqualifiedClassName() . "
";
}
}