[TYPO3-mvc] How to use the repository within a hook?

S.Korth s.korth at dms-arts.com
Wed Aug 11 14:21:51 CEST 2010


Hey all,

i try to get some data within a hook. But i only get an empty array.
What iam doing wrong? Is it possible?


The Hook:

<?php

/**
  * A datamap hook
  *
  * @version $Id:$
  * @copyright Copyright belongs to the respective authors
  * @license http://opensource.org/licenses/gpl-license.php GNU Public 
License, version 2
  */
class Tx_Recipes_Hook_Datamap {

   /**
    * @var Tx_Recipes_Domain_Repository_RecipeRepository
    */
     protected $recipeRepository = null;

   /**
    * Constructor
    */
   public function __construct() {
     t3lib_div::makeInstance('Tx_Extbase_Dispatcher');
     $this->recipeRepository = 
t3lib_div::makeInstance('Tx_Recipes_Domain_Repository_RecipeRepository');
   }

   /**
    * implements the hook processDatamap_afterDatabaseOperations that 
gets invoked
    * when a form in the backend was saved and written to the database.
    *
    * @param string $status
    * @param string $table
    * @param integer $id
    * @param array $fieldArray
    * @param t3lib_TCEmain $tce
    */
    public function processDatamap_afterDatabaseOperations($status, 
$table, $id, $fieldArray, $tce){
      if ($table == 'tx_recipes_domain_model_recipe') {
        if($status == 'new'){

          $recipe = 
t3lib_div::makeInstance('Tx_Recipes_Domain_Model_Recipe');

          var_dump($this->recipeRepository->findAll());

 
//print_r($this->recipeRepository->findByUid($tce->substNEWwithIDs[$id]));

          //$recipe = $this->recipes->findByUid($tce->substNEWwithIDs[$id]);

          //if(empty($recipe)){
          //  throw new InvalidArgumentException('Cant find any object.');
          //}
          //$recipe->setCode($tce->substNEWwithIDs[$id]);
        }
      }
    }

}
?>


More information about the TYPO3-project-typo3v4mvc mailing list