/** * Met les Infrastructures de la collection dans le InfrastructureStore * Vérifie si le Infrastructure était déjà storé, dans ce cas, remplace le Infrastructure concerné par celui du InfrastructureStore */ public function store() { $replaces = array(); foreach ($this as $offset => $infrastructure) { /** @var Infrastructure $infrastructure */ if (InfrastructureStore::exists($infrastructure->getId())) { $replaces[$offset] = $infrastructure; } else { InfrastructureStore::store($infrastructure); } } unset($offset); foreach ($replaces as $offset => $infrastructure) { $this->offsetSet($offset, InfrastructureStore::getById($infrastructure->getId())); } }