typo3 流持续更新关系

typo3 flow persist updated relation

我在更新我的关系时遇到了 TYPO3 Flow 问题。 我错了吗,Flow 应该自动更新更改的关系,所以我不必用相应的存储库更新相关实体?

示例 1:
我有一个模型 "Project",在属性 "jobs" 上有多个 "Job" 个子项。 如果我这样做:

$project->setJobs($collectionOfJobs);
$this->projectRepository->update($project);

然后作业未使用新的项目 ID 正确更新。

示例 2:
我想实现模型 "Project" 和 "Briefing" 之间的双向一对一关系,发现 TYPO3 中存在一个已知错误:

所以我想通过手动设置另一侧的关系来修复它:

class Briefing {    

 /**
  * @param \Some\Package\Domain\Model\Project $project
  * @return void
  */
 public function setProject($project) {
   $this->project = $project;
   $this->project->setBriefing($this);
   $this->projectRepository->update($this->project); // FIXME: Bug? Flow should do this
 }

但我必须自己更新与其存储库的关系。 Flow 不应该自动执行此操作吗?

那么我真的需要用自己的存储库更新每个子项还是 Flow 应该为我做这件事?

环境:
- TYPO3 FLOW 2.3.3(最新稳定版)
- 学说 2.3.6
- PHP 5.4.39-0+deb7u2

来自Flow manual

When you add or remove an object to or from a repository, the object will be added to or removed from the underlying persistence as expected upon persistAll. But what about changes to already persisted objects? As we have seen, those changes are only persisted, if the changed object is given to update on the corresponding repository.

Now, for objects that have no corresponding repository, how are changes persisted? In the same way you fetch those objects from their parent - by traversal. TYPO3 Flow follows references from objects managed in a repository (aggregate roots) for all persistence operations, unless the referenced object itself is an aggregate root.

因此,如果您的实体有一个存储库,您必须明确调用更新方法。这本来是不同的,但是 changed for Flow 1.0.

也许您认为这应该有效,因为它在 TYPO3 CMS Extbase < 6.2 之前也有效,直到 changed there