I have got two (2) classes:
Person model class
<?php
class Person extends BaseDto
{
/**
* @var array|PostalAddress
*/
protected $postalAddresses = array();
/**
* @param array|PostalAddress $postalAddresses
*/
public function setPostalAddresses($postalAddresses)
{
$this->postalAddresses = $postalAddresses;
}
/**
* @return array|PostalAddress[]
*/
public function getPostalAddresses()
{
return $this->postalAddresses;
}
}
PostalAddress model class
<?php
class PostalAddress
{
/**
* @var string $privatePersonFirstName
*/
protected $privatePersonFirstName;
/**
* @var string $privatePersonName
*/
protected $privatePersonName;
/**
* @return string
*/
public function getPrivatePersonFirstName()
{
return $this->privatePersonFirstName;
}
/**
* @param string $privatePersonFirstName
*/
public function setPrivatePersonFirstName($privatePersonFirstName)
{
$this->privatePersonFirstName = $privatePersonFirstName;
}
/**
* @return string
*/
public function getPrivatePersonName()
{
return $this->privatePersonName;
}
/**
* @param string $privatePersonName
*/
public function setPrivatePersonName($privatePersonName)
{
$this->privatePersonName = $privatePersonName;
}
}
In the controller PostalAddressConroller I have got an action which creates the form to edit a single address.
I would like to make some fields editable only if certain conditions are met. Example: The organization fields on the address are only editable in case the person is of type private person and the address is of type employer.
To implement such a condition check, I would like to create a method on the PostalAddress model. But for this, It would require to have a reference back to the parent object inside the controller.
I would like to avoid to put all the logic inside the templates to keep the templates clean and easy to understand.
Is there support on extbase level for such back references?
In case I have to implement such a back reference myself: How do I prevent circular references in general (for example on object serialization)?
if($model->isAllowedProperty) { AddFieldToResultArrOrSimilar }- Xatenev