后处理记录的“非实时”版本

时间:2018-08-08 07:07:14

标签: typo3 extbase

我有一个相当复杂的扩展名,该扩展名大多数与extbase一起使用,但也使用»core tce«api来使版本控制/工作区进入循环,尤其是在提交某些前端表单时。

要基本了解这种表单提交会发生什么情况,下面是一个控制器(前端-Extbase)操作中的一些简化示例 a :< / p>

public function saveAction(Company $company):void
{
  // map the entity to a data array, in order
  // to use tcemain/datahandler
  // https://stackoverflow.com/questions/51395532/entity-to-datamap-array
  $data = $this->dataMapService->map($company);

  $cmd = [];
  $cmd[$this->getTableName($entity)][$entity->getUid()] = $data;


  $this->tce->start($cmd, [], $this->BE_USER);
  $this->tce->process_datamap();
}

这会触发所有必要的钩子,以便在»non-live«工作区中创建新版本。

但这当然不是故事的结局

这些“公司记录”需要更多注意,因此存在一个钩子,可以在保存(前端和后端) b 后对记录进行后处理:

通过这种方式包含:

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] =
'EXT:'.$_EXTKEY.'/Classes/Hooks/Hooks.php:Foo\\Bar\\Hooks\\Company';

在这里回调:

public function processDatamap_afterDatabaseOperations(
  $status,
  $table,
  $id,
  array &$fieldArray,
  \TYPO3\CMS\Core\DataHandling\DataHandler $parentObj
)
{
  // code to ignore other records…

  // trouble starts here
  $uid = $this->getUid($id, $status, $parentObj);

  $company = $this->companyRepository->findByUid($uid);
}

问题:

控制器 a 中的

$entity->getUid()产生给定记录的»live«版本的uid,在钩子 b中但是 sup>,$id是指记录的新创建/更新的»non-live«版本的uid。

$company = $this->companyRepository->findByUid($uid);
如果uid是»non-live«版本之一,并且后期处理失败,则

产生null

问题

如何使Extbase»查找«记录的真实版本以对其进行后处理?

0 个答案:

没有答案