protected function getCachedCollection()
{
if ($this->collection !== null) {
return $this->collection;
} elseif ($this->parent->getPreloadContainer()) {
$key = spl_object_hash($this->parent->getPreloadContainer()) . '_' . $this->metadata->name;
$cache = $this->parent->getRepository()->getMapper()->getCollectionCache();
if (!isset($cache->{$key})) {
$cache->{$key} = $this->createCollection();
}
$collection = $cache->{$key};
} else {
$collection = $this->createCollection();
}
return $this->collection = $collection;
}