public function lock($space, $key, $type) { if (!$this->driver->isTransactionRunning()) { $this->driver->beginTransaction(); register_shutdown_function(array($this, 'commit')); } // By loading the entity we create a shared lock. $entity = $this->loadEntity($space, $key, false); if ($entity === null) { $this->write($space, $key, null); $entity = $this->loadEntity($space, $key, false); } if ($type == self::EXCLUSIVE_LOCK) { // When we write the entity back to the database, we force that the // row is exclusivly locked. We need to write the whole entity (all fields) otherwise // we may lock only certain fields. $this->entityManager->persist($entity, false); } }
public function beginTransaction() { $this->driver->beginTransaction(); }