Skip to content
Snippets Groups Projects
Commit 75fe84fc authored by Adriano Cori's avatar Adriano Cori
Browse files

Code cleanup

parent 50ccdfb6
No related branches found
No related tags found
No related merge requests found
......@@ -79,23 +79,23 @@ class HttpConfigRequestForm extends EntityForm {
$commandName = $this->request->get('commandName');
$http_config_request = $this->entity;
$form['label'] = array(
$form['label'] = [
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#maxlength' => 255,
'#default_value' => $http_config_request->label(),
'#description' => $this->t("Label for the Http Config Request."),
'#required' => TRUE,
);
];
$form['id'] = array(
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $http_config_request->id(),
'#machine_name' => array(
'#machine_name' => [
'exists' => '\Drupal\http_client_manager\Entity\HttpConfigRequest::load',
),
],
'#disabled' => !$http_config_request->isNew(),
);
];
$form['service_api'] = [
'#type' => 'value',
......@@ -146,9 +146,9 @@ class HttpConfigRequestForm extends EntityForm {
}
// Show the token help.
$form['token_help'] = array(
$form['token_help'] = [
'#theme' => 'token_tree_link',
);
];
return $form;
}
......
......@@ -2,7 +2,6 @@
namespace Drupal\http_client_manager;
use Drupal\http_client_manager\Event\HttpClientEvents;
use Drupal\http_client_manager\Event\HttpClientHandlerStackEvent;
use Guzzle\Service\Loader\JsonLoader;
......
<?php
namespace Drupal\http_client_manager;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
......@@ -10,14 +11,15 @@ use Symfony\Component\DependencyInjection\ContainerAwareTrait;
* @package Drupal\http_client_manager
*/
class HttpClientManagerFactory implements HttpClientManagerFactoryInterface {
use ContainerAwareTrait;
/**
* An array of http clients.
* An array of HTTP Clients.
*
* @var array
*/
protected $clients = array();
protected $clients = [];
/**
* {@inheritdoc}
......
......@@ -98,7 +98,7 @@ class HttpConfigRequestListBuilder extends ConfigEntityListBuilder {
$operations = parent::getDefaultOperations($entity);
if ($entity->access('execute') && $entity->hasLinkTemplate('execute')) {
$operations['execute'] = array(
$operations['execute'] = [
'title' => $this->t('Execute'),
'weight' => 101,
'url' => Url::fromRoute('entity.http_config_request.execute', [
......@@ -106,7 +106,7 @@ class HttpConfigRequestListBuilder extends ConfigEntityListBuilder {
'serviceApi' => $entity->get('service_api'),
'commandName' => $entity->get('command_name'),
]),
);
];
}
return $operations;
......
......@@ -136,12 +136,10 @@ class HttpServiceApiHandler implements HttpServiceApiHandlerInterface {
/**
* Builds all services api provided by .http_services_api.yml files.
*
* @return array[]
* Each return api is an array with the following keys:
* Each service api is an array with the following keys:
* - id: The machine name of the Service Api.
* - title: The human-readable name of the API.
* - api_path: The Guzzle description path (relative to module directory).
* - base_url: The Service API base url.
* - provider: The provider module of the Service Api.
* - source: The absolute path to the Service API description file.
* - config: An array of additional configurations for the HttpClient class.
......@@ -150,16 +148,15 @@ class HttpServiceApiHandler implements HttpServiceApiHandlerInterface {
* example_service:
* title: "Example Service"
* api_path: src/HttpService/example_service.json
* base_url: "http://www.example.com/api/v1"
* config:
* command.params:
* command.request_options:
* timeout: 4
* connect_timeout: 3
* base_uri: "http://www.example.com/api/v1"
* timeout: 4
* connect_timeout: 3
* auth: ['username', 'secretPassword', 'Basic']
* @endcode
*/
protected function buildServicesApiYaml() {
$this->servicesApi = array();
$this->servicesApi = [];
$items = $this->getYamlDiscovery()->findAll();
foreach ($items as $provider => $servicesApi) {
......@@ -237,8 +234,7 @@ class HttpServiceApiHandler implements HttpServiceApiHandlerInterface {
* @param array $serviceApi
* An array of service api definition.
*
* @return bool
* Whether or not the api is valid.
* @throws \RuntimeException in case of invalid HTTP Service API definition.
*/
protected function validateServiceApiDefinition($id, array $serviceApi) {
foreach (self::getOverridableProperties() as $property => $isRequired) {
......@@ -261,7 +257,7 @@ class HttpServiceApiHandler implements HttpServiceApiHandlerInterface {
* Returns the human readable names of all modules keyed by machine name.
*/
protected function getModuleNames() {
$modules = array();
$modules = [];
foreach (array_keys($this->moduleHandler->getModuleList()) as $module) {
$modules[$module] = $this->moduleHandler->getName($module);
}
......
......@@ -2,7 +2,6 @@
namespace Drupal\http_client_manager\Plugin\HttpServiceApiWrapper;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Session\AccountProxyInterface;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment