Execute current command on given resource.

@param ApiResourceInterface $resource

@return bool|mixed
190274
protected function executeOn(ApiResourceInterface $resource)
    {
        $response = $this->execute($resource);

        if (method_exists($this, 'handleResponse')) {
            return $this->handleResponse($response, $resource);
        }

        return true;
    }
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;
    }
858575
public static function fromResource(Resource $resource)
    {
        if (!is_subclass_of($resource->model_class, Medools\Model::class)) {
            $message = 'Invalid Resource model_class in ' . static::class . ': '
                . $resource->model_class;
            throw new \LogicException($message);
        }

        $controller = new static;

        $list = $resource->getList();
        if (empty($list)) {
            return false;
        }

        foreach ($list as $id) {
            if (!$controller->generate($id)) {
                return false;
            }
        }

        if ($resource->content_type === 'application/zip') {
            $controller->zip();
        } else {
            $controller->output();
        }

        return true;
    }
776083
public function execute($resource = null, array $files = array())
    {
        $this->populateCDNResources();

        $urls = [];
        foreach ($files as $file) {
            $urls[] = '/' . urlencode($file);
        }

        $cdnResources = array_filter($this->cdnResources, function($value, $key) use ($resource) {
            return $value['cname'] == $resource;
        }, ARRAY_FILTER_USE_BOTH);

        foreach ($cdnResources as $cdnResource) {
            $this->client->post($this->url, [
                'form_params' => [
                    'cdn_id' => $cdnResource['id'],
                    'login' => $this->login,
                    'passwd' => $this->password,
                    'url' => $urls
                ]
            ]);
        }

        return;
    }
170255
public function execute(ServerRequestInterface $request, ResponseInterface $response) : ResponseInterface {
		$httpRequestResponse = new HTTPRequestResponseContainer($request, $response);

		$this->dispatchRequestFilters($httpRequestResponse);

		$this->dispatchResponseFilters($httpRequestResponse);

		return $httpRequestResponse->getResponse();
	}
1190487
protected function createReader(ResourceInterface $resource)
    {
        try {
            $jsonFile = $resource->getFile()->getPathname();

            $this->fileObject = new \SplFileObject($jsonFile);
        } catch (EmptyResponseException $e) {
            // getting an empty response is not a problem for jsonlines files, this
            // just means that there are no records.
            $this->fileObject = new \ArrayIterator();
        }
    }
109960
public function deleteAction( $resource )
	{
		$response = $this->createAdmin( $resource )->delete( $this->getPsrRequest(), new Response() );
		return $this->setPsrResponse( $response );
	}
410795
public function setResource(ResourceInterface $resource = null)
    {
        $this->resource = $resource;

        // Clear urls
        $this->urls = null;

        return $this;
    }
209652
public function get(string $resource): Promise {
        return call(function () use ($resource) {
            $uri = yield $this->getResourceUri($resource);

            $this->logger->debug('Requesting {uri} via GET', [
                'uri' => $uri,
            ]);

            try {
                /** @var Response $response */
                $response = yield $this->http->request($uri);

                // We just buffer the body here, so no further I/O will happen once this method's promise resolves.
                $body = yield $response->getBody();

                $this->logger->debug('Request for {uri} via GET has been processed with status {status}: {body}', [
                    'uri' => $uri,
                    'status' => $response->getStatus(),
                    'body' => $body
                ]);

                $this->saveNonce($response);
            } catch (Throwable $e) {
                throw new AcmeException("GET request to {$uri} failed: " . $e->getMessage(), null, $e);
            } catch (Exception $e) {
                throw new AcmeException("GET request to {$uri} failed: " . $e->getMessage(), null, $e);
            }

            return $response;
        });
    }
1260613
protected function execute(InputInterface $input, OutputInterface $output) {
		$action = $input->getArgument('action');
		if (!is_callable([ $this, $action ])) {
			$output->writeln('<error>Please specify a valid action: start/stop/status</error>');
			return 1;
		}
		return $this->$action($input, $output);
	}
1014420
public function create($name, HttpResourceInterface $resource)
    {
        $this->client->create(
            $this->capabilities->get($name)->getUrl(),
            $resource
        );

        return $this;
    }
1162319
public function load(string $resource, string $type = null) : RepositoryInterface
    {
        $resourceContent = $resource;

        if (empty($type)) {
            $file = $this->getLocation($resource);
            $resourceContent = $this->readFile($file);
        }

        $parsedResource = $this->parseJson($resourceContent);
        $errorMsg = $this->getLastErrorMessage(json_last_error());

        if ($errorMsg) {
            $msg = $type ? sprintf('JSON parse error: %s.', $errorMsg) : sprintf('JSON parse error: %s at %s', $errorMsg, $resource);

            throw new \RuntimeException($msg);
        }

        $repository = new Repository($parsedResource ?? []);

        return $this->parseImports($repository, $resource);
    }
622206
public function get($resource)
    {
        if (!array_key_exists($resource, $this->resources)) {
            throw new \InvalidArgumentException(sprintf('This resource "%s" does not exist.', $resource));
        }

        $class = $this->resources[$resource];

        return new $class($this->client);
    }
912232
public function put($resource, $data = [])
    {
        $exec = $this->execute(Method::$HTTP_PUT, $resource, ['json' => $data]);

        return $exec;
    }
1204688
public function requestUrl(ApiResourceInterface $resource)
    {
        $resourcePath = $this->resourcePath().'/'.$this->getResourceId();

        return $resource->apiUrl($resourcePath);
    }
526488
public function checkResource($resource)
    {
        $resource =
            $resource instanceof Resource
                ? $resource
                : $this->getResourceBySlug($resource);

        $checked = $this->cache->remember($resource->slug, function () use (
            $resource
        ) {
            return $resource->check($this->getCurrentAction());
        });

        $resource->targets = $checked->targets;

        return $resource;
    }
342460
public function post($resource, $data = [])
    {
        $exec = $this->execute(Method::$HTTP_POST, $resource, ['json' => $data]);

        return $exec;
    }