summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateu Aguiló Bosch2017-12-24 09:02:12 (GMT)
committerMateu Aguiló Bosch2017-12-24 09:02:12 (GMT)
commit1ab44a5550c5558b72cd658ac6b7da97102e7097 (patch)
tree40075efd1a9ca33da857aa2ac16a31a8e8b0ee8e
parent4a01066e7c2dbbfe39bb4fde55b1f3b531b41f9c (diff)
fix(CodingStandards): use phpcb for coding standard issues
-rw-r--r--jsonapi_extras.module5
-rw-r--r--src/Entity/JsonapiResourceConfig.php3
-rw-r--r--src/EventSubscriber/JsonApiExtrasRouteAlterSubscriber.php2
-rw-r--r--src/Form/JsonapiResourceConfigForm.php4
-rw-r--r--src/JsonapiResourceConfigListBuilder.php12
-rw-r--r--src/Normalizer/FieldItemNormalizer.php2
-rw-r--r--src/Normalizer/SchemaFieldDefinitionNormalizer.php1
-rw-r--r--src/Normalizer/SchemataSchemaNormalizer.php2
-rw-r--r--src/Plugin/Validation/Constraint/DuplicateFieldConstraintValidator.php4
-rw-r--r--src/ResourceType/ConfigurableResourceTypeRepository.php2
-rw-r--r--tests/src/Functional/JsonExtrasApiFunctionalTest.php13
11 files changed, 28 insertions, 22 deletions
diff --git a/jsonapi_extras.module b/jsonapi_extras.module
index 830c631..f26e487 100644
--- a/jsonapi_extras.module
+++ b/jsonapi_extras.module
@@ -1,5 +1,10 @@
<?php
+/**
+ * @file
+ * Module implementation file.
+ */
+
use Drupal\Core\Routing\RouteMatchInterface;
/**
diff --git a/src/Entity/JsonapiResourceConfig.php b/src/Entity/JsonapiResourceConfig.php
index ec3f9e0..1f4e6bb 100644
--- a/src/Entity/JsonapiResourceConfig.php
+++ b/src/Entity/JsonapiResourceConfig.php
@@ -83,9 +83,10 @@ class JsonapiResourceConfig extends ConfigEntityBase {
*/
public function calculateDependencies() {
parent::calculateDependencies();
- $id = explode('--',$this->id);
+ $id = explode('--', $this->id);
$typeManager = $this->entityTypeManager();
$dependency = $typeManager->getDefinition($id[0])->getBundleConfigDependency($id[1]);
$this->addDependency($dependency['type'], $dependency['name']);
}
+
}
diff --git a/src/EventSubscriber/JsonApiExtrasRouteAlterSubscriber.php b/src/EventSubscriber/JsonApiExtrasRouteAlterSubscriber.php
index 45344ae..af53cec 100644
--- a/src/EventSubscriber/JsonApiExtrasRouteAlterSubscriber.php
+++ b/src/EventSubscriber/JsonApiExtrasRouteAlterSubscriber.php
@@ -58,7 +58,7 @@ class JsonApiExtrasRouteAlterSubscriber implements EventSubscriberInterface {
$collection->get('jsonapi.resource_list')
->setPath($path);
- /** @var ConfigurableResourceType $resource_type */
+ /** @var \Drupal\jsonapi_extras\ResourceType\ConfigurableResourceType $resource_type */
foreach ($this->resourceTypeRepository->all() as $resource_type) {
// Overwrite routes.
$paths = $this->getPathsForResourceType($resource_type, $prefix);
diff --git a/src/Form/JsonapiResourceConfigForm.php b/src/Form/JsonapiResourceConfigForm.php
index b6c2694..dc1f175 100644
--- a/src/Form/JsonapiResourceConfigForm.php
+++ b/src/Form/JsonapiResourceConfigForm.php
@@ -133,7 +133,7 @@ class JsonapiResourceConfigForm extends EntityForm {
$entity_type_id = $this->request->get('entity_type_id');
$bundle = $this->request->get('bundle');
- /** @var JsonapiResourceConfig $entity */
+ /** @var \Drupal\jsonapi_extras\Entity\JsonapiResourceConfig $entity */
$entity = $this->getEntity();
$resource_id = $entity->get('id');
// If we are editing an entity we don't want the Entity Type and Bundle
@@ -346,7 +346,7 @@ class JsonapiResourceConfigForm extends EntityForm {
* {@inheritdoc}
*/
public function buildEntity(array $form, FormStateInterface $form_state) {
- /** @var JsonapiResourceConfig $entity */
+ /** @var \Drupal\jsonapi_extras\Entity\JsonapiResourceConfig $entity */
$entity = parent::buildEntity($form, $form_state);
// Trim slashes from path.
diff --git a/src/JsonapiResourceConfigListBuilder.php b/src/JsonapiResourceConfigListBuilder.php
index 6f46f92..12e89ca 100644
--- a/src/JsonapiResourceConfigListBuilder.php
+++ b/src/JsonapiResourceConfigListBuilder.php
@@ -4,11 +4,8 @@ namespace Drupal\jsonapi_extras;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Config\ImmutableConfig;
-use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface;
-use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeInterface;
-use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Url;
use Drupal\jsonapi_extras\ResourceType\ConfigurableResourceTypeRepository;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -35,7 +32,7 @@ class JsonapiResourceConfigListBuilder extends ConfigEntityListBuilder {
/**
* Constructs new JsonapiResourceConfigListBuilder.
*
- * @param EntityTypeInterface $entity_type
+ * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* @param \Drupal\jsonapi_extras\ResourceType\ConfigurableResourceTypeRepository $resource_type_repository
@@ -112,7 +109,7 @@ class JsonapiResourceConfigListBuilder extends ConfigEntityListBuilder {
],
'#attached' => [
'library' => [
- 'jsonapi_extras/admin'
+ 'jsonapi_extras/admin',
],
],
];
@@ -130,13 +127,13 @@ class JsonapiResourceConfigListBuilder extends ConfigEntityListBuilder {
],
'#attributes' => [
'class' => [
- 'jsonapi-resources-table'
+ 'jsonapi-resources-table',
],
],
'#attached' => [
'library' => [
'jsonapi_extras/admin',
- ]
+ ],
],
];
}
@@ -216,5 +213,4 @@ class JsonapiResourceConfigListBuilder extends ConfigEntityListBuilder {
return $list;
}
-
}
diff --git a/src/Normalizer/FieldItemNormalizer.php b/src/Normalizer/FieldItemNormalizer.php
index b95e298..b13eed9 100644
--- a/src/Normalizer/FieldItemNormalizer.php
+++ b/src/Normalizer/FieldItemNormalizer.php
@@ -61,7 +61,7 @@ class FieldItemNormalizer extends NormalizerBase {
/**
* {@inheritdoc}
*/
- public function normalize($object, $format = NULL, array $context = array()) {
+ public function normalize($object, $format = NULL, array $context = []) {
// First get the regular output.
$normalized_output = $this->subject->normalize($object, $format, $context);
// Then detect if there is any enhancer to be applied here.
diff --git a/src/Normalizer/SchemaFieldDefinitionNormalizer.php b/src/Normalizer/SchemaFieldDefinitionNormalizer.php
index 3a32be3..c83b2e1 100644
--- a/src/Normalizer/SchemaFieldDefinitionNormalizer.php
+++ b/src/Normalizer/SchemaFieldDefinitionNormalizer.php
@@ -2,7 +2,6 @@
namespace Drupal\jsonapi_extras\Normalizer;
-use Drupal\Component\Utility\NestedArray;
use Drupal\jsonapi_extras\ResourceType\ConfigurableResourceType;
use Drupal\schemata_json_schema\Normalizer\jsonapi\FieldDefinitionNormalizer as SchemataJsonSchemaFieldDefinitionNormalizer;
use Drupal\jsonapi\ResourceType\ResourceTypeRepository;
diff --git a/src/Normalizer/SchemataSchemaNormalizer.php b/src/Normalizer/SchemataSchemaNormalizer.php
index 822adae..f697b9b 100644
--- a/src/Normalizer/SchemataSchemaNormalizer.php
+++ b/src/Normalizer/SchemataSchemaNormalizer.php
@@ -18,7 +18,7 @@ class SchemataSchemaNormalizer extends SchemataJsonSchemaSchemataSchemaNormalize
protected $resourceTypeRepository;
/**
- * @param ResourceTypeRepository $resource_type_repository
+ * @param \Drupal\jsonapi\ResourceType\ResourceTypeRepository $resource_type_repository
* A resource repository.
*/
public function __construct(ResourceTypeRepository $resource_type_repository) {
diff --git a/src/Plugin/Validation/Constraint/DuplicateFieldConstraintValidator.php b/src/Plugin/Validation/Constraint/DuplicateFieldConstraintValidator.php
index 45f5c96..c1032de 100644
--- a/src/Plugin/Validation/Constraint/DuplicateFieldConstraintValidator.php
+++ b/src/Plugin/Validation/Constraint/DuplicateFieldConstraintValidator.php
@@ -29,7 +29,7 @@ class DuplicateFieldConstraintValidator extends ConstraintValidator {
$resourceFields = $entity_data['resourceFields'];
$overrides = [];
- // Get the field values
+ // Get the field values.
foreach ($resourceFields as $field => $data) {
// Only get the overridden fields.
if ($data['fieldName'] != $data['publicName']) {
@@ -58,7 +58,7 @@ class DuplicateFieldConstraintValidator extends ConstraintValidator {
}
}
- // Validate URL and resource type
+ // Validate URL and resource type.
$resource_types = $this->entityTypeManager
->getStorage('jsonapi_resource_config')
->loadByProperties(['disabled' => FALSE]);
diff --git a/src/ResourceType/ConfigurableResourceTypeRepository.php b/src/ResourceType/ConfigurableResourceTypeRepository.php
index 321a821..ae8b1c4 100644
--- a/src/ResourceType/ConfigurableResourceTypeRepository.php
+++ b/src/ResourceType/ConfigurableResourceTypeRepository.php
@@ -30,7 +30,7 @@ class ConfigurableResourceTypeRepository extends ResourceTypeRepository {
protected $enhancerManager;
/**
- * @var ConfigFactoryInterface
+ * @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
diff --git a/tests/src/Functional/JsonExtrasApiFunctionalTest.php b/tests/src/Functional/JsonExtrasApiFunctionalTest.php
index 503c5fb..7e60cba 100644
--- a/tests/src/Functional/JsonExtrasApiFunctionalTest.php
+++ b/tests/src/Functional/JsonExtrasApiFunctionalTest.php
@@ -28,13 +28,18 @@ class JsonExtrasApiFunctionalTest extends JsonApiFunctionalTestBase {
parent::setUp();
$config = \Drupal::configFactory()->getEditable('jsonapi_extras.settings');
$config->set('path_prefix', 'api');
- $config->set('include_count', true);
+ $config->set('include_count', TRUE);
$config->save(TRUE);
$this->grantPermissions(Role::load(Role::ANONYMOUS_ID), ['access jsonapi resource list']);
static::overrideResources();
$this->resetAll();
}
+ /**
+ * {@inheritdoc}
+ *
+ * Appends the 'application/vnd.api+json' if there's no Accept header.
+ */
protected function drupalGet($path, array $options = [], array $headers = []) {
if (empty($headers['Accept']) && empty($headers['accept'])) {
$headers['Accept'] = 'application/vnd.api+json';
@@ -78,18 +83,18 @@ class JsonExtrasApiFunctionalTest extends JsonApiFunctionalTestBase {
$output = Json::decode($this->drupalGet('/api/articles/' . $this->nodes[1]->uuid()));
$this->assertArrayNotHasKey('uuid', $output['data']['attributes']);
- // 6. Test the field enhancers: DateTimeEnhancer
+ // 6. Test the field enhancers: DateTimeEnhancer.
$output = Json::decode($this->drupalGet('/api/articles/' . $this->nodes[2]->uuid()));
$timestamp = \DateTime::createFromFormat('Y-m-d\TH:i:sO', $output['data']['attributes']['createdAt'])
->format('U');
$this->assertSame((int) $timestamp, $this->nodes[2]->getCreatedTime());
- // 7. Test the field enhancers: UuidLinkEnhancer
+ // 7. Test the field enhancers: UuidLinkEnhancer.
$output = Json::decode($this->drupalGet('/api/articles/' . $this->nodes[3]->uuid()));
$expected_link = 'entity:node/article/' . $this->nodes[2]->uuid();
$this->assertSame($expected_link, $output['data']['attributes']['link']['uri']);
- // 8. Test the field enhancers: SingleNestedEnhancer
+ // 8. Test the field enhancers: SingleNestedEnhancer.
$output = Json::decode($this->drupalGet('/api/articles/' . $this->nodes[3]->uuid()));
$this->assertInternalType('string', $output['data']['attributes']['body']);
}