Validate the resource

@param \BeatSwitch\Lock\Resources\Resource|null $resource
@return bool
196204
protected function matchesResource(Resource $resource = null)
    {
        // If the resource is null we should only return true if the current resource is also null.
        if ($resource === null) {
            return $this->getResource() === null || (
                $this->getResourceType() === null && $this->getResourceId() === null
            );
        }

        // If the permission's resource id is null then all resources with a specific ID are accepted.
        if ($this->getResourceId() === null) {
            return $this->getResourceType() === $resource->getResourceType();
        }

        // Otherwise make sure that we're matching a specific resource.
        return (
            $this->getResourceType() === $resource->getResourceType() &&
            $this->getResourceId() === $resource->getResourceId()
        );
    }
378210
public function hasFailedResource(ResourceNode $resource)
    {
        return !is_null($this->failedResourceIds) && in_array($resource->getId(), $this->failedResourceIds);
    }
107077
public function supports($resource, $type = null)
    {
        if (is_string($resource)) {
            if ($this->isFile($resource)) {
                return $this->validateExtension($resource);
            } else {
                return $this->isJson($resource);
            }
        }

        return false;
    }
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;
    }
693102
public function resolveLoader($resource)
    {
        foreach ($this->loaders as $loader) {
            if ($loader->supports($resource)) {
                return $loader;
            }
        }

        return null;
    }
962437
public function isAllowed(Lock $lock, $action, Resource $resource = null)
    {
        return $this->resolve($lock, $action, $resource);
    }
604985
public function isGranted($resource)
    {
        foreach ($this->roles as $role) {
            if (true === $role->hasResource($resource)) {
                return true;
            }
        }

        return false;
    }
311082
public function cannot($action, $resource = null, $resourceId = null)
    {
        return ! $this->can($action, $resource, $resourceId);
    }
876376
public function resolvePath($resource)
    {
        // Skip blank resources
        if (empty($resource)) {
            return null;
        }
        $resourceObj = $this->resolveResource($resource);
        if ($resourceObj instanceof ModuleResource) {
            return $resourceObj->getRelativePath();
        }
        return $resource;
    }
840041
public function validator($resource=null)
    {

        $resource = $this->passedOrCurrent($resource);

        if ($class = $this->mapper->validatorClass($resource)) {
            return $this->makeValidator($resource, $class);
        }

        $modelClass = class_basename($this->modelClass($resource));

        if ($class = $this->finder->validatorClass($resource, $modelClass)) {
            return $this->makeValidator($resource, $class);;
        }

        $class = 'Cmsable\Resource\GenericResourceValidator';

        if ($rules = $this->getManualRules($resource)) {
            $validator = $this->makeValidator($resource, $class);
            return $validator->setRules($rules);
        }

        // Support for rules inside forms
        if (!$this->hasForm($resource)) {
            throw new RuntimeException('No validator for resource $resource found');
        }


        if ($rules = $this->formRules($this->form(null, $resource))) {
             $validator = $this->makeValidator($resource, $class);
             return $validator->setRules($rules);

        }

        throw new RuntimeException('No validator for resource $resource found');

    }
1319432
protected boolean resourceIsValid(CmsResource resource) {

        if (!resource.getRootPath().startsWith(m_basePath)) {
            return false;
        }
        if (m_requireFile & resource.isFolder()) {
            return false;
        }
        if (m_requireFolder & resource.isFile()) {
            return false;
        }
        return true;
    }
317626
public function allows($resource = null, $privilege = null, $profile = null)
    {
        if($profile === null)
            $profile = auth()->guard('pulsar')->user()->profile_id_010;

        try
        {
            return parent::isAllowed($profile, $resource, $privilege);
        }
        catch(Exception\InvalidArgumentException $e)
        {
            return false;
        }
    }
1090184
protected function validate($connection = null)
	{
		$rules = $this->getRules();

        if (is_null($connection))
        {
            $validation = $this->getValidator($rules);
        }
        else {
            $vaidation = $this->getValidator($rules, $connection);
        }

		if ($validation->passes())
		{
			return true;
		}

		$this->errors = $validation->messages();

		return false;
	}
46540
public function remove( Resource $resource )
    {
        $cnt = 0;
        if( false !== $key = array_search( $resource, $this->instances, true ) ) {
            unset( $this->instances[$key] );
            $cnt++;
        }
        return $cnt;
    }
1177211
public function hasResource($resource)
    {
        if (!isset($this->resourcesCached[$resource])) {
            if (isset($this->resources[$resource])) {
                $this->resourcesCached[$resource] = $this->resources[$resource];
            } else {
                $found = false;
                foreach ($this->resources as $resourceName) {
                    $regex = str_replace(
                        array("\*", "\?"), // wildcard chars
                        array('.*', '.'),   // regexp chars
                        preg_quote($resourceName)
                    );

                    if (preg_match('/^' . $regex . '$/is', $resource)) {
                        $found = true;
                    }
                }

                $this->resourcesCached[$resource] = $found;
            }
        }

        return $this->resourcesCached[$resource];
    }
220009
public function load(FilesystemResource $resource)
    {

        if(!$this->validateExtension($resource)){
            return false;
        }

        return $this->transform($resource);
    }
419958
public function getActionsByResource($resource)
    {
        if (!isset($this->resources[$resource])) {
            return null; // no resource found
        }

        $actions = array();
        foreach ($this->resources[$resource] as $action => $path) {
            $actions[] = $action;
        }

        return $actions;
    }