Commit d980fc6b authored by willzyx's avatar willzyx
Browse files

Coding standard

parent 8d61aaa5
/**
* Dumpers
*/
.devel-dumper .details-wrapper{
.devel-dumper .details-wrapper {
max-height: 450px;
margin-right: 3px;
overflow: auto;
......
......@@ -4,35 +4,39 @@
*/
.toolbar .toolbar-tray-vertical .edit-devel-toolbar {
text-align: right; /* LTR */
padding: 1em;
text-align: right; /* LTR */
padding: 1em;
}
[dir="rtl"] .toolbar .toolbar-tray-vertical .edit-devel-toolbar {
text-align: left;
text-align: left;
}
.toolbar .toolbar-tray-horizontal .edit-devel-toolbar {
float: right; /* LTR */
float: right; /* LTR */
}
[dir="rtl"] .toolbar .toolbar-tray-horizontal .edit-devel-toolbar {
float: left;
float: left;
}
.toolbar .toolbar-tray-horizontal .toolbar-menu {
float: left; /* LTR */
float: left; /* LTR */
}
[dir="rtl"] .toolbar .toolbar-tray-horizontal .toolbar-menu {
float: right;
float: right;
}
.toolbar .toolbar-bar .toolbar-icon-devel:before{
background-image: url(../icons/bebebe/cog.svg);
.toolbar .toolbar-bar .toolbar-icon-devel:before {
background-image: url(../icons/bebebe/cog.svg);
}
.toolbar-bar .toolbar-icon-devel:active:before,
.toolbar-bar .toolbar-icon-devel.is-active:before {
background-image: url(../icons/ffffff/cog.svg);
background-image: url(../icons/ffffff/cog.svg);
}
.toolbar-horizontal .toolbar-horizontal-item-hidden {
display: none;
display: none;
}
......@@ -13,7 +13,7 @@
/**
* Alter devel dumper information declared by other modules.
*
* @param $info
* @param array $info
* Devel dumper information to alter.
*/
function hook_devel_dumper_info_alter(&$info) {
......
......@@ -16,7 +16,7 @@ function devel_requirements($phase) {
// https://www.drupal.org/node/2834400.
$requirements['devel'] = [
'title' => t('Devel module enabled'),
'description' => t('The Devel module provides access to internal debugging information; therefore it\'s recommended to disable this module on sites in production.'),
'description' => t("The Devel module provides access to internal debugging information; therefore it's recommended to disable this module on sites in production."),
'severity' => REQUIREMENT_INFO,
];
}
......@@ -39,7 +39,7 @@ function devel_update_8001() {
}
/**
* Add enforced dependencies to system.menu.devel
* Add enforced dependencies to system.menu.devel.
*/
function devel_update_8002() {
$config = \Drupal::configFactory()->getEditable('system.menu.devel');
......
......@@ -15,6 +15,7 @@ use Drupal\Component\Annotation\Plugin;
* @see plugin_api
*/
class DevelDumper extends Plugin {
/**
* The human-readable name of the DevelDumper type.
*
......
......@@ -45,10 +45,10 @@ class EntityDebugController extends ControllerBase {
* Returns the entity type definition of the current entity.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* A RouteMatch object.
* A RouteMatch object.
*
* @return array
* Array of page elements to render.
* Array of page elements to render.
*/
public function entityTypeDefinition(RouteMatchInterface $route_match) {
$output = [];
......@@ -66,10 +66,10 @@ class EntityDebugController extends ControllerBase {
* Returns the loaded structure of the current entity.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* A RouteMatch object.
* A RouteMatch object.
*
* @return array
* Array of page elements to render.
* Array of page elements to render.
*/
public function entityLoad(RouteMatchInterface $route_match) {
$output = [];
......@@ -81,7 +81,7 @@ class EntityDebugController extends ControllerBase {
// By calling ::getFieldDefinitions() we are sure that field definitions
// are populated and available in the dump output.
// @see https://www.drupal.org/node/2311557
if($entity instanceof FieldableEntityInterface) {
if ($entity instanceof FieldableEntityInterface) {
$entity->getFieldDefinitions();
}
......@@ -95,10 +95,10 @@ class EntityDebugController extends ControllerBase {
* Returns the render structure of the current entity.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* A RouteMatch object.
* A RouteMatch object.
*
* @return array
* Array of page elements to render.
* Array of page elements to render.
*/
public function entityRender(RouteMatchInterface $route_match) {
$output = [];
......@@ -136,8 +136,7 @@ class EntityDebugController extends ControllerBase {
*/
protected function getEntityFromRouteMatch(RouteMatchInterface $route_match) {
$parameter_name = $route_match->getRouteObject()->getOption('_devel_entity_type_id');
$entity = $route_match->getParameter($parameter_name);
return $entity;
return $route_match->getParameter($parameter_name);
}
}
......@@ -45,7 +45,7 @@ class SwitchUserController extends ControllerBase {
protected $session;
/**
* Constructs a new SwitchUserController object
* Constructs a new SwitchUserController object.
*
* @param \Drupal\Core\Session\AccountProxyInterface $account
* The current user.
......@@ -82,8 +82,8 @@ class SwitchUserController extends ControllerBase {
/**
* Switches to a different user.
*
* We don't call session_save_session() because we really want to change users.
* Usually unsafe!
* We don't call session_save_session() because we really want to change
* users. Usually unsafe!
*
* @param string $name
* The username to switch to, or NULL to log out.
......
......@@ -3,7 +3,9 @@
namespace Drupal\devel;
/**
* Interface DevelDumperManagerInterface
* Interface DevelDumperManagerInterface.
*
* @package Drupal\devel
*/
interface DevelDumperManagerInterface {
......
......@@ -31,7 +31,7 @@ class ThemeInfoRebuildSubscriber implements EventSubscriberInterface {
/**
* The devel config.
*
* @var \Drupal\Core\Config\Config;
* @var \Drupal\Core\Config\Config
*/
protected $config;
......
......@@ -56,63 +56,63 @@ class DevelReinstall extends FormBase {
return empty($modules[$module->getName()]->info['required']) && drupal_get_installed_schema_version($module->getName()) > SCHEMA_UNINSTALLED && $module->getName() !== 'devel';
});
$form['filters'] = array(
$form['filters'] = [
'#type' => 'container',
'#attributes' => array(
'class' => array('table-filter', 'js-show'),
),
);
$form['filters']['text'] = array(
'#attributes' => [
'class' => ['table-filter', 'js-show'],
],
];
$form['filters']['text'] = [
'#type' => 'search',
'#title' => $this->t('Search'),
'#size' => 30,
'#placeholder' => $this->t('Enter module name'),
'#attributes' => array(
'class' => array('table-filter-text'),
'#attributes' => [
'class' => ['table-filter-text'],
'data-table' => '#devel-reinstall-form',
'autocomplete' => 'off',
'title' => $this->t('Enter a part of the module name or description to filter by.'),
),
);
],
];
// Only build the rest of the form if there are any modules available to
// uninstall;
// uninstall.
if (empty($uninstallable)) {
return $form;
}
$header = array(
$header = [
'name' => $this->t('Name'),
'description' => $this->t('Description'),
);
];
$rows = array();
$rows = [];
foreach ($uninstallable as $module) {
$name = $module->info['name'] ? : $module->getName();
$name = $module->info['name'] ?: $module->getName();
$rows[$module->getName()] = array(
'name' => array(
'data' => array(
$rows[$module->getName()] = [
'name' => [
'data' => [
'#type' => 'inline_template',
'#template' => '<label class="module-name table-filter-text-source">{{ module_name }}</label>',
'#context' => array('module_name' => $name),
)
),
'description' => array(
'#context' => ['module_name' => $name],
],
],
'description' => [
'data' => $module->info['description'],
'class' => array('description'),
),
);
'class' => ['description'],
],
];
}
$form['reinstall'] = array(
$form['reinstall'] = [
'#type' => 'tableselect',
'#header' => $header,
'#options' => $rows,
'#js_select' => FALSE,
'#empty' => $this->t('No modules are available to uninstall.'),
);
];
$form['#attached']['library'][] = 'system/drupal.system.modules';
......@@ -144,10 +144,9 @@ class DevelReinstall extends FormBase {
$reinstall = array_keys(array_filter($modules));
$this->moduleInstaller->uninstall($reinstall, FALSE);
$this->moduleInstaller->install($reinstall, FALSE);
$this->messenger()->addMessage($this->t('Uninstalled and installed: %names.', array('%names' => implode(', ', $reinstall))));
}
catch (\Exception $e) {
$this->messenger()->addError($this->t('Unable to reinstall modules. Error: %error.', array('%error' => $e->getMessage())));
$this->messenger()->addMessage($this->t('Uninstalled and installed: %names.', ['%names' => implode(', ', $reinstall)]));
} catch (\Exception $e) {
$this->messenger()->addError($this->t('Unable to reinstall modules. Error: %error.', ['%error' => $e->getMessage()]));
}
}
......
......@@ -25,6 +25,7 @@ class SwitchUserForm extends FormBase {
* Constructs a new SwitchUserForm object.
*
* @param \Drupal\Core\Access\CsrfTokenGenerator $csrf_token_generator
* The CSRF token generator.
*/
public function __construct(CsrfTokenGenerator $csrf_token_generator) {
$this->csrfToken = $csrf_token_generator;
......@@ -62,7 +63,7 @@ class SwitchUserForm extends FormBase {
'#placeholder' => $this->t('Enter username'),
'#target_type' => 'user',
'#selection_settings' => [
'include_anonymous' => FALSE
'include_anonymous' => FALSE,
],
'#process_default_value' => FALSE,
'#maxlength' => USERNAME_MAX_LENGTH,
......
......@@ -20,7 +20,7 @@ class DevelLocalTask extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* The entity manager
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
......
......@@ -44,9 +44,9 @@ class DoctrineDebug extends DevelDumperBase {
public function exportAsRenderable($input, $name = NULL) {
$output['container'] = [
'#type' => 'details',
'#title' => $name ? : $this->t('Variable'),
'#title' => $name ?: $this->t('Variable'),
'#attached' => [
'library' => ['devel/devel']
'library' => ['devel/devel'],
],
'#attributes' => [
'class' => ['container-inline', 'devel-dumper', 'devel-selectable'],
......
......@@ -36,9 +36,9 @@ class DrupalVariable extends DevelDumperBase {
public function exportAsRenderable($input, $name = NULL) {
$output['container'] = [
'#type' => 'details',
'#title' => $name ? : $this->t('Variable'),
'#title' => $name ?: $this->t('Variable'),
'#attached' => [
'library' => ['devel/devel']
'library' => ['devel/devel'],
],
'#attributes' => [
'class' => ['container-inline', 'devel-dumper', 'devel-selectable'],
......
......@@ -15,7 +15,6 @@ use Symfony\Component\VarDumper\Dumper\HtmlDumper;
* label = @Translation("Symfony var-dumper"),
* description = @Translation("Wrapper for <a href='https://github.com/symfony/var-dumper'>Symfony var-dumper</a> debugging tool."),
* )
*
*/
class VarDumper extends DevelDumperBase {
......
......@@ -20,13 +20,14 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* @endcode
*
* By default the mails are saved in 'temporary://devel-mails'. This setting
* can be changed using 'debug_mail_directory' config setting. For example,
* can be changed using 'debug_mail_directory' config setting. For example:
* @code
* $config['devel.settings']['debug_mail_directory'] = 'temporary://my-directory';
* @endcode
*
* The default filename pattern used is '%to-%subject-%datetime.mail.txt'. This
* setting can be changed using 'debug_mail_directory' config setting. For example,
* setting can be changed using 'debug_mail_directory' config setting.
* For example:
* @code
* $config['devel.settings']['debug_mail_file_format'] = 'devel-mail-%to-%subject-%datetime.mail.txt';
* @endcode
......@@ -47,7 +48,7 @@ class DevelMailLog implements MailInterface, ContainerFactoryPluginInterface {
/**
* The devel.settings config object.
*
* @var \Drupal\Core\Config\Config;
* @var \Drupal\Core\Config\Config
*/
protected $config;
......@@ -120,7 +121,7 @@ class DevelMailLog implements MailInterface, ContainerFactoryPluginInterface {
* @return string
* The output message.
*/
protected function composeMessage($message) {
protected function composeMessage(array $message) {
$mimeheaders = [];
$message['headers']['To'] = $message['to'];
foreach ($message['headers'] as $name => $value) {
......@@ -128,7 +129,7 @@ class DevelMailLog implements MailInterface, ContainerFactoryPluginInterface {
}
$line_endings = Settings::get('mail_line_endings', PHP_EOL);
$output = join($line_endings, $mimeheaders) . $line_endings;
$output = implode($line_endings, $mimeheaders) . $line_endings;
// 'Subject:' is a mail header and should not be translated.
$output .= 'Subject: ' . $message['subject'] . $line_endings;
// Blank line to separate headers from body.
......@@ -140,7 +141,7 @@ class DevelMailLog implements MailInterface, ContainerFactoryPluginInterface {
/**
* Replaces placeholders with sanitized values in a string.
*
* @param $filename
* @param string $filename
* The string that contains the placeholders. The following placeholders
* are considered in the replacement:
* - %to: replaced by the email recipient value.
......@@ -152,7 +153,7 @@ class DevelMailLog implements MailInterface, ContainerFactoryPluginInterface {
* @return string
* The formatted string.
*/
protected function replacePlaceholders($filename, $message) {
protected function replacePlaceholders($filename, array $message) {
$tokens = [
'%to' => $message['to'],
'%subject' => $message['subject'],
......@@ -164,10 +165,11 @@ class DevelMailLog implements MailInterface, ContainerFactoryPluginInterface {
/**
* Checks that the directory exists and is writable.
*
* Public directories will be protected by adding an .htaccess which
* indicates that the directory is private.
*
* @param $directory
* @param string $directory
* A string reference containing the name of a directory path or URI.
*
* @return bool
......
......@@ -122,7 +122,13 @@ class DevelClientSideFilterTableTest extends UnitTestCase {
['data' => 'test2', 'filter' => TRUE, 'class' => ['test2']],
['data' => 'test3', 'class' => ['test3']],
['test4'],
['data' => 'test5', 'filter' => TRUE, 'class' => ['devel-event-name-header'], 'colspan' => '3', 'header' => TRUE],
[
'data' => 'test5',
'filter' => TRUE,
'class' => ['devel-event-name-header'],
'colspan' => '3',
'header' => TRUE,
],
],
],
'#empty' => $t->translate('Empty 2'),
......@@ -157,11 +163,25 @@ class DevelClientSideFilterTableTest extends UnitTestCase {
'#header' => $headers,
'#rows' => [
[
['data' => 'test1', 'filter' => TRUE, 'class' => ['table-filter-text-source']],
['data' => 'test2', 'filter' => TRUE, 'class' => ['test2', 'table-filter-text-source']],
[
'data' => 'test1',
'filter' => TRUE,
'class' => ['table-filter-text-source'],
],
[
'data' => 'test2',
'filter' => TRUE,
'class' => ['test2', 'table-filter-text-source'],
],
['data' => 'test3', 'class' => ['test3']],
['test4'],
['data' => 'test5', 'filter' => TRUE, 'class' => ['devel-event-name-header', 'table-filter-text-source'], 'colspan' => '3', 'header' => TRUE],
[
'data' => 'test5',
'filter' => TRUE,
'class' => ['devel-event-name-header', 'table-filter-text-source'],
'colspan' => '3',
'header' => TRUE,
],
],
],
'#empty' => $t->translate('Empty 2'),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment