[Flow] Reset model value for reference (set to null)
Steffen Wickham
steffen at gaming-inc.de
Sun May 12 15:51:52 CEST 2013
Hi Carsten,
thanks for your hint. At 2 a.m. my head isn't that clever. ;)
But that doesn't do the trick at all. I'd modified my RefereeAssignment
as follows:
/**
* The referee's position
*
* @var \AFSVN\Basic\Domain\Model\Position
* @ORM\ManyToOne
* @ORM\Column(nullable=true)
*/
protected $position;
/**
* Set the corresponding position for this assignment
*
* @param \AFSVN\Basic\Domain\Model\Position $positionReference
* @throws \Exception
* @return void
*/
public function setPosition( $positionReference ) {
if ( $positionReference === NULL || $positionReference
instanceof \AFSVN\Basic\Domain\Model\Position ) {
$this->position = $positionReference;
} else {
throw new \Exception('Position can only be an instance of
\AFSVN\Basic\Domain\Model\Position or NULL');
}
}
I had to remove the type hint within the parameter definition of the
setPosition() method (old code was: "public function setPosition(
\AFSVN\Basic\Domain\Model\Position $positionReference ) {" ) and do some
validation manually. Now i can add new positions or remove them as well.
Thank you!
Greetings,
Steffen
Am 12.05.2013 08:43, schrieb Carsten Bleicker:
> sorry, think there was an error:
> @ORM\Column(nullable=true)
>
> Column, not Columns
>
> Am 12.05.2013 um 08:34 schrieb Carsten Bleicker:
>
>> just an idea:
>>
>> /**
>> * @var \AFSVN\Basic\Domain\Model\Position
>> * @Flow\ManyToOne
>> * @ORM\Columns(nullable=true)
>> */
>> protected $position;
>>
>> /**
>> * @param \AFSVN\Basic\Domain\Model\Position $position
>> * @return void
>> */
>> setPosition(\AFSVN\Basic\Domain\Model\Position $position = null){}
>>
>>
>> run ./flow doctrine:update to build the nullable column.
>>
>>
>> hope it helps!
>> hit me if not :)
>>
>>
>> Am 12.05.2013 um 02:33 schrieb Steffen Wickham:
>>
>>> Hi guys,
>>>
>>> I know that this question had been already asked a long while ago, but
>>> honestly I can't find it in my mailinglist archive.
>>>
>>> I've got a ManyToOne relation in my model "RefereeAssignment" which
>>> refers to my model "Position". Under some circumstances a position
>>> reference has to be reset within RefereeAssignment. I'd tried to pass
>>> "NULL" to the repository but it crashes as expected with the following
>>> error:
>>> "Catchable Fatal Error: Argument 1 passed to
>>> AFSVN\Basic\Domain\Model\RefereeAssignment_Original::setPosition() must
>>> be an instance of AFSVN\Basic\Domain\Model\Position, null given, called
>>> in /[...]/AFSVN_Basic_Controller_MatchController.php on line 462 and
>>> defined in /[...]/AFSVN_Basic_Domain_Model_RefereeAssignment.php line 77"
>>>
>>> Does anybody remember how this could be archived or know how to solve it?
>>>
>>> Cheers,
>>> Steffen
>>> _______________________________________________
>>> Flow mailing list
>>> Flow at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
More information about the Flow
mailing list