[TYPO3-mvc] Problems with lazy loading

Manfred Rutschmann manfred.rutschmann at revier.de
Thu Jun 10 10:27:08 CEST 2010


hi list,

two tables in the db:
tx_mretikett_domain_model_label
tx_mretikett_domain_model_theme

i create a new tx_mretikett_domain_model_label and save in
tx_mretikett_domain_model_label.theme the uid of a linked
tx_mretikett_domain_model_theme

In my model for the label i set this:
=======================================================================
=======================================================================
    /**
	 * @var
Tx_Extbase_Persistence_ObjectStorage<Tx_MrEtikett_Domain_Model_Theme>
	 * @lazy
     * 
     */
    Protected $theme;


public function __construct() {
	$this->theme = new Tx_Extbase_Persistence_ObjectStorage();
}


    /**
     *  Get the theme of the label
     *  @return
Tx_Extbase_Persistence_ObjectStorage<Tx_MrEtikett_Domain_Model_Theme>
     */
    public function getTheme() {
        return $this->theme;
    }

	
	/**
	 * Setter for the theme to this label
	 *
	 * @param Tx_Extbase_Persistence_ObjectStorage $theme An Object Storage of
related theme instances
	 * @return void
	 */
	public function setTheme(Tx_Extbase_Persistence_ObjectStorage $theme) {
		$this->theme = $theme;
	}   
=======================================================================
=======================================================================

so far so good. in fluid now i try to get the object from the theme when a
label ist display (in the list of all labels). In my labelController is
this index action:

=======================================================================
=======================================================================

    /**
     *
     * The index action. Displays a list of all available data.
     *
     * @return void
     *
     */
    Public Function indexAction() {
        // Setting module tool to true for the be menu
        $this->view->assign('modLabel', TRUE);
        // Setting the bepath
        $this->view->assign('backPath',
t3lib_extMgm::extRelPath('mr_etikett'));
        // get complete list of Labels
        $Labels = $this->labelRepository->findAll();
        // generate the list
        $this->view->assign('labels', $Labels);
    }
=======================================================================
=======================================================================


In fluid my template like this:


=======================================================================
=======================================================================

	<f:if condition="{labels}">
		<f:then>	
			<f:for each="{labels}" as="Label">
				<div class="labelbox">
					<h1>{Label.title}</h1>
					<div class="image">
						<mr:be.image src="uploads/tx_mretikett/{Label.image}" alt=""
width="100" />
	 
					</div>
					<div class="info">
						
						Thema: 
						<f:for each="{Label.Theme}" as="thema">
							{thema.title}
						</f:for>
					</div>
					<div class="options">
						<f:be.buttons.icon uri="{f:uri.action(action:'edit', controller:
'BeLabel', arguments:{Label: Label})}" icon="edit2" title="Etikett
bearbeiten" />		
						<f:be.buttons.icon uri="{f:uri.action(action:'delete', controller:
'BeLabel', arguments:{Label: Label})}" icon="deletedok" title="Etikett
löschen" />		
					</div>
				</div>
			</f:for>
				<div class="clear"></div>
		</f:then>

		<f:else>
			Keine Etiketten vorhanden.
		</f:else>
	
	</f:if>
=======================================================================
=======================================================================


On the part with 
<f:for each="{Label.Theme}" as="thema">
	{thema.title}
</f:for>

i get this execption:

=======================================================================
=======================================================================
Uncaught TYPO3 Exception
#1252502725: Could not determine type of relation for the property "theme".
This is mainly caused by a missing type declaration above the property
definition.

Tx_Extbase_Persistence_Exception thrown in file
C:\xampp170\htdocs\xxx\typo3\sysext\extbase\Classes\Persistence\Mapper\DataMapper.php
in line 363.

40
Tx_Extbase_Persistence_Mapper_DataMapper::getPreparedQuery(Tx_MrEtikett_Domain_Model_Label,
"theme", "3")


C:\xampp170\htdocs\xxx\typo3\sysext\extbase\Classes\Persistence\Mapper\DataMapper.php:

00330:  protected function
fetchRelatedEager(Tx_Extbase_DomainObject_DomainObjectInterface
$parentObject, $propertyName, $fieldValue = '') {
00331:   if ($fieldValue === '') return array();

00332:   $query = $this->getPreparedQuery($parentObject, $propertyName,
$fieldValue);

00333:   return $query->execute();
00334:  }


39
Tx_Extbase_Persistence_Mapper_DataMapper::fetchRelatedEager(Tx_MrEtikett_Domain_Model_Label,
"theme", "3")


C:\xampp170\htdocs\xxx\typo3\sysext\extbase\Classes\Persistence\Mapper\DataMapper.php:

00314:    }
00315:   } else {

00316:    $result = $this->fetchRelatedEager($parentObject, $propertyName,
$fieldValue);

00317:   }
00318:   return $result;
=======================================================================
=======================================================================

i take a look in the label objects and find some part to the theme:
Array
(
    [0] => Tx_MrEtikett_Domain_Model_Label Object
        (
            [title:protected] => Test 1
            [crdate:protected] => 
            [description:protected] => Test sw dd
            [image] => 4c1084b32f2d1.pdf
            [theme:protected] => Tx_Extbase_Persistence_LazyObjectStorage
Object
                (
                    [parentObject:protected] =>
Tx_MrEtikett_Domain_Model_Label Object
 *RECURSION*
                    [propertyName:protected] => theme
                    [fieldValue:protected] => 3
                    [isInitialized:protected] => 
                    [storage:protected] => Array
                        (
                        )

                )

the right uid trom the label.theme is in fieldValue, but all other
information of the object theme is missing.

Now im a little bit confused and no idea whats going wrong...

Thx Manfred


More information about the TYPO3-project-typo3v4mvc mailing list