Check resource.

@return Result
1829
public function check()
    {
        foreach ($this->target->paths as $path) {
            if (! $this->getFilesystem()->isWritable($path)) {
                return $this->makeResult(
                    false,
                    sprintf($this->target->getErrorMessage(), $path)
                );
            }
        }

        return $this->makeHealthyResult();
    }
313354
public static function check()
    {
        if (Session::exists(static::resource('session'))) {
            return true;
        } elseif (Cookie::existe(static::resource('cookie'))) {
            $token = Cookie::get(static::resource('cookie'));

            $result = Query::from(config('auth.table'))
                ->where('rememberToken', '=', $token)
                ->get();

            if (count($result) > 0) {
                return true;
            }

            return false;
        }

        return false;
    }
886132
public function check()
    {
        if (!$this->isEnabled()) {
            return;
        }

        $host = $this->container->get('request_stack')->getCurrentRequest()->getHttpHost();
        $console = realpath($this->container->get('kernel')->getProjectDir().'/bin/console');
        $installed = filectime($console);
        $bundles = $this->parseComposer();
        $title = $this->container->getParameter('kunstmaan_admin.website_title');

        $jsonData = json_encode(array(
            'host' => $host,
            'installed' => $installed,
            'bundles' => $bundles,
            'project' => $title,
        ));

        try {
            $client = $this->getClient();
            $response = $client->post($this->webserviceUrl, ['body' => $jsonData]);
            $contents = $response->getBody()->getContents();
            $data = json_decode($contents);

            if (null === $data) {
                return false;
            }

            // Save the result in the cache to make sure we don't do the check too often
            $this->cache->save('version_check', $data, $this->cacheTimeframe);

            return $data;
        } catch (Exception $e) {
            // We did not receive valid json
            return false;
        }
    }
762476
protected function _actionCheck()
    {
        $actions = $this->config('actions');
        if (is_bool($actions)) {
            return $actions;
        }
        if (is_string($actions)) {
            $actions = [$actions];
        }
        if(count(array_filter(array_keys($actions), 'is_string')) > 0){
            $_actions = [];
            foreach($actions as $key=>$value){
                if(is_string($key)){
                    $_actions[] = $key;
                } else {
                    $_actions[] = $value;
                }
            }
            $actions = $_actions;
        }
        return in_array($this->request->action, $actions);
    }
996365
public static function check()
    {
        $route = isset($_GET['_framework_url_']) ? $_GET['_framework_url_'] : '';

        $out = config('maintenance.out', []);

        $out[] = config('panel.route', 'vinala');

        if (config('panel.setup', true)) {
            if (config('maintenance.enabled', false) && !in_array($route, $out)) {
                return static::$enabled = true;
            }
        }

        return static::$enabled = false;
    }
795440
public function isConnected()
    {
        try {
            return \is_resource($this->connection) && \ftp_rawlist($this->connection, $this->getRoot()) !== false;
        } catch (\ErrorException $e) {
            if (\strpos($e->getMessage(), 'ftp_rawlist') === false) {
                throw $e;
            }

            return false;
        }
    }
1188994
public function countUngenerated()
    {
        $query = $this->createQuery();
        $query->matching($query->logicalAnd($query->equals('resource', null), $query->equals('staticResource', null)));
        return $query->count();
    }
244932
public function check()
    {
        app('queue')->pushOn(
            $this->target->name,
            instantiate($this->target->testJob)
        );

        $worker = app('queue.worker');

        $connection = $this->target->connection
            ?: app('config')['queue.default'];

        $queue = app('config')->get(
            "queue.connections.{$connection}.queue",
            'default'
        );

        $worker->setCache(instantiate($this->target->cacheInstance)->driver());

        $worker->runNextJob($connection, $queue, $this->gatherWorkerOptions());

        return $this->makeResult(true);
    }
154953
public function valid()
    {
        if ($this->_resource === null && $this->_filename) {
            $this->_resource = fopen($this->_filename, $this->_mode);
        }
        return !!$this->_resource && is_resource($this->_resource);
    }
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()
        );
    }
280679
protected function _actionCheck()
    {
        $actions = $this->getConfig('actions');
        if (is_bool($actions)) {
            return $actions;
        }

        return in_array($this->request->getParam('action'), (array)$actions, true);
    }
872297
public boolean isValid() {
        if (valid == null) {
            valid = (this.resource != null);
            if (valid) {
                valid = (getResourceResolver().getResource(getPath()) != null);
            }
        }
        return valid;
    }
1035751
public function check()
    {
        if (class_exists($this->className)) {
            return [EnvironmentCheck::OK, 'Class ' . $this->className.' exists'];
        }
        return [EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist'];
    }
143324
public function check()
    {
        $result = true;

        // TODO This check tries only to connect to the database
        // But it would make sense to check
        //  a) insert, select, update, delete, etc. access
        //  a) a) Which access rights do i need? Topic hardening?
        try {
            $this->database->connect($this->database->getConfig());
        } catch (\Exception $e) {
            $result = false;
        }

        return $result;
    }
761792
public function check()
    {
    	$action = $this->request->param('action');
        $controller = $this->request->param('controller');
        $prefix = ($this->request->param('prefix') === false) ? '/' : $this->request->param('prefix');
        $plugin = ($this->request->param('plugin') === false) ? '' : $this->request->param('plugin');

        $plugin_prefix = (empty($plugin)) ? $prefix : $plugin . '.' . $prefix;
        if( isset($this->_authorized[$plugin_prefix][$controller]) &&
            in_array($action, $this->_authorized[$plugin_prefix][$controller]) ) return true;

        $user_id = $this->request->session()->read('Auth.User.id');
        $group_id = -1;
        if( isset($this->controllers['group']) ) {
            $User = TableRegistry::get($this->controllers['user']);
            $group_id = $User->get($user_id)->group_id;
        }

        $UserGroupPermission = TableRegistry::get('UserGroupPermission');
        $Permission = TableRegistry::get('Permission');

        $unique_string = $this->getUniqueString($controller, $action, $prefix, $plugin);
        $permission_id = $Permission->find()
            ->select(['id'])
            ->where(['unique_string' => $unique_string])->first();
        if( is_null($permission_id) ) return false;

        $allow = $UserGroupPermission->find()
            ->select(['allow'])
            ->where(
                [
                    'group_or_user'     => 'user',
                    'group_or_user_id'  => $user_id,

                ])
            ->orWhere(
                [
                    'group_or_user'     => 'group',
                    'group_or_user_id'  => $group_id
                ])->andWhere(['permission_id' => $permission_id->id])
            ->order(['allow'=>'DESC'])->first();
        if( is_null($allow) ) return false;

        return $allow->allow;
    }
332667
public function isValid() {
		if (is_resource($this->process)) {
			$status = proc_get_status($this->process);
			return $status['running'];
		} else {
			return false;
		}
	}
682440
public function check()
    {
        $urls = $this->getURLs();

        $chs = [];
        foreach ($urls as $url) {
            $ch = curl_init();
            $chs[] = $ch;
            curl_setopt_array($ch, $this->getCurlOpts($url));
        }
        // Parallel execution for faster performance
        $mh = curl_multi_init();
        foreach ($chs as $ch) {
            curl_multi_add_handle($mh, $ch);
        }

        $active = null;
        // Execute the handles
        do {
            $mrc = curl_multi_exec($mh, $active);
            curl_multi_select($mh);
        } while ($active > 0);

        while ($active && $mrc == CURLM_OK) {
            if (curl_multi_select($mh) != -1) {
                do {
                    $mrc = curl_multi_exec($mh, $active);
                } while ($mrc == CURLM_CALL_MULTI_PERFORM);
            }
        }

        $hasError = false;
        $msgs = [];
        foreach ($chs as $ch) {
            $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
            $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            if (curl_errno($ch) || $code >= 400) {
                $hasError = true;
                $msgs[] = sprintf(
                    'Error retrieving "%s": %s (Code: %s)',
                    $url,
                    curl_error($ch),
                    $code
                );
            } else {
                $msgs[] = sprintf(
                    'Success retrieving "%s" (Code: %s)',
                    $url,
                    $code
                );
            }
        }

        // Close the handles
        foreach ($chs as $ch) {
            curl_multi_remove_handle($mh, $ch);
        }
        curl_multi_close($mh);

        if ($hasError) {
            return [EnvironmentCheck::ERROR, implode(', ', $msgs)];
        }

        return [EnvironmentCheck::OK, implode(', ', $msgs)];
    }