Skip to content
Snippets Groups Projects
Unverified Commit 5b5511a0 authored by git's avatar git Committed by Mateu Aguiló Bosch
Browse files

Issue #3065906 by Sergiu Stici: Drupal best practices and coding standards

parent 5d670254
Branches
No related tags found
No related merge requests found
.advanced-opts {
display: none;
background-color: rgba(0, 0, 0, 0.05);
display: none;
background-color: rgba(0, 0, 0, 0.05);
}
.advanced-opts td:nth-child(2) {
font-weight: bold;
font-weight: bold;
}
.toggle-expanded span {
color: #000;
display: inline-block;
color: #000;
display: inline-block;
}
.toggle-expanded {
cursor: pointer;
cursor: pointer;
}
.toggle-expanded span:hover {
text-decoration: none;
text-decoration: none;
}
.toggle-expanded span::before {
margin-right: 0.3em;
margin-right: 0.3em;
}
.toggle-expanded.content-collapsed span::before {
content: "▸";
content: "▸";
}
.toggle-expanded.content-expanded span::before {
content: "▾";
content: "▾";
}
......@@ -49,6 +49,6 @@ function jsonapi_extras_theme() {
* - elements: An associative array containing a Form API structure to be
* rendered as a table.
*/
function template_preprocess_expandable_rows_table(&$variables) {
function template_preprocess_expandable_rows_table(array &$variables) {
template_preprocess_table($variables);
}
......@@ -2,14 +2,21 @@
JSON API Defaults
===================
The JSON API module provides zero configuration out of the box. Use JSON API Extras and Defaults to customize your API. JSON API Defaults provides default includes and filters (or any parameter) for resources. Use this module if you want your api client just use simple resource without any url parameters and still deliver all related objects.
The JSON API module provides zero configuration out of the box.
Use JSON API Extras and Defaults to customize your API.
JSON API Defaults provides default includes and filters (or any parameter)
for resources.
Use this module if you want your api client just use simple resource without
any url parameters and still deliver all related objects.
Here are the current features of the JSON API Defaults module:
- Default includes: if you apply default includes to a resource type, then collections of that
resource type will apply those includes when there is no include in the collection query.
- Default filters: if you apply default filters to a resource type, then collections of that
resource type will apply those filters when there is no filter in the collection query.
- Default includes: if you apply default includes to a resource type,
then collections of that resource type will apply those includes when
there is no include in the collection query.
- Default filters: if you apply default filters to a resource type, then
collections of that resource type will apply those filters when there is
no filter in the collection query.
--------------
Installation
......
......@@ -13,6 +13,9 @@ use Drupal\Tests\jsonapi_extras\Functional\JsonApiExtrasFunctionalTestBase;
*/
class JsonApiDefaultsFunctionalTest extends JsonApiExtrasFunctionalTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'jsonapi_defaults',
];
......
......@@ -13,6 +13,9 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class JsonapiExtrasSettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
protected $routerBuilder;
/**
......
......@@ -2,7 +2,6 @@
namespace Drupal\jsonapi_extras\Plugin;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Shaper\DataAdaptor\ReversibleTransformationInterface;
use Shaper\DataAdaptor\ReversibleTransformationValidationInterface;
use Shaper\Transformation\TransformationInterface;
......
......@@ -8,7 +8,6 @@ use Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Shaper\Util\Context;
/**
* Perform additional manipulations to JSON fields.
*
......@@ -21,16 +20,23 @@ use Shaper\Util\Context;
class JSONFieldEnhancer extends ResourceFieldEnhancerBase implements ContainerFactoryPluginInterface {
/**
* The serialization json.
*
* @var Drupal\Component\serialization\Json
*/
protected $encoder;
/**
* Constructs a new JSONFieldEnhancer.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* @param $plugin_definition
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Component\Serialization\Json $encoder
* The serialization json.
*/
public function __construct(array $configuration, string $plugin_id, $plugin_definition, Json $encoder) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
......@@ -73,8 +79,8 @@ class JSONFieldEnhancer extends ResourceFieldEnhancerBase implements ContainerFa
'oneOf' => [
['type' => 'object'],
['type' => 'array'],
['type' => 'null']
]
['type' => 'null'],
],
];
}
......
......@@ -22,6 +22,9 @@ use Symfony\Component\Routing\Route;
*/
class JsonApiExtrasFunctionalTest extends JsonApiFunctionalTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'jsonapi_extras',
'basic_auth',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment