Typo3 访问现有的 table 以使用它的数据
Typo3 accessing an existing table to consume data of it
我试图将现有的 table 集成到我的扩展中。问题是 table 的内容没有被接管。我用现有 table 的名称创建了一个新模型,并根据现有的列名命名了属性。我也实现了属性对应的getters和setters
现有table的名字是tx_institutsseminarverwaltung_domain_model_event.
在这种情况下我的失败是什么?只想从另一个扩展访问现有 table 的数据。
提前致谢。
更新:
我试过这个:
/**
* Protected Variable objectManager wird mit NULL initialisiert.
*
* @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
* @inject
*/
protected $objectManager = NULL;
和 listAction():
/**
* action list
*
* @return void
*/
public function listAction() {
echo "test";
$theRepository = $this->objectManager->get('\TYPO3\institutsseminarverwaltung\Domain\Repository\EventRepository');
$yourRecords = $theRepository->findAll();
$this->view->assign('events', $yourRecords);
}
但是没有返回结果。
您应该使用链接到此 table 的存储库。像这样:
$theRepository = $this->objectManager->get(\Your\VendorName\Domain\Repository\TheRepository::class);
$yourRecords = $theRepository->findAll();
您如何尝试 "consume" 或从您的扩展程序中的其他 table 访问数据?
你有现有的存储库吗table(也许已经有一个现有的存储库,你可以重复使用)?
见german typo3 board mapping existing tables and SO thread TYPO3 / How to make repository from existing table fe_users?
解决方案是:
$querySettings = $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings');
$querySettings->setRespectStoragePage(FALSE);
$theRepository = $this->objectManager->get('TYPO3\institutsseminarverwaltung\Domain\Repository\EventRepository');
$theRepository->setDefaultQuerySettings($querySettings);
$yourRecords = $theRepository->findAll();
$this->view->assign('events', $yourRecords);
我试图将现有的 table 集成到我的扩展中。问题是 table 的内容没有被接管。我用现有 table 的名称创建了一个新模型,并根据现有的列名命名了属性。我也实现了属性对应的getters和setters
现有table的名字是tx_institutsseminarverwaltung_domain_model_event.
在这种情况下我的失败是什么?只想从另一个扩展访问现有 table 的数据。
提前致谢。
更新:
我试过这个:
/**
* Protected Variable objectManager wird mit NULL initialisiert.
*
* @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
* @inject
*/
protected $objectManager = NULL;
和 listAction():
/**
* action list
*
* @return void
*/
public function listAction() {
echo "test";
$theRepository = $this->objectManager->get('\TYPO3\institutsseminarverwaltung\Domain\Repository\EventRepository');
$yourRecords = $theRepository->findAll();
$this->view->assign('events', $yourRecords);
}
但是没有返回结果。
您应该使用链接到此 table 的存储库。像这样:
$theRepository = $this->objectManager->get(\Your\VendorName\Domain\Repository\TheRepository::class);
$yourRecords = $theRepository->findAll();
您如何尝试 "consume" 或从您的扩展程序中的其他 table 访问数据?
你有现有的存储库吗table(也许已经有一个现有的存储库,你可以重复使用)?
见german typo3 board mapping existing tables and SO thread TYPO3 / How to make repository from existing table fe_users?
解决方案是:
$querySettings = $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings');
$querySettings->setRespectStoragePage(FALSE);
$theRepository = $this->objectManager->get('TYPO3\institutsseminarverwaltung\Domain\Repository\EventRepository');
$theRepository->setDefaultQuerySettings($querySettings);
$yourRecords = $theRepository->findAll();
$this->view->assign('events', $yourRecords);