在extbase

时间:2015-05-26 09:46:24

标签: repository extbase findall typo3-4.5

我刚用typo3 4.5创建了一个扩展模型(产品)。我创建了“productRepository”,然后将它注入ProductController,但我仍然得到了

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

这是ProductController的外观:

/**
 * @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);
}

和ProductRepository:

class Tx_PiProductDetail_Domain_Repository_ProductRepository extends Tx_Extbase_Persistence_Repository { }

1 个答案:

答案 0 :(得分:1)

这与Extbase中的objectreflection caching有关。

TYPO3 4.5中,您应该truncate手动设置数据库中的所有cache个相关表。我猜Extbase对象和反射缓存的相关表是cf_extbase_objectcf_extbase_object_tagsbcf_extbase_reflectioncf_extbase_reflection_tags,但我不确定。

TYPO3 4.5中,您可以通过将此问题添加到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';