protected function checkLock($createOnMiss = true)
	{
		$this->isPostRequest();

		$user = $this->getCurrentUser();

		if (! $user) {
			return;
		}

		$localization = $this->getPageLocalization();

		if ($localization->isLocked()) {

			$lock = $localization->getLock();
			
			if ($lock->getUserName() !== $user->getUsername()) {
				throw new ObjectLockedException('page.error.page_locked', 'Page is locked by another user');
			} else {

				$entityManager = $this->getEntityManager();

//				if ( ! $this->lockTransactionOpened) {
//					$entityManager->beginTransaction();
//
//					$this->lockTransactionOpened = true;
//				}
				
//				$entityManager->lock($lock, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ);

				$lock->setModificationTime(new \DateTime('now'));
				
				$entityManager->flush($lock);
			}
		} elseif ($createOnMiss) {

//			$entityManager = $this->getEntityManager();

//			if ( ! $this->lockTransactionOpened) {
//				$entityManager->beginTransaction();
//				$this->lockTransactionOpened = true;
//			}

			// Creates lock if doesn't exist
//			$entityManager->lock(
//					$this->createLock(),
//					\Doctrine\DBAL\LockMode::PESSIMISTIC_READ
//			);
		}
	}
protected function checkLock($createOnMiss = true)
	{
		$this->isPostRequest();

		$user = $this->getCurrentUser();

		if (! $user) {
			return;
		}

		$localization = $this->getPageLocalization();

		if ($localization->isLocked()) {

			$lock = $localization->getLock();
			
			if ($lock->getUserName() !== $user->getUsername()) {
				throw new ObjectLockedException('page.error.page_locked', 'Page is locked by another user');
			} else {

				$entityManager = $this->getEntityManager();

//				if ( ! $this->lockTransactionOpened) {
//					$entityManager->beginTransaction();
//
//					$this->lockTransactionOpened = true;
//				}
				
//				$entityManager->lock($lock, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ);

				$lock->setModificationTime(new \DateTime('now'));
				
				$entityManager->flush($lock);
			}
		} elseif ($createOnMiss) {

//			$entityManager = $this->getEntityManager();

//			if ( ! $this->lockTransactionOpened) {
//				$entityManager->beginTransaction();
//				$this->lockTransactionOpened = true;
//			}

			// Creates lock if doesn't exist
//			$entityManager->lock(
//					$this->createLock(),
//					\Doctrine\DBAL\LockMode::PESSIMISTIC_READ
//			);
		}
	}
protected function checkLock ( $ createOnMiss = true ) { $ this -> isPostRequest ( ) ; $ user = $ this -> getCurrentUser ( ) ; if ( ! $ user ) { return ; } $ localization = $ this -> getPageLocalization ( ) ; if ( $ localization -> isLocked ( ) ) { $ lock = $ localization -> getLock ( ) ; if ( $ lock -> getUserName ( ) !== $ user -> getUsername ( ) ) { throw new ObjectLockedException ( 'page.error.page_locked' , 'Page is locked by another user' ) ; } else { $ entityManager = $ this -> getEntityManager ( ) ; //				if ( ! $this->lockTransactionOpened) { //					$entityManager->beginTransaction(); // //					$this->lockTransactionOpened = true; //				} //				$entityManager->lock($lock, \Doctrine\DBAL\LockMode::PESSIMISTIC_READ); $ lock -> setModificationTime ( new \ DateTime ( 'now' ) ) ; $ entityManager -> flush ( $ lock ) ; } } elseif ( $ createOnMiss ) { //			$entityManager = $this->getEntityManager(); //			if ( ! $this->lockTransactionOpened) { //				$entityManager->beginTransaction(); //				$this->lockTransactionOpened = true; //			} // Creates lock if doesn't exist //			$entityManager->lock( //					$this->createLock(), //					\Doctrine\DBAL\LockMode::PESSIMISTIC_READ //			); } }
Checks, whether the page is locked by current user or not,
will throw an exception if no, and update lock modified time if yes.

@param bool $createOnMiss
@throws ObjectLockedException if page is locked by another user
@return void
Checks whether the page is locked by current user or not will throw an exception if no and update lock modified time if yes .