43 $this->annotations = [];
44 $this->primary =
false;
45 $this->
transient=
false;
46 $this->manyToOne =
false;
52 if (\count($this->annotations) > 0) {
53 $annotationsStr =
"\n".$this->annotsEngine->getAnnotationsStr($this->annotations);
55 return $annotationsStr .
"\n\t{$this->access} $" . $this->name .
";\n";
59 if ($this->primary ===
false) {
60 $this->annotations[] = $this->annotsEngine->getAnnotation($this->container,
'id');
61 $this->primary =
true;
66 if ($this->
transient ===
false) {
67 $this->annotations[] = $this->annotsEngine->getAnnotation($this->container,
'transient');
68 $this->
transient =
true;
73 $annot = $this->annotsEngine->getAnnotation($this->container,
'column',[
'name'=>$this->name,
'dbType'=>$infos[
'Type'],
'nullable'=>(\strtolower($infos[
'Nullable']) ===
'yes')]);
74 $this->annotations[
'column'] = $annot;
78 $this->annotations[] = $this->annotsEngine->getAnnotation($this->container,
'manyToOne');
79 $joinColumn = $this->annotsEngine->getAnnotation($this->container,
'joinColumn',[
'name'=>
$name,
'className'=>$className,
'nullable'=>$nullable]);
80 $this->annotations[] = $joinColumn;
81 $this->manyToOne =
true;
85 $this->annotations[] = $this->annotsEngine->getAnnotation($this->container,
'oneToMany',[
'mappedBy'=>$mappedBy,
'className'=>$className]);;
89 $this->annotations[] = $this->annotsEngine->getAnnotation($this->container,
'transformer',[
'name'=>
$name]);;
100 if ($dbType ==
'datetime') {
133 return \in_array($this->name, $pwArray);
136 public function addManyToMany($targetEntity, $inversedBy, $joinTable, $joinColumns = [], $inverseJoinColumns = []) {
137 $manyToMany = $this->annotsEngine->getAnnotation($this->container,
'manyToMany',\compact(
'targetEntity',
'inversedBy'));
138 $jtArray[
'name'] = $joinTable;
139 if (\count($joinColumns) == 2) {
140 $jtArray[
'joinColumns'] = $joinColumns;
142 if (\count($inverseJoinColumns) == 2) {
143 $jtArray[
'inverseJoinColumns'] = $inverseJoinColumns;
145 $this->annotations[] = $manyToMany;
146 $this->annotations[] = $this->annotsEngine->getAnnotation($this->container,
'joinTable',$jtArray);
158 foreach ($this->annotations as $annotation) {
159 if ($this->annotsEngine->isManyToOne($annotation)) {
167 foreach ($this->annotations as $annotation) {
168 if ($this->annotsEngine->isOneToMany($annotation)) {
180 return $this->primary && DbTypes::isInt ( $this->
getDbType() );
184 $result =
"\n\tpublic function " . $this->
getGetterName() .
"(){\n";
185 $result .=
"\t\t" .
'return $this->' . $this->name .
";\n";
191 return 'get' . \ucfirst($this->name);
195 $result =
"\n\tpublic function " . $this->
getSetterName() .
'($' . $this->name .
"){\n";
196 $result .=
"\t\t" .
'$this->' . $this->name .
'=$' . $this->name .
";\n";
202 return 'set' . \ucfirst($this->name);
206 $name = \trim($this->name,
's');
208 $result .=
"\t\t" .
'$this->' . $this->name .
'[]=$' .
$name .
";\n";
214 $name = \trim($this->name,
's');
216 $mappedBy=$annot->mappedBy;
218 $result .=
"\t\t" .
'$this->' . $this->name .
'[]=$' .
$name .
";\n";
219 $result .=
"\t\t\$" .
$name .
'->set' .\ucfirst($mappedBy).
"(\$this);\n";
225 return 'add'.\ucfirst(\rtrim($this->name,
's'));
229 return 'addTo'.\ucfirst($this->name);
233 return \count($this->annotations) > 1;
237 foreach ($this->annotations as $annot) {
238 if ($this->annotsEngine->isMany($annot)) {
246 foreach ($this->annotations as $annot) {
247 if ($this->annotsEngine->isManyToMany($annot)) {
255 foreach ($this->annotations as $annot) {
256 if ($this->annotsEngine->isOneToMany($annot)) {
264 if (isset($this->annotations[
'column']))
265 return $this->annotations[
'column']->nullable;
270 if (isset($this->annotations[
'column']))
271 return $this->annotations[
'column']->dbType;
277 $validators = $parser->parse();
278 if ($validators && \count($validators)) {
279 $this->annotations = \array_merge($this->annotations, $validators);
299 $this->annotations=\array_merge($this->annotations,
$annotations);
getAddInManyToManyMember()
addManyToOne($name, $className, $nullable=false)
__construct($container, $annotsEngine, $name, $access='private')
setTransformer()
Try to set a transformer to the member.
getAddInOneToManyMember()
addOneToMany($mappedBy, $className)
addManyToMany($targetEntity, $inversedBy, $joinTable, $joinColumns=[], $inverseJoinColumns=[])
getInManyToManyMemberName()
getInOneToManyMemberName()
addAnnotations(array $annotations)
Ubiquity\annotations$AnnotationsInterface This class is part of Ubiquity.