Commit f6ae5852 authored by catch's avatar catch

Issue #2572801 by alexpott, vprocessor, andriyun, andypost, chishah92, Mile23,...

Issue #2572801 by alexpott, vprocessor, andriyun, andypost, chishah92, Mile23, attiks, hussainweb, klausi, dawehner, pfrenssen: Fix 'Drupal.WhiteSpace.ScopeIndent' coding standard
parent b6a64fc0
......@@ -37,7 +37,7 @@ class SiteSettingsForm extends FormBase {
public function __construct($site_path, RendererInterface $renderer) {
$this->sitePath = $site_path;
$this->renderer = $renderer;
}
}
/**
* {@inheritdoc}
......
......@@ -202,8 +202,7 @@ public static function htmlToText($string, $allowed_tags = NULL) {
// Ensure blank new-line.
$chunk = '';
}
// Fall-through.
// Intentional fall-through to the processing for '/li' and '/dd'.
case '/li':
case '/dd':
array_pop($indent);
......@@ -212,6 +211,7 @@ public static function htmlToText($string, $allowed_tags = NULL) {
case '/h3':
case '/h4':
array_pop($indent);
// Intentional fall-through to the processing for '/h5' and '/h6'.
case '/h5':
case '/h6':
// Ensure blank new-line.
......
......@@ -85,7 +85,7 @@ public static function create($data_type = 'any') {
*
* @param string $data_type
* The required data type.
* @param mixed string|null $label
* @param string|null $label
* The label of this context definition for the UI.
* @param bool $required
* Whether the context definition is required.
......
......@@ -21,11 +21,9 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter
switch ($operation) {
case 'view':
return AccessResult::allowedIfHasPermission($account, 'access news feeds');
break;
default:
return AccessResult::allowedIfHasPermission($account, 'administer news feeds');
break;
}
}
......
......@@ -111,13 +111,12 @@ public function fetchObjectCallback() {
switch ($this->calls_to_fetch) {
case 1:
return 'something';
break;
case 2:
return 'something-else';
break;
default:
return FALSE;
break;
}
}
......
......@@ -23,11 +23,11 @@
'weight',
'selected'
))
->values(array(
->values(array(
'category' => 'Upgrade test',
'recipients' => 'test1@example.com,test2@example.com',
'reply' => 'Test reply',
'weight' => 1,
'selected' => 1,
))
->execute();
->execute();
......@@ -167,7 +167,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$default_value = $items->defaultValuesFormSubmit($form['default_value'], $form, $form_state);
}
$this->entity->setDefaultValue($default_value);
}
}
/**
* {@inheritdoc}
......
......@@ -185,11 +185,17 @@ public function import() {
}
catch (RequirementsException $e) {
$this->message->display(
$this->t('Migration @id did not meet the requirements. @message @requirements', array(
$this->t(
'Migration @id did not meet the requirements. @message @requirements',
array(
'@id' => $this->migration->id(),
'@message' => $e->getMessage(),
'@requirements' => $e->getRequirementsString(),
)), 'error');
)
),
'error'
);
return MigrationInterface::RESULT_FAILED;
}
......@@ -476,30 +482,44 @@ protected function memoryExceeded() {
}
if ($pct_memory > $threshold) {
$this->message->display(
$this->t('Memory usage is @usage (@pct% of limit @limit), reclaiming memory.',
array('@pct' => round($pct_memory * 100),
$this->t(
'Memory usage is @usage (@pct% of limit @limit), reclaiming memory.',
array(
'@pct' => round($pct_memory * 100),
'@usage' => $this->formatSize($usage),
'@limit' => $this->formatSize($this->memoryLimit))),
'warning');
'@limit' => $this->formatSize($this->memoryLimit),
)
),
'warning'
);
$usage = $this->attemptMemoryReclaim();
$pct_memory = $usage / $this->memoryLimit;
// Use a lower threshold - we don't want to be in a situation where we keep
// coming back here and trimming a tiny amount
if ($pct_memory > (0.90 * $threshold)) {
$this->message->display(
$this->t('Memory usage is now @usage (@pct% of limit @limit), not enough reclaimed, starting new batch',
array('@pct' => round($pct_memory * 100),
$this->t(
'Memory usage is now @usage (@pct% of limit @limit), not enough reclaimed, starting new batch',
array(
'@pct' => round($pct_memory * 100),
'@usage' => $this->formatSize($usage),
'@limit' => $this->formatSize($this->memoryLimit))),
'warning');
'@limit' => $this->formatSize($this->memoryLimit),
)
),
'warning'
);
return TRUE;
}
else {
$this->message->display(
$this->t('Memory usage is now @usage (@pct% of limit @limit), reclaimed enough, continuing',
array('@pct' => round($pct_memory * 100),
$this->t(
'Memory usage is now @usage (@pct% of limit @limit), reclaimed enough, continuing',
array(
'@pct' => round($pct_memory * 100),
'@usage' => $this->formatSize($usage),
'@limit' => $this->formatSize($this->memoryLimit))),
'@limit' => $this->formatSize($this->memoryLimit),
)
),
'warning');
return FALSE;
}
......
......@@ -21,7 +21,6 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter
switch ($operation) {
case 'view':
return AccessResult::allowedIfHasPermission($account, 'access content');
break;
case 'delete':
if ($entity->isLocked()) {
......@@ -34,7 +33,7 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter
default:
return parent::checkAccess($entity, $operation, $account);
break;
}
}
......
......@@ -17,7 +17,7 @@
$views_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/drupal-8.views-entity-views-data-2455125.yml'));
foreach ($views_configs as $views_config) {
$connection->insert('config')
$connection->insert('config')
->fields(array(
'collection',
'name',
......
......@@ -99,10 +99,10 @@ public function testPrefix() {
$this->assertEquals('extra2', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
// This breaks simpletest cleanup.
// $command_tester->execute([
// '--prefix' => 'notsimpletest',
// ]);
// $this->assertEquals('notsimpletest', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
// $command_tester->execute([
// '--prefix' => 'notsimpletest',
// ]);
// $this->assertEquals('notsimpletest', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
}
}
......
......@@ -21,15 +21,12 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter
switch ($operation) {
case 'view':
return AccessResult::allowedIfHasPermission($account, 'access content');
break;
case 'update':
return AccessResult::allowedIfHasPermissions($account, ["edit terms in {$entity->bundle()}", 'administer taxonomy'], 'OR');
break;
case 'delete':
return AccessResult::allowedIfHasPermissions($account, ["delete terms in {$entity->bundle()}", 'administer taxonomy'], 'OR');
break;
default:
// No opinion.
......
......@@ -120,7 +120,6 @@ public function getFieldType(Row $row) {
return 'text_long';
default:
return parent::getFieldType($row);
break;
}
}
}
......
......@@ -112,16 +112,4 @@ function render_item($count, $item) {
return $item['permission'];
}
/*
protected function documentSelfTokens(&$tokens) {
$tokens['[' . $this->options['id'] . '-role' . ']'] = $this->t('The name of the role.');
$tokens['[' . $this->options['id'] . '-rid' . ']'] = $this->t('The role ID of the role.');
}
protected function addSelfTokens(&$tokens, $item) {
$tokens['[' . $this->options['id'] . '-role' . ']'] = $item['role'];
$tokens['[' . $this->options['id'] . '-rid' . ']'] = $item['rid'];
}
*/
}
......@@ -96,7 +96,7 @@ protected function valueSubmit($form, FormStateInterface $form_state) {
// prevent array filter from removing our anonymous user.
}
/**
/**
* {@inheritdoc}
*/
public function getValueOptions() {
......
......@@ -124,25 +124,10 @@ protected function createSerializedUser($name, $include_password = TRUE) {
global $base_url;
// New user info to be serialized.
$data = [
"_links" =>
[
"type" => ["href" => $base_url . "/rest/type/user/user"],
],
"langcode" => [
[
"value" => "en",
],
],
"name" => [
[
"value" => $name,
],
],
"mail" => [
[
"value" => "$name@example.com",
],
],
"_links" => ["type" => ["href" => $base_url . "/rest/type/user/user"]],
"langcode" => [["value" => "en"]],
"name" => [["value" => $name]],
"mail" => [["value" => "$name@example.com"]],
];
if ($include_password) {
$data['pass']['value'] = 'SuperSecretPassword';
......
......@@ -14,8 +14,8 @@
// already.
$connection->delete('config')->condition('name', 'user.mail')->execute();
$connection->insert('config')
->fields(array('collection', 'name', 'data'))
->values(array(
->fields(array('collection', 'name', 'data'))
->values(array(
'collection' => '',
'name' => 'user.mail',
'data' => "a:10:{s:14:\"cancel_confirm\";a:2:{s:4:\"body\";s:369:\"[user:name],\n\nA request to cancel your account has been made at [site:name].\n\nYou may now cancel your account on [site:url-brief] by clicking this link or copying and pasting it into your browser:\n\n[user:cancel-url]\n\nNOTE: The cancellation of your account is not reversible.\n\nThis link expires in one day and nothing will happen if it is not used.\n\n-- [site:name] team\";s:7:\"subject\";s:59:\"Account cancellation request for [user:name] at [site:name]\";}s:14:\"password_reset\";a:2:{s:4:\"body\";s:397:\"[user:name],\n\nA request to reset the password for your account has been made at [site:name].\n\nYou may now log in by clicking this link or copying and pasting it to your browser:\n\n[user:one-time-login-url]\n\nThis link can only be used once to log in and will lead you to a page where you can set your password. It expires after one day and nothing will happen if it's not used.\n\n-- [site:name] team\";s:7:\"subject\";s:60:\"Replacement login information for [user:name] at [site:name]\";}s:22:\"register_admin_created\";a:2:{s:4:\"body\";s:463:\"[user:name],\n\nA site administrator at [site:name] has created an account for you. You may now log in by clicking this link or copying and pasting it to your browser:\n\n[user:one-time-login-url]\n\nThis link can only be used once to log in and will lead you to a page where you can set your password.\n\nAfter setting your password, you will be able to log in at [site:login-url] in the future using:\n\nusername: [user:name]\npassword: Your password\n\n-- [site:name] team\";s:7:\"subject\";s:58:\"An administrator created an account for you at [site:name]\";}s:29:\"register_no_approval_required\";a:2:{s:4:\"body\";s:437:\"[user:name],\n\nThank you for registering at [site:name]. You may now log in by clicking this link or copying and pasting it to your browser:\n\n[user:one-time-login-url]\n\nThis link can only be used once to log in and will lead you to a page where you can set your password.\n\nAfter setting your password, you will be able to log in at [site:login-url] in the future using:\n\nusername: [user:name]\npassword: Your password\n\n-- [site:name] team\";s:7:\"subject\";s:46:\"Account details for [user:name] at [site:name]\";}s:25:\"register_pending_approval\";a:2:{s:4:\"body\";s:281:\"[user:name],\n\nThank you for registering at [site:name]. Your application for an account is currently pending approval. Once it has been approved, you will receive another email containing information about how to log in, set your password, and other details.\n\n\n-- [site:name] team\";s:7:\"subject\";s:71:\"Account details for [user:name] at [site:name] (pending admin approval)\";}s:31:\"register_pending_approval_admin\";a:2:{s:4:\"body\";s:56:\"[user:name] has applied for an account.\n\n[user:edit-url]\";s:7:\"subject\";s:71:\"Account details for [user:name] at [site:name] (pending admin approval)\";}s:16:\"status_activated\";a:2:{s:4:\"body\";s:446:\"[user:name],\n\nYour account at [site:name] has been activated.\n\nYou may now log in by clicking this link or copying and pasting it into your browser:\n\n[user:one-time-login-url]\n\nThis link can only be used once to log in and will lead you to a page where you can set your password.\n\nAfter setting your password, you will be able to log in at [site:login-url] in the future using:\n\nusername: [user:name]\npassword: Your password\n\n-- [site:name] team\";s:7:\"subject\";s:57:\"Account details for [user:name] at [site:name] (approved)\";}s:14:\"status_blocked\";a:2:{s:4:\"body\";s:89:\"[user:name],\n\nYour account on [site:account-name] has been blocked.\n\n-- [site:name] team\";s:7:\"subject\";s:56:\"Account details for [user:name] at [site:name] (blocked)\";}s:15:\"status_canceled\";a:2:{s:4:\"body\";s:82:\"[user:name],\n\nYour account on [site:name] has been canceled.\n\n-- [site:name] team\";s:7:\"subject\";s:57:\"Account details for [user:name] at [site:name] (canceled)\";}s:8:\"langcode\";s:2:\"en\";}"
......
......@@ -105,25 +105,25 @@ public function testBuildPermissionsYaml() {
$url = vfsStream::url('modules');
mkdir($url . '/module_a');
file_put_contents($url . '/module_a/module_a.permissions.yml',
"access_module_a: single_description"
);
file_put_contents($url . '/module_a/module_a.permissions.yml', "access_module_a: single_description");
mkdir($url . '/module_b');
file_put_contents($url . '/module_b/module_b.permissions.yml',
"'access module b':
file_put_contents($url . '/module_b/module_b.permissions.yml', <<<EOF
'access module b':
title: 'Access B'
description: 'bla bla'
'access module a via module b':
title: 'Access A via B'
provider: 'module_a'
");
EOF
);
mkdir($url . '/module_c');
file_put_contents($url . '/module_c/module_c.permissions.yml',
"'access_module_c':
file_put_contents($url . '/module_c/module_c.permissions.yml', <<<EOF
'access_module_c':
title: 'Access C'
description: 'bla bla'
'restrict access': TRUE
");
EOF
);
$modules = array('module_a', 'module_b', 'module_c');
$extensions = array(
'module_a' => $this->mockModuleExtension('module_a', 'Module a'),
......@@ -187,9 +187,10 @@ public function testBuildPermissionsSortPerModule() {
$url = vfsStream::url('modules');
mkdir($url . '/module_a');
file_put_contents($url . '/module_a/module_a.permissions.yml',
"access_module_a2: single_description2
access_module_a1: single_description1"
file_put_contents($url . '/module_a/module_a.permissions.yml', <<<EOF
access_module_a2: single_description2
access_module_a1: single_description1
EOF
);
mkdir($url . '/module_b');
file_put_contents($url . '/module_b/module_b.permissions.yml',
......@@ -234,21 +235,24 @@ public function testBuildPermissionsYamlCallback() {
$url = vfsStream::url('modules');
mkdir($url . '/module_a');
file_put_contents($url . '/module_a/module_a.permissions.yml',
"permission_callbacks:
file_put_contents($url . '/module_a/module_a.permissions.yml', <<<EOF
permission_callbacks:
- 'Drupal\\user\\Tests\\TestPermissionCallbacks::singleDescription'
");
EOF
);
mkdir($url . '/module_b');
file_put_contents($url . '/module_b/module_b.permissions.yml',
"permission_callbacks:
file_put_contents($url . '/module_b/module_b.permissions.yml', <<<EOF
permission_callbacks:
- 'Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescription'
- 'Drupal\\user\\Tests\\TestPermissionCallbacks::titleProvider'
");
EOF
);
mkdir($url . '/module_c');
file_put_contents($url . '/module_c/module_c.permissions.yml',
"permission_callbacks:
file_put_contents($url . '/module_c/module_c.permissions.yml', <<<EOF
permission_callbacks:
- 'Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescriptionRestrictAccess'
");
EOF
);
$modules = array('module_a', 'module_b', 'module_c');
$extensions = array(
......@@ -309,13 +313,14 @@ public function testPermissionsYamlStaticAndCallback() {
$url = vfsStream::url('modules');
mkdir($url . '/module_a');
file_put_contents($url . '/module_a/module_a.permissions.yml',
"'access module a':
file_put_contents($url . '/module_a/module_a.permissions.yml', <<<EOF
'access module a':
title: 'Access A'
description: 'bla bla'
permission_callbacks:
- 'Drupal\\user\\Tests\\TestPermissionCallbacks::titleDescription'
");
EOF
);
$modules = array('module_a');
$extensions = array(
......
......@@ -5,7 +5,7 @@
use Drupal\Tests\Core\Session\UserSessionTest;
use Drupal\user\RoleInterface;
/**
/**
* @coversDefaultClass \Drupal\user\Entity\User
* @group user
*/
......
......@@ -64,11 +64,10 @@ public function adminSummary() {
case 'asc':
default:
return $this->t('asc');
break;
case 'DESC';
case 'desc';
return $this->t('desc');
break;
}
}
......
......@@ -69,8 +69,7 @@ public function testTranslationRows() {
$translation->save();
$this->drupalGet('test_entity_field_renderers/entity_translation');
$this->assertRows(
[
$this->assertRows([
[
'title' => 'example EN',
'sticky' => 'Off',
......@@ -82,8 +81,7 @@ public function testTranslationRows() {
]);
$this->drupalGet('test_entity_field_renderers/entity_default');
$this->assertRows(
[
$this->assertRows([
[
'title' => 'example EN',
'sticky' => 'Off',
......@@ -95,8 +93,7 @@ public function testTranslationRows() {
]);
$this->drupalGet('test_entity_field_renderers/site_default');
$this->assertRows(
[
$this->assertRows([
[
'title' => 'example EN',
'sticky' => 'Off',
......@@ -108,8 +105,7 @@ public function testTranslationRows() {
]);
$this->drupalGet('test_entity_field_renderers/language_interface');
$this->assertRows(
[
$this->assertRows([
[
'title' => 'example EN',
'sticky' => 'Off',
......@@ -121,8 +117,7 @@ public function testTranslationRows() {
]);
$this->drupalGet('test_entity_field_renderers/language_interface', ['language' => new Language(['id' => 'es'])]);
$this->assertRows(
[
$this->assertRows([
[
'title' => 'example ES',
'sticky' => 'On',
......@@ -134,8 +129,7 @@ public function testTranslationRows() {
]);
$this->drupalGet('test_entity_field_renderers/en');
$this->assertRows(
[
$this->assertRows([
[
'title' => 'example EN',
'sticky' => 'Off',
......@@ -147,8 +141,7 @@ public function testTranslationRows() {
]);
$this->drupalGet('test_entity_field_renderers/es');
$this->assertRows(
[
$this->assertRows([
[
'title' => 'example ES',
'sticky' => 'On',
......
......@@ -90,7 +90,7 @@ public function build(ViewExecutable $view) {
// @todo You could add a string representation of the query.
$this->view->build_info['query'] = "";
$this->view->build_info['count_query'] = "";
}
}
/**
* {@inheritdoc}
......