2015-08-20 36 views
0

我有我的CommandController,我用它來定義一個調度程序任務清理我的回購數據。出於某種原因,這是行不通的。我也無法添加()一個新元素到我的$ itemRepository(在這個commandcontroller內)。任何想法我失蹤了?Extbase CommandController任務刪除回購

<?php 

namespace VENDX\Items\Command; 

use TYPO3\CMS\Core\Utility\GeneralUtility; 
use TYPO3\CMS\Extbase\Utility\DebuggerUtility; 


class TestCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController 
{ 
    /** 
* itemRepository 
* 
* @var \VENDX\Items\Domain\Repository\ItemRepository 
* @inject 
*/ 
protected $itemRepository; 

/** 
* @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager 
* @inject 
*/ 
protected $persistenceManager; 

/** 
* 
* @return void 
*/ 

public function repoDeleteCommand() { 

    $this->$itemRepository->removeAll(); 

} 


} 

?> 
+0

你有你的持久性是上下文設置?通常這可以很容易地通過'module.tx_yourext

+0

完成,它看起來不同:我在my_ext/Configuration/TypoScript/setup.txt中添加了'module.tx_items.persistence d4ny3l

回答

2

好吧,我解決了這個問題:

在我第一次嘗試,我試圖通過上面的符號來使用回購。但是我錯過了沒有'$'需要@回購,因爲命名空間已經用$ this定義。

格式錯誤:

public function repoDeleteCommand() { 

    $this->$itemRepository->removeAll(); 

} 

所以正確的格式是:

public function repoDeleteCommand() { 

    $this->itemRepository->removeAll(); 

}