本文整理汇总了PHP中Doctrine\Common\Collections\ArrayCollection::setDirty方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayCollection::setDirty方法的具体用法?PHP ArrayCollection::setDirty怎么用?PHP ArrayCollection::setDirty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Collections\ArrayCollection
的用法示例。
在下文中一共展示了ArrayCollection::setDirty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVoteInfoAssignment
private function getVoteInfoAssignment(AbstractTerritoire $territoire)
{
// try to fetch from cache
if (isset($this->cache['voteInfo'][spl_object_hash($territoire)])) {
return $this->cache['voteInfo'][spl_object_hash($territoire)];
}
// if not in cache, not changed, so we dont mind fetching from db
if ($this->voteInfos instanceof PersistentCollection) {
$this->voteInfos->setDirty(false);
}
$criteria = Criteria::create()->where(Criteria::expr()->eq('territoire_id', $territoire->getId()));
$collection = $this->voteInfos->matching($criteria);
if ($this->voteInfos instanceof PersistentCollection) {
$this->voteInfos->setDirty(true);
}
// filter again if territoire_id were not initialized
$criteria = Criteria::create()->where(Criteria::expr()->eq('territoire', $territoire));
$array = array_values($collection->matching($criteria)->toArray());
if (array_key_exists(0, $array)) {
$voteInfoAssignment = $array[0];
}
// new one if not found
if (!isset($voteInfoAssignment)) {
$voteInfoAssignment = new VoteInfoAssignment($this, $territoire);
$this->voteInfos[] = $voteInfoAssignment;
}
// put to cache
$this->cache['voteInfo'][spl_object_hash($territoire)] = $voteInfoAssignment;
return $voteInfoAssignment;
}