[TYPO3-mvc] problems with a property in my model - all others are fine - property is of typeTx_Extbase_Persistence_LazyObjectStorage
Stephen Bungert
stephenbungert at yahoo.de
Wed Oct 31 20:20:02 CET 2012
I have a model that has several fields of type "inline".
It doesn't work in the frontend - backend is fine.
I know it finds the correct record - I have debugged the queries ExtBAse
makes and cann see that it finds the record, but using any property from the
record causes an error. For eyample, if I use {item.preview.title} in my
template I get the error:
Call to undefined method
Tx_Extbase_Persistence_LazyObjectStorage::getTitle()
I have lots of other similar properties to preview and they all work, but
preview doesn't.
here is the tca for my preview property:
====
'preview' => array(
'exclude' => 1,
'label' => $sbp2Label . 'preview',
'l10n_mode' => 'mergeIfNotBlank',
'config' => array(
'type' => 'inline',
'foreign_table' => 'tx_sbportfolio2_domain_model_image',
'foreign_field' => 'itempreview',
'minitems' => 0,
'maxitems' => 1,
'appearance' => array(
'collapse' => 0,
'levelLinksPosition' => 'top',
'showSynchronizationLink' => 1,
'showPossibleLocalizationRecords' => 1,
'showAllLocalizationLink' => 1,
'newRecordLinkAddTitle' => 1,
'expandSingle' => 1,
'newRecordLinkAddTitle' => 1,
'enabledControls' => array(
'info' => true,
'new' => true,
'dragdrop' => false,
'sort' => false,
'hide' => true,
'delete' => true,
),
),
),
),
====
in my model class I have defined prview like this:
====
/**
* An image to be used as a preview of the item.
*
* @var
Tx_Extbase_Persistence_ObjectStorage<Tx_SbPortfolio2_Domain_Model_Image>
* @lazy
*/
protected $preview;
====
in my classes initStorageObjects() methods I have the following line
====
$this->preview = new Tx_Extbase_Persistence_ObjectStorage();
====
My methods for getting and setting look like this:
====
/**
* Adds a preview Image
*
* @param Tx_SbPortfolio2_Domain_Model_Image $preview
* @return void
*/
public function addPreview(Tx_SbPortfolio2_Domain_Model_Image $preview) {
$this->preview->attach($preview);
}
/**
* Removes a preiew Image
*
* @param Tx_SbPortfolio2_Domain_Model_Image $previewToRemove The Image to
be removed
* @return void
*/
public function removePreview(Tx_SbPortfolio2_Domain_Model_Image
$previewToRemove) {
$this->preview->detach($previewToRemove);
}
/**
* Returns the preview
*
* @return
Tx_Extbase_Persistence_ObjectStorage<Tx_SbPortfolio2_Domain_Model_Image>
$preview
*/
public function getPreview() {
return $this->preview;
}
/**
* Sets the preview
*
* @param
Tx_Extbase_Persistence_ObjectStorage<Tx_SbPortfolio2_Domain_Model_Image>
$preview
* @return void
*/
public function setPreview(Tx_Extbase_Persistence_ObjectStorage $preview) {
$this->preview = $preview;
}
====
I think the problem is in my clas somewhere, I have recently changed the
code, and before it used to work in the FE:
Before get and set preview used to return and accept as an argument an
object of type Tx_SbPortfolio2_Domain_Model_Image, but now I have modified
it like my other properties to Tx_Extbase_Persistence_ObjectStorage.
Does anyone have any tips about how to solve this? Or see what I have done
wrong?
Thanks.
Stephen
More information about the TYPO3-project-typo3v4mvc
mailing list