Skip to content

Commit d3216d1

Browse files
committed
CS fixes.
1 parent 1c0c9ca commit d3216d1

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

form_api_example/src/Plugin/Block/SimpleFormBlock.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ class SimpleFormBlock extends BlockBase implements ContainerFactoryPluginInterfa
2727
*
2828
* @var \Drupal\Core\Form\FormBuilderInterface
2929
*/
30-
protected $form_builder;
30+
protected $formBuilder;
3131

3232
/**
3333
* {@inheritdoc}
3434
*/
3535
public function __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilderInterface $form_builder) {
3636
parent::__construct($configuration, $plugin_id, $plugin_definition);
37-
$this->form_builder = $form_builder;
37+
$this->formBuilder = $form_builder;
3838
}
3939

4040
/**
@@ -55,7 +55,7 @@ public static function create(ContainerInterface $container, array $configuratio
5555
public function build() {
5656
$output = [
5757
'description' => [
58-
'#markup' => $this->t('Using form provided by ' . SimpleForm::class),
58+
'#markup' => $this->t('Using form provided by @classname', ['@classname' => SimpleForm::class]),
5959
],
6060
];
6161

@@ -66,7 +66,7 @@ public function build() {
6666
//
6767
// In this case the build() method of a block plugin is expected to return
6868
// a render array so we add the form to the existing output and return it.
69-
$output['form'] = $this->form_builder->getForm(SimpleForm::class);
69+
$output['form'] = $this->formBuilder->getForm(SimpleForm::class);
7070
return $output;
7171
}
7272

form_api_example/tests/src/Functional/SimpleFormBlockTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Drupal\Tests\form_api_example\Functional;
44

5-
use Drupal\Core\Url;
65
use Drupal\Tests\BrowserTestBase;
76

87
/**

session_example/src/Form/SessionExampleForm.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Drupal\session_example\Form;
44

5+
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
56
use Drupal\Core\Form\FormBase;
67
use Drupal\Core\Form\FormStateInterface;
78
use Drupal\Core\Link;
89
use Symfony\Component\DependencyInjection\ContainerInterface;
9-
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
1010
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1111

1212
/**
@@ -37,17 +37,19 @@ class SessionExampleForm extends FormBase {
3737
*
3838
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
3939
*/
40-
protected $cache_tag_invalidator;
40+
protected $cacheTagInvalidator;
4141

4242
/**
4343
* Constructs a new SessionExampleForm object.
4444
*
45-
* @param \Symfony\Component\HttpFoundation\Session\SessionInterface
45+
* @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
4646
* The session object.
47+
* @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $invalidator
48+
* The cache tag invalidator service.
4749
*/
4850
public function __construct(SessionInterface $session, CacheTagsInvalidatorInterface $invalidator) {
4951
$this->session = $session;
50-
$this->cache_tag_invalidator = $invalidator;
52+
$this->cacheTagInvalidator = $invalidator;
5153
}
5254

5355
/**
@@ -155,7 +157,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
155157
// Tell the user what happened here, and that they can look at another page
156158
// to see the result.
157159
$this->messenger()->addMessage($this->t('The session has been saved successfully. @link', [
158-
'@link' => Link::createFromRoute('Check here.', 'session_example.view')->toString()
160+
'@link' => Link::createFromRoute('Check here.', 'session_example.view')->toString(),
159161
]));
160162
// Since we might have changed the session information, we will invalidate
161163
// the cache tag for this session.
@@ -188,7 +190,7 @@ public function submitClearSession(array &$form, FormStateInterface $form_state)
188190
* updates their information in the submit handlers.
189191
*/
190192
protected function invalidateCacheTag() {
191-
$this->cache_tag_invalidator->invalidateTags(['session_example:' . $this->session->getId()]);
193+
$this->cacheTagInvalidator->invalidateTags(['session_example:' . $this->session->getId()]);
192194
}
193195

194196
}

session_example/tests/src/Functional/SessionExampleTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class SessionExampleTest extends BrowserTestBase {
1717

1818
public static $modules = ['session_example', 'block'];
1919

20+
/**
21+
* {@inheritdoc}
22+
*/
2023
protected function setUp() {
2124
parent::setUp();
2225
// Place our blocks.
@@ -119,6 +122,9 @@ public function testSessionExample() {
119122
$assert->pageTextContains('No color');
120123
}
121124

125+
/**
126+
* Ensure the session data does not follow different users around.
127+
*/
122128
public function testUserIsolation() {
123129
$assert = $this->assertSession();
124130
// Our setUp() method has already logged in a user, so let's add some data.

0 commit comments

Comments
 (0)