Added <variableDefault> on generated class.
This allow to unset many-to-one and one-to-one relations Example: $user->setGroup(null);
This commit is contained in:
parent
e19fd756cb
commit
9c1202a766
@ -117,7 +117,7 @@ public function <methodName>()
|
|||||||
* @param <variableType>$<variableName>
|
* @param <variableType>$<variableName>
|
||||||
* @return <entity>
|
* @return <entity>
|
||||||
*/
|
*/
|
||||||
public function <methodName>(<methodTypeHint>$<variableName>)
|
public function <methodName>(<methodTypeHint>$<variableName><variableDefault>)
|
||||||
{
|
{
|
||||||
<spaces>$this-><fieldName> = $<variableName>;
|
<spaces>$this-><fieldName> = $<variableName>;
|
||||||
<spaces>return $this;
|
<spaces>return $this;
|
||||||
@ -634,7 +634,7 @@ public function <methodName>()
|
|||||||
|
|
||||||
foreach ($metadata->associationMappings as $associationMapping) {
|
foreach ($metadata->associationMappings as $associationMapping) {
|
||||||
if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) {
|
if ($associationMapping['type'] & ClassMetadataInfo::TO_ONE) {
|
||||||
if ($code = $this->_generateEntityStubMethod($metadata, 'set', $associationMapping['fieldName'], $associationMapping['targetEntity'])) {
|
if ($code = $this->_generateEntityStubMethod($metadata, 'set', $associationMapping['fieldName'], $associationMapping['targetEntity'], 'null')) {
|
||||||
$methods[] = $code;
|
$methods[] = $code;
|
||||||
}
|
}
|
||||||
if ($code = $this->_generateEntityStubMethod($metadata, 'get', $associationMapping['fieldName'], $associationMapping['targetEntity'])) {
|
if ($code = $this->_generateEntityStubMethod($metadata, 'get', $associationMapping['fieldName'], $associationMapping['targetEntity'])) {
|
||||||
@ -707,7 +707,7 @@ public function <methodName>()
|
|||||||
return implode("\n", $lines);
|
return implode("\n", $lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _generateEntityStubMethod(ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null)
|
private function _generateEntityStubMethod(ClassMetadataInfo $metadata, $type, $fieldName, $typeHint = null, $defaultValue = null)
|
||||||
{
|
{
|
||||||
if ($type == "add") {
|
if ($type == "add") {
|
||||||
$addMethod = explode("\\", $typeHint);
|
$addMethod = explode("\\", $typeHint);
|
||||||
@ -737,6 +737,7 @@ public function <methodName>()
|
|||||||
'<variableName>' => Inflector::camelize($fieldName),
|
'<variableName>' => Inflector::camelize($fieldName),
|
||||||
'<methodName>' => $methodName,
|
'<methodName>' => $methodName,
|
||||||
'<fieldName>' => $fieldName,
|
'<fieldName>' => $fieldName,
|
||||||
|
'<variableDefault>' => ($defaultValue!==null?('='.$defaultValue):''),
|
||||||
'<entity>' => $this->_getClassName($metadata)
|
'<entity>' => $this->_getClassName($metadata)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user