@EXT\Route(
"/claco/form/entries/lock/{locked}/switch",
name="claro_claco_form_entries_lock_switch",
options = {"expose"=true}
)

Switches lock of entries

@param int $locked

@return JsonResponse
974553
public function entriesLockSwitchAction($locked, Request $request)
    {
        $entries = $this->decodeIdsString($request, 'Claroline\ClacoFormBundle\Entity\Entry');
        $clacoForms = [];

        foreach ($entries as $entry) {
            $clacoForm = $entry->getClacoForm();
            $clacoFormId = $clacoForm->getId();

            if (!isset($clacoForms[$clacoFormId])) {
                $clacoForms[$clacoFormId] = $clacoForm;
            }
        }
        foreach ($clacoForms as $clacoForm) {
            $this->clacoFormManager->checkRight($clacoForm, 'ADMINISTRATE');
        }

        $updatedEntries = $this->clacoFormManager->switchEntriesLock($entries, 1 === intval($locked));
        $serializedEntries = [];

        foreach ($updatedEntries as $entry) {
            $serializedEntries[] = $this->entrySerializer->serialize($entry);
        }

        return new JsonResponse($serializedEntries, 200);
    }
764126
protected function serializeSwitch(DOMElement $switch)
	{
		// Use a specialized branch table if the minimum number of branches is reached
		if ($switch->hasAttribute('branch-key') && $this->hasMultipleCases($switch))
		{
			return $this->serializeHash($switch);
		}

		$php   = '';
		$if    = 'if';
		foreach ($this->xpath->query('case', $switch) as $case)
		{
			if ($case->hasAttribute('test'))
			{
				$php .= $if . '(' . $this->convertCondition($case->getAttribute('test')) . ')';
			}
			else
			{
				$php .= 'else';
			}

			$php .= '{' . $this->serializeChildren($case) . '}';
			$if   = 'elseif';
		}

		return $php;
	}
18820
private function getLockFile()
    {
        $composerFile = \Composer\Factory::getComposerFile();

        $lockFile = 'json' === pathinfo($composerFile, PATHINFO_EXTENSION)
            ? substr($composerFile, 0, -4) . 'lock'
            : $composerFile . '.lock';

        return new \Composer\Json\JsonFile($lockFile, null, $this->appIO);
    }
1072744
public function lockAction(Request $request)
    {
        // get request parameters
        $eid = (int) $request->get('eid');
        $language = $request->get('language');

        $elementService = $this->get('phlexible_element.element_service');
        $lockManager = $this->get('phlexible_element.element_lock_manager');

        $element = $elementService->findElement($eid);

        if ($lockManager->isLocked($element)) {
            return new ResultResponse(false, 'Element already locked.');
        } else {
            try {
                // try to lock the element
                $lockManager->lock($element, $this->getUser()->getId());

                return new ResultResponse(true, 'Lock aquired.');
            } catch (\Exception $e) {
                return new ResultResponse(false, $e->getMessage());
            }
        }
    }
594544
public function switchQueueEntries($first, $second)
    {
        $url = $this->buildUrl('switch', [
            'value'  => $first,
            'value2' => $second
        ]);
        $request = $this->guzzle->request('GET', $url);

        return json_decode($request->getBody(), true)['result'];
    }
891157
public function setLockMapping(array &$mapping) : void
    {
        if ($mapping['type'] !== 'int') {
            throw LockException::invalidLockFieldType($mapping['type']);
        }

        $this->isLockable = true;
        $this->lockField  = $mapping['fieldName'];
    }
66669
public function lock($operation)
    {
        if ((LOCK_NB & $operation) == LOCK_NB) {
            $this->lock = $operation - LOCK_NB;
        } else {
            $this->lock = $operation;
        }

        return $this;
    }
147773
public function updatelock($data) {
		if ($this->data()->ID && $this->data()->canEdit()) {
			$lock = $this->getEditingLocks($this->data(), true);
			$response = new stdClass();
			$response->status = 1;
			if ($lock != null && $lock['user'] != Member::currentUser()->Email) {
				// someone else has stolen it !
				$response->status = 0;
				$response->message = _t('WikiPage.LOCK_STOLEN', "Another user (" . $lock['user'] . ") has forcefully taken this lock");
			}
			return Convert::raw2json($response);
		}
	}
1081631
public function setLockMode($lockMode)
    {
        if (in_array($lockMode, array(LockMode::NONE, LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE), true)) {
            if ( ! $this->_em->getConnection()->isTransactionActive()) {
                throw TransactionRequiredException::transactionRequired();
            }
        }

        $this->setHint(self::HINT_LOCK_MODE, $lockMode);

        return $this;
    }
449836
public function lock($document, $lockMode)
    {
        $id = $this->uow->getDocumentIdentifier($document);
        $criteria = array('_id' => $this->class->getDatabaseIdentifierValue($id));
        $lockMapping = $this->class->fieldMappings[$this->class->lockField];
        $this->collection->update($criteria, array('$set' => array($lockMapping['name'] => $lockMode)));
        $this->class->reflFields[$this->class->lockField]->setValue($document, $lockMode);
    }
770215
public function lockTable($option = null)
	{
		if(empty($option))
		{
			return false;
		}
		else
		{
			$sql = 'lock table ';
			foreach($option as $tableName => $type)
			{
				$sql .= $tableName . ' ' . $type . ',';
			}
			return $this->execute(substr($sql, 0, -1));
		}
	}
1174855
public function lock($document, $lockMode, $lockVersion = null)
    {
        if ($this->getDocumentState($document) != self::STATE_MANAGED) {
            throw new \InvalidArgumentException("Document is not MANAGED.");
        }

        $documentName = get_class($document);
        $class = $this->dm->getClassMetadata($documentName);

        if ($lockMode == LockMode::OPTIMISTIC) {
            if ( ! $class->isVersioned) {
                throw LockException::notVersioned($documentName);
            }

            if ($lockVersion != null) {
                $documentVersion = $class->reflFields[$class->versionField]->getValue($document);
                if ($documentVersion != $lockVersion) {
                    throw LockException::lockFailedVersionMissmatch($document, $lockVersion, $documentVersion);
                }
            }
        } elseif (in_array($lockMode, array(LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE))) {
            $this->getDocumentPersister($class->name)->lock($document, $lockMode);
        }
    }
373866
public function commit($unlock = true)
    {
        if (empty($this->insertions) && empty($this->deletions)) {
            return null;
        }

        $this->lock();

        $data = '';

        rewind($this->handle);

        $data = trim(stream_get_contents($this->handle));

        if ($data !== '') {
            $data = unserialize($data);

            $this->data = $this->insertions + $data;

            $data = null;

            foreach ($this->deletions as $key => $value) {
                unset($this->data[$key]);
            }
        } else {
            $this->data = $this->insertions;
        }

        $this->insertions = array();
        $this->deletions = array();

        $this->write();

        if ($unlock) {
            flock($this->handle, LOCK_UN);
        }

        $this->iterator = new \ArrayIterator($this->data);
    }
789677
public function adminDesktopHomeLockChangeAction(Role $role, $locked)
    {
        $roleOptions = $this->roleManager->getRoleOptions($role);
        $details = $roleOptions->getDetails();
        $details['home_lock'] = ($locked === '1');
        $roleOptions->setDetails($details);
        $this->roleManager->persistRoleOptions($roleOptions);

        return new Response('success', 200);
    }
468917
public function release_lock(lock $lock) {
        $params = array('locktype' => $this->dblockid,
                        'token' => $lock->get_key());
        $result = $this->db->get_record_sql('SELECT pg_advisory_unlock(:locktype, :token) AS unlocked', $params);
        $result = $result->unlocked === 't';
        if ($result) {
            unset($this->openlocks[$lock->get_key()]);
        }
        return $result;
    }
855437
private function getLockHandler(FsDestination $destination)
    {
        if (false == isset($this->lockHandlers[$destination->getName()])) {
            $this->lockHandlers[$destination->getName()] = new LockHandler(
                $destination->getName(),
                $destination->getFileInfo()->getPath()
            );
        }

        return $this->lockHandlers[$destination->getName()];
    }
300038
public static function getLock($id) {

        $model = get_called_class();
        /* @var $t Record */
        $t = new $model;
        $select = DB::select($t->getTable())->where($t->getPkField(), $id)->lock()->setRecord($model);
        Event::trigger('record_before_select', [$t, $select]);
        $data = $select->find();
        return $data;
    }