本文整理匯總了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;
}