public function cleanUp() { $maxEndtime = Customweb_Core_Util_System::getScriptExecutionEndTime() - 4; // Remove all contexts which are not changed in the last 2 days and the state is not completed. $where = 'updatedOn < NOW() - INTERVAL 2 DAY AND state != "completed" LIMIT 0,40'; $entities = $this->entityManager->search($this->contextEntityName, $where); foreach ($entities as $entity) { if ($maxEndtime > time()) { $this->entityManager->remove($entity); } else { break; } } }
public function remove($space, $key) { $entity = $this->loadEntity($space, $key); if ($entity !== null) { $this->entityManager->remove($entity); } }