Skip to content
Snippets Groups Projects
Commit 09f9fb42 authored by Guido Robertone's avatar Guido Robertone Committed by Mark Miller
Browse files

Issue #3368001 by emacoti, zarpele: PHPCS fixes

parent f40f9360
No related branches found
No related tags found
1 merge request!5Issue #3368001 by emacoti, zarpele: PHPCS fixes
Showing
with 50 additions and 81 deletions
......@@ -207,4 +207,5 @@ This project has been sponsored by:
(http://www.mediacurrent.com) for more information.
* Acquia
Commercially Supported Drupal. Visit (http://acquia.com) for more information.
Commercially Supported Drupal. Visit (http://acquia.com)
for more information.
......@@ -3,6 +3,4 @@ machine_name: ng2-example-1
type: pdb
description: 'NG 2 Example Component 1'
category: NG2
version: '1.0.0'
module_status: active
presentation: ng2
......@@ -3,6 +3,4 @@ machine_name: ng2-example-2
type: pdb
description: 'NG 2 Example Component 2'
category: NG2
version: '1.0.0'
module_status: active
presentation: ng2
......@@ -3,8 +3,6 @@ machine_name: ng2-example-configuration
type: pdb
description: 'NG 2 Example Component Configuration'
category: NG2
version: '1.0.0'
module_status: active
presentation: ng2
configuration:
text:
......
......@@ -3,8 +3,6 @@ machine_name: ng2-example-node
type: pdb
description: 'NG 2 Example Component Node'
category: NG2
version: '1.0.0'
module_status: active
presentation: ng2
contexts:
entity: node
......@@ -3,6 +3,4 @@ machine_name: ng2-hero
type: pdb
description: 'NG 2 Hero block, a basic example'
category: NG2
version: '1.0.0'
module_status: active
presentation: ng2
......@@ -3,6 +3,4 @@ machine_name: ng2-todo
type: pdb
description: 'NG 2 ToDo example component'
category: NG2
version: '1.0.0'
module_status: active
presentation: ng2
......@@ -241,11 +241,7 @@ label[for='toggle-all'] {
left: 0;
height: 50px;
overflow: hidden;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2),
0 8px 0 -3px #f6f6f6,
0 9px 1px -3px rgba(0, 0, 0, 0.2),
0 16px 0 -6px #f6f6f6,
0 17px 2px -6px rgba(0, 0, 0, 0.2);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 8px 0 -3px #f6f6f6, 0 9px 1px -3px rgba(0, 0, 0, 0.2), 0 16px 0 -6px #f6f6f6, 0 17px 2px -6px rgba(0, 0, 0, 0.2);
}
.todo-count {
......
......@@ -5,4 +5,4 @@ package: PDB
configure: pdb_ng2.form
core_version_requirement: ^9 || ^10
dependencies:
- pdb
- pdb:pdb
......@@ -5,27 +5,21 @@
* Any procedural Angular 2 PHP work lives here.
*/
/**
* Add our component paths for Angular 2.
*
* @param object $components
* The components.
*/
function pdb_ng2_component_info_alter($components) {
// Read info files for each module.
foreach ($components as $key => $component) {
foreach ($components as $component) {
// Set component path if it hasn't been hardcoded.
if ($component->info['presentation'] == 'ng2' && empty($component->info['path'])) {
// Use js or ts sourcing depending on development mode.
$config_settings = \Drupal::config('pdb_ng2.settings');
$ext = 'js';
if (isset($config_settings) && $config_settings->get('development_mode')) {
$ext = 'ts';
}
$component->info['path'] = $component->getPath();
}
else {
$path = isset($component->info['path']) ? $component->info['path'] : '';
$path = $component->info['path'] ?? '';
if (!empty($path) && $path[0] != '/') {
$component->info['path'] = $component->getPath() . '/' . $path;
}
......
......@@ -4,4 +4,4 @@ pdb_ng2.form:
_title: 'PDB Angular2'
_form: '\Drupal\pdb_ng2\Form\PdbNg2Form'
requirements:
_permission: 'access administration pages'
_permission: 'administer site configuration'
......@@ -6,7 +6,7 @@ use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class PdbNg2Form.
* Provides a form for Ng2 specific settings.
*
* @package Drupal\pdb_ng2\Form
*/
......@@ -48,8 +48,7 @@ class PdbNg2Form extends ConfigFormBase {
// Set variables based on form values.
$development_mode = $form_state->getValue('development_mode');
// Get the config object.
$config = \Drupal::service('config.factory')
->getEditable('pdb_ng2.settings');
$config = $this->configFactory->getEditable('pdb_ng2.settings');
// Set the values the user submitted in the form.
$config->set('development_mode', $development_mode);
$config->save();
......
......@@ -3,8 +3,6 @@ machine_name: react-example-1
type: pdb
description: 'React Example Component 1'
category: React
version: '1.0.0'
module_status: active
presentation: react
add_js:
footer:
......
......@@ -2,8 +2,7 @@
background: #fff;
margin: 130px 0 40px 0;
position: relative;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2),
0 25px 50px 0 rgba(0, 0, 0, 0.1);
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
}
.todoapp input::-webkit-input-placeholder {
......@@ -213,11 +212,7 @@ label[for='toggle-all'] {
left: 0;
height: 50px;
overflow: hidden;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2),
0 8px 0 -3px #f6f6f6,
0 9px 1px -3px rgba(0, 0, 0, 0.2),
0 16px 0 -6px #f6f6f6,
0 17px 2px -6px rgba(0, 0, 0, 0.2);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 8px 0 -3px #f6f6f6, 0 9px 1px -3px rgba(0, 0, 0, 0.2), 0 16px 0 -6px #f6f6f6, 0 17px 2px -6px rgba(0, 0, 0, 0.2);
}
.todo-count {
......
......@@ -3,8 +3,6 @@ machine_name: react-todo
type: pdb
description: 'React ToDo'
category: React
version: '1.0.0'
module_status: active
presentation: react
add_js:
footer:
......
......@@ -4,4 +4,4 @@ description: 'Turns on react framework for use by PDB'
package: PDB
core_version_requirement: ^9 || ^10
dependencies:
- pdb
- pdb:pdb
......@@ -2,17 +2,16 @@
namespace Drupal\pdb;
use Drupal\pdb\Discovery\PdbRecursiveExtensionFilterIterator;
use Drupal\pdb\Event\PdbDiscoveryEvent;
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\Core\Extension\InfoParserException;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Extension\Extension;
use Drupal\Core\Serialization\Yaml;
use Drupal\Core\Site\Settings;
use Drupal\pdb\Discovery\PdbRecursiveExtensionFilterIterator;
use Drupal\pdb\Event\PdbDiscoveryEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
use Drupal\Core\Serialization\Yaml;
/**
* Discovery service for front-end components provided by modules and themes.
......@@ -112,7 +111,7 @@ class ComponentDiscovery extends ExtensionDiscovery implements ComponentDiscover
return parent::scan($type, $include_tests);
}
// Based on parent::scan().
/* From here, based on parent::scan(). */
$files = [];
foreach ($search_dirs as $dir) {
......@@ -149,7 +148,7 @@ class ComponentDiscovery extends ExtensionDiscovery implements ComponentDiscover
return parent::scanDirectory($dir, $include_tests);
}
// Based on parent::scanDirectory().
/* From here, based on parent::scanDirectory(). */
$files = [];
......
......@@ -11,7 +11,7 @@ use Drupal\pdb\FrameworkAwareBlockInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Class PdbBlock.
* Provides a base class with core logic for PDB components.
*
* @package Drupal\pdb\Plugin\Block
*/
......@@ -227,7 +227,7 @@ abstract class PdbBlock extends BlockBase implements FrameworkAwareBlockInterfac
}
foreach ($entity as $field_name => $field) {
// @var \Drupal\Core\Field\FieldItemListInterface $field
/** @var \Drupal\Core\Field\FieldItemListInterface $field */
$field_access = $field->access('view', NULL, TRUE);
// @todo Used addCacheableDependency($field_access);
......@@ -240,24 +240,6 @@ abstract class PdbBlock extends BlockBase implements FrameworkAwareBlockInterfac
}
}
/**
* Add serialized entity to the JS Contexts.
*
* @param \Drupal\Core\Entity\Plugin\DataType\EntityAdapter $data
* The entity to serialize.
* @param array $js_contexts
* The full array of JS contexts.
* @param string $key
* The context key.
*
* @deprecated in pdb:8.x-1.0 and is removed from pdb:2.0.0.
* Instead, you should just use ::getContextEntityValue().
*/
protected function addEntityJsContext(EntityAdapter $data, array &$js_contexts, $key) {
@trigger_error('addEntityJsContext() is deprecated in pdb:8.x-1.0 and is removed from pdb:2.0.0. Use ::getContextEntityValue() instead.', E_USER_DEPRECATED);
$this->getContextEntityValue($key, $data, $js_contexts);
}
/**
* Get an array of serialized JS contexts.
*
......@@ -312,7 +294,7 @@ abstract class PdbBlock extends BlockBase implements FrameworkAwareBlockInterfac
* @return array
* Form elements.
*/
protected function createElementsFromConfiguration($configuration, FormStateInterface $form_state) {
protected function createElementsFromConfiguration(array $configuration, FormStateInterface $form_state) {
$elements = [];
$defaults = (!empty($this->configuration['pdb_configuration'])) ?
$this->configuration['pdb_configuration'] : [];
......
......@@ -4,9 +4,8 @@ namespace Drupal\Tests\pdb\Unit\Plugin\Block;
use Drupal\Component\Uuid\UuidInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContextAwarePluginInterface;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Plugin\Context\EntityContextDefinition;
use Drupal\Core\Plugin\ContextAwarePluginInterface;
use Drupal\pdb\Plugin\Block\PdbBlock;
use Drupal\Tests\UnitTestCase;
use Prophecy\PhpUnit\ProphecyTrait;
......@@ -60,7 +59,9 @@ class PdbBlockTest extends UnitTestCase {
],
],
'settings' => [
'pdb' => ['settings test'],
'pdb' => [
'settings test' => 1,
],
],
'configuration' => [
'testField' => [
......@@ -83,26 +84,44 @@ class PdbBlockTest extends UnitTestCase {
// Create a new instance from the Abstract Class.
$anonymous_class_from_abstract = new class($configuration, $plugin_id, $plugin_definition, $uuid_service) extends PdbBlock {
/**
* Return class instance.
*/
public function returnThis() {
return $this;
}
/**
* Attach framework stuff.
*/
public function attachFramework(array $component) {
return ['drupalSettings' => ['pdb' => ['webcomponents' => []]]];
}
/**
* Attach page header stuff.
*/
public function attachPageHeader(array $component) {
return ['page_attachment'];
}
/**
* Get current context values.
*/
protected function getContextsValues(array $contexts) {
return ['context_key' => 'context_value'];
}
/**
* Get current context values for JS usage.
*/
protected function getJsContexts(array $contexts) {
return ['context_key' => 'context_value'];
}
/**
* Context assignment element.
*/
protected function addContextAssignmentElement(ContextAwarePluginInterface $plugin, array $contexts) {
return 'context';
}
......@@ -111,7 +130,7 @@ class PdbBlockTest extends UnitTestCase {
$this->plugin = $anonymous_class_from_abstract->returnThis();
// Create a translation stub for the t() method
// Create a translation stub for the t() method.
$translator = $this->getStringTranslationStub();
$this->plugin->setStringTranslation($translator);
}
......@@ -124,7 +143,7 @@ class PdbBlockTest extends UnitTestCase {
'#attached' => [
'drupalSettings' => [
'pdb' => [
'settings test',
'settings test' => 1,
'webcomponents' => [],
'configuration' => [
'uuid' => [
......@@ -140,8 +159,8 @@ class PdbBlockTest extends UnitTestCase {
],
],
],
'pdb/example-1/footer',
'page_attachment',
0 => 'pdb/example-1/footer',
1 => 'page_attachment',
],
];
......
......@@ -2,8 +2,8 @@
namespace Drupal\Tests\pdb\Unit\Plugin\Derivative;
use Drupal\pdb\Plugin\Derivative\PdbBlockDeriver;
use Drupal\pdb\ComponentDiscoveryInterface;
use Drupal\pdb\Plugin\Derivative\PdbBlockDeriver;
use Drupal\Tests\UnitTestCase;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
......
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