Check if a parameter exists in the resource properties

@param mixed $p Parameter
@param string $resourceName Resource name
@param mixed[] $resourceProperties Properties
@return boolean
331767
protected function isParameterExistsInResourceProperties($p, $resourceName = '', $resourceProperties)
	{
		// Reference
		if (isset($p['$ref'])) {
			$parameter = $this->resolveReference($p['$ref'])['target'];
		} else {
			$parameter = $p;
		}
		
		// Check if it's a resource property
		if (count($resourceProperties) > 0) {
			// Resource Id pattern
			$pattern = '/(\w+)Id$/';
			if (preg_match($pattern, $parameter['name'])) {
				$resourcePropertyToMatch = ucfirst(substr($parameter['name'], 0, strlen($parameter['name']) - 2));
				$snakeCaseResourcePropertyToMatch = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $resourcePropertyToMatch));
				foreach ($resourceProperties as $resourceProperty) {
					if ($resourceProperty['name'] == $snakeCaseResourcePropertyToMatch) {
						return true;
					}
				}
			}
		}
		
		// This resource Id ?
		
		// Resource Id pattern
		$pattern = '/(\w+)Id$/';
		
		if (preg_match($pattern, $parameter['name'])) {
			$resourcePropertyToMatch = ucfirst(substr($parameter['name'], 0, strlen($parameter['name']) - 2));
			if ($resourceName == $resourcePropertyToMatch) {
				return true;
			}
		}
		
		// This resource composite key or foreign key ?
		
		$snakeCaseParameterName = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $parameter['name']));
		foreach ($resourceProperties as $resourceProperty) {
			if ($resourceProperty['name'] == $snakeCaseParameterName) {
				return true;
			}
		}
		
		return false;
	}
450456
protected function resourceExists($resource)
    {
        /** @var \DreamFactory\Core\Contracts\ServiceResponseInterface $rs */
        $rs = ServiceManager::handleRequest($this->service->getName(), Verbs::GET, $resource);
        if ($rs->getStatusCode() === HttpStatusCodes::HTTP_NOT_FOUND) {
            return false;
        }

        return true;
    }
107045
public function hasResource($resource) {

		if(null !== $resource && false === is_string($resource)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($resource)), E_USER_ERROR);
		}

		return true === array_key_exists($resource, $this -> resources);
	}
922323
private function _checkRepositoryProperty()
    {
        if (!$this->repository) {
            if (Lang::has('resource-controller.propertynotset')) {
                $message = trans('resource-controller.propertynotset', ['property' => '$repository']);
            } else {
                $message = '$repository property must be set.';
            }

            throw new ResourceControllerException($message);
        }
    }
1193906
public function support(ResourceNode $resourceNode, string $actionName, string $method): bool
    {
        $action = $this->get($resourceNode, $actionName);

        if (empty($action) || !in_array($method, $action->getApi())) {
            return false;
        }

        return true;
    }
261478
public function can($permissions, $resourceName = null, $resourceId = null)
    {
        return $this->caller()->can($permissions, $resourceName, $resourceId);
    }
1209692
private function _checkResourceNameProperty()
    {
        if (!$this->resourceName) {
            if (Lang::has('resource-composer.propertynotset')) {
                $message = trans('resource-composer.propertynotset', ['property' => '$resourceName']);
            } else {
                $message = '$resourceName property must be set.';
            }

            throw new ResourceComposerException($message);
        }
    }
701902
protected function isPropertyEnabled(string $property/*, string $resourceClass*/): bool
    {
        if (\func_num_args() > 1) {
            $resourceClass = func_get_arg(1);
        } else {
            if (__CLASS__ !== \get_class($this)) {
                $r = new \ReflectionMethod($this, __FUNCTION__);
                if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
                    @trigger_error(sprintf('Method %s() will have a second `$resourceClass` argument in version API Platform 3.0. Not defining it is deprecated since API Platform 2.1.', __FUNCTION__), E_USER_DEPRECATED);
                }
            }
            $resourceClass = null;
        }

        if (null === $this->properties) {
            // to ensure sanity, nested properties must still be explicitly enabled
            return !$this->isPropertyNested($property, $resourceClass);
        }

        return \array_key_exists($property, $this->properties);
    }
1053379
private function existsParamTagWithArgument($parameters, ArgumentDescriptor $argument)
    {
        foreach ($parameters as $parameter) {
            if ($argument->getName() == $parameter->getVariableName()) {
                return true;
            }
        }

        return false;
    }
983856
private function getResourceParam(ResourceParam $resourceParam, array $query)
    {
        $uri = $resourceParam->templated === true ? uri_template($resourceParam->uri, $query) : $resourceParam->uri;
        $resource = $this->injector->getInstance(ResourceInterface::class);
        $resourceResult = $resource->get->uri($uri)->eager->request();
        $fragment = parse_url($uri, PHP_URL_FRAGMENT);

        return $resourceResult[$fragment];
    }
128803
public function publicKeyExists($publicKey) {
        $this->validatePublicKeyName($publicKey);

        return $this->resourceExists($this->getKeyUrl($publicKey));
    }
1101137
public function callMethod($resourceNamePlural, $methodName, $arguments = [])
    {
        $controller = $this->createController($resourceNamePlural);

        if (method_exists($controller, $methodName) == false) {
            throw new InvalidMethodException('The method ('.$methodName.') does not exist for the class '.get_class($controller));
        }
        return call_user_func_array([$controller, $methodName], $arguments);
    }
485620
public function isParameterSet($instanceName, $paramName) {
		return isset($this->declaredInstances[$instanceName]['fieldProperties'][$paramName]) || isset($this->declaredInstances[$instanceName]['fieldBinds'][$paramName]);
	}
276651
public static function deleteContact($resourceName=null, $optParams=[])
    {
        if (!$resourceName) {
            
            self::checkFind();

            $resourceName = self::$resourceName;
        }

        return self::getService()->people->deleteContact($resourceName, $optParams);
    }
526725
protected function hasNotBeenAdded(ResourceInterface $resource): bool
    {
        return isset($this->addedResources[$resource->getId()][$resource->getType()]) === false;
    }
1118154
public function resourceFor($resourceName)
    {
        $resourceConfig = $this->config->resourceConfigurationFor($resourceName);

        return $this->newResource($resourceConfig);
    }
1204582
public function hasPermission($permissionName, Subject $subject, Resource $resource = null, array $params = [])
    {
        return in_array($permissionName, $this->getPermissions($subject, $resource, $params));
    }