@param resource $resource

@return bool
505500
protected function applyLock($resource)
    {
        if ($this->shouldLock === false) {
            $this->lockApplied = false;
            return flock($resource, LOCK_UN);
        }

        $lock = $this->shouldLock === true ? $this->getLockMode() : $this->shouldLock;


        if (!flock($resource, $lock)) {
            return false;
        }

        $this->lockApplied = true;

        return true;
    }
1253119
private function isIdElsewhere(Resource $res): bool {
        $revMatches = $this->reversePropertyUris($res);
        foreach ($revMatches as $prop) {
            if ($prop != RC::idProp()) {
                continue;
            }
            $matches = $this->resourcesMatching($prop, $res);
            foreach ($matches as $i) {
                if ($i->getUri() != $res->getUri()) {
                    return true;
                }
            }
        }
        return false;
    }
235957
public static function fromResource(Resource $resource)
    {
        if (isset($resource->query['with_billets'])) {
            return static::withBillets($resource);
        }
        return parent::fromResource($resource);
    }
378210
public function hasFailedResource(ResourceNode $resource)
    {
        return !is_null($this->failedResourceIds) && in_array($resource->getId(), $this->failedResourceIds);
    }
947131
public function hasSharedLock($resource = null): bool
    {
        if (null !== $resource) {
            return isset($this->sharedLock[$this->getResourceId($resource)]);
        }

        return !empty($this->sharedLock);
    }
109960
public function deleteAction( $resource )
	{
		$response = $this->createAdmin( $resource )->delete( $this->getPsrRequest(), new Response() );
		return $this->setPsrResponse( $response );
	}
538965
public function hasExclusiveLock($resource = null): bool
    {
        if (null !== $resource) {
            return $this->exclusiveLock === $this->getResourceId($resource);
        }

        return null !== $this->exclusiveLock;
    }
39669
protected function resolvePermissions($action, Resource $resource)
    {
        $permissions = $this->getPermissions();

        // Search for restrictions in the permissions. We'll do this first
        // because restrictions should override any privileges.
        if (! $this->resolveRestrictions($permissions, $action, $resource)) {
            return false;
        }

        // Check if one of the caller's roles has permission to do the action on the resource.
        foreach ($this->getLockInstancesForCallerRoles() as $roleLock) {
            if ($roleLock->can($action, $resource)) {
                return true;
            }
        }

        // If no restrictions are found, pass when a privilege is found on either the roles or caller.
        return $this->resolvePrivileges($permissions, $action, $resource);
    }
26752
public function tryResourceAssignation(DomainResource $resource)
    {
        if ($type = $this->matchType($resource)) {
            $this->resources[$type] = $resource;

            return true;
        }

        return false;
    }
1326718
public static boolean isValid(Resource resource) {
        return resource instanceof ResourceHandle
                ? ((ResourceHandle) resource).isValid()
                : resource != null && resource.getResourceResolver().getResource(resource.getPath()) != null;
    }
1119712
public function delete($resource)
    {
        $event = $this->createResourceEvent($resource);
        $this->dispatcher->dispatch($this->config->getEventName('pre_delete'), $event);

        if (!$event->isPropagationStopped()) {
            $this->removeResource($event);

            $this->dispatcher->dispatch($this->config->getEventName('post_delete'), $event);
        }

        return $event;
    }
795491
public final function resourceCheck(File $file) {
        if ($this->resourcePathMatch($file)) {
            if (is_null($this->getParentProject()->getResourceByFile($file)) && !is_null($resource = $this->resourceFactory($file))) {
                $this->getParentProject()->registerResource($resource);
            }
            return TRUE;
        } else {
            return FALSE;
        }
    }
366440
protected function hasError($resource)
    {
        // No error if no resource
        if (empty($resource)) {
            return false;
        }

        // If the error code is empty the statement / connection has not been run yet
        $code = $resource->errorCode();
        if (empty($code)) {
            return false;
        }

        // Skip 'ok' and undefined 'warning' types.
        // @see http://docstore.mik.ua/orelly/java-ent/jenut/ch08_06.htm
        return $code !== '00000' && $code !== '01000';
    }
69197
public function hasResource(ResourceInterface $otherResource) {
		if ($this->isEmpty()) {
			return false;
		}
		if ($this->type === RelationshipObject::TO_ONE) {
			return $this->resource->getResource()->equals($otherResource->getResource());
		}
		if ($this->type === RelationshipObject::TO_MANY) {
			foreach ($this->resources as $ownResource) {
				if ($ownResource->getResource()->equals($otherResource->getResource())) {
					return true;
				}
			}
		}
		
		return false;
	}
618873
public function deserialize($data, Resource $resource = null)
    {
        if (empty($resource)) {
            $resource = new Resource();
        }
        if (isset($data['resourceType']) && isset($data['resourceType']['name'])) {
            $resourceType = $this->resourceTypeRepo->findOneBy(['name' => $data['resourceType']['name']]);
            $resource->setResourceType($resourceType);
        }
        if (isset($data['name'])) {
            $resource->setName($data['name']);
        }
        if (isset($data['maxTimeReservation'])) {
            $resource->setMaxTimeReservation($data['maxTimeReservation']);
        }
        if (isset($data['description'])) {
            $resource->setDescription($data['description']);
        }
        if (isset($data['localization'])) {
            $resource->setLocalisation($data['localization']);
        }
        if (isset($data['quantity'])) {
            $resource->setQuantity($data['quantity']);
        }
        if (isset($data['color'])) {
            $resource->setColor($data['color']);
        }
        if (isset($data['organizations'])) {
            $this->deserializeOrganizations($resource, $data['organizations']);
        }

        return $resource;
    }
1356947
public function getInlcudeResources($resource)
    {
        switch ($resource) {
            case 'administrative_areas':
                return $this->administrativeAreas()->getQuery();
            case 'cities':
                return $this->cities()->getQuery()->select("ctrystore_cities.*");
        }
        return false;
    }
243278
protected function matchType(DomainResource $resource)
    {
        foreach ($this->getOperations() as $operation => $name) {
            if ($resource->type === $this->type . "_$operation") {
                return $operation;
            }
        }

        return false;
    }