findAll on non object in extbase

大兔子大兔子 提交于 2019-12-13 07:40:39

问题


I just created an extension in typo3 4.5 with one model (product). I created the "productRepository" then injected it in the ProductController but I still get the

Call to a member function findAll() on a non-object

here is how the ProductController looks like :

/**
 * @var Tx_PiProductDetail_Domain_Repository_ProductRepository
 */
protected $productRepository;

/**
 * @param Tx_PiProductDetail_Domain_Repository_ProductRepository $productRepository
 * @return void
 */
public function injectProductRepository(Tx_PiProductDetail_Domain_Repository_ProductRepository $productRepository) {
    $this->productRepository = $productRepository;
}

/**
 * action list
 *
 * @return void
 */
public function listAction() {
    $products = $this->productRepository->findAll();
    $this->view->assign('products', $products);
}

and the ProductRepository :

class Tx_PiProductDetail_Domain_Repository_ProductRepository extends Tx_Extbase_Persistence_Repository { }

回答1:


This has something to do with the object and reflection caching in Extbase.

In TYPO3 4.5 you should truncate manually all cache related tables in your database. I guess the related tables for the Extbase object and reflection caching are cf_extbase_object, cf_extbase_object_tags, bcf_extbase_reflection and cf_extbase_reflection_tags but I'm not sure.

In TYPO3 4.5 you can avoid the problem while developing by adding this to your typo3conf/localconf.php:

$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection']['backend'] = 't3lib_cache_backend_NullBackend';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_object']['backend'] = 't3lib_cache_backend_NullBackend';


来源:https://stackoverflow.com/questions/30455040/findall-on-non-object-in-extbase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!