for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Drupal\entity_browser;
use Drupal\Core\Form\FormStateInterface;
/**
* Provides base form methods for configurable plugins entity browser.
*/
trait PluginConfigurationFormTrait {
* Implements PluginFormInterface::buildConfigurationForm().
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form_state
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
return $form;
}
* Implements PluginFormInterface::validateConfigurationForm().
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
$form
* Implements PluginFormInterface::submitConfigurationForm().
*
* This is the default implementation for the most common cases where the form
* element names match keys in configuration array. Plugins can override this
* if they need more complex logic.
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$values = $form_state->getValues();
if ($this instanceof WidgetInterface) {
$values = $values['table'][$this->uuid()]['form'];
if (!empty($values)) {
foreach ($values as $key => $value) {
if (array_key_exists($key, $this->configuration)) {
$this->configuration[$key] = $value;
configuration
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.