Skip to content

Commit 74efb17

Browse files
author
Mike van den Hoek
committed
(refactor): skip prefilling when identification session is active in editor
1 parent 467dab9 commit 74efb17

File tree

14 files changed

+85
-13
lines changed

14 files changed

+85
-13
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
# track this file .gitignore (i.e. do NOT ignore it)
3737
!.gitignore
3838

39-
!.php_cs
39+
!.php-cs-fixer.php
4040

4141
# Eslint
4242
!.eslintrc

.php-cs-fixer.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$finder = PhpCsFixer\Finder::create()
6+
->notPath('vendor')
7+
->notPath('node_modules')
8+
->in(__DIR__)
9+
->in('./resources/views')
10+
->in('./config')
11+
->name('*.php')
12+
->notName('*.blade.php')
13+
->ignoreDotFiles(true)
14+
->ignoreVCS(true);
15+
16+
return (new PhpCsFixer\Config)
17+
->setRules([
18+
'@PSR2' => true,
19+
'array_syntax' => [
20+
'syntax' => 'short',
21+
],
22+
'ordered_imports' => [
23+
'sort_algorithm' => 'alpha',
24+
],
25+
'no_unused_imports' => true,
26+
'binary_operator_spaces' => [
27+
'default' => 'single_space',
28+
'operators' => [
29+
'=>' => null,
30+
'|' => 'no_space',
31+
],
32+
],
33+
'full_opening_tag' => true,
34+
'yoda_style' => [
35+
'always_move_variable' => true,
36+
'equal' => true,
37+
'identical' => true,
38+
'less_and_greater' => true,
39+
],
40+
])
41+
->setFinder($finder);

build/blocks.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '33b24b2f8a8b7ff4f915');
1+
<?php return ['dependencies' => ['react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'], 'version' => '33b24b2f8a8b7ff4f915'];

build/icons.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => '12341f29470476729a0c');
1+
<?php return ['dependencies' => [], 'version' => '12341f29470476729a0c'];

build/style.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array(), 'version' => 'd63fd4982613309d5c57');
1+
<?php return ['dependencies' => [], 'version' => 'd63fd4982613309d5c57'];

src/PrefillGravityForms/Controllers/BaseController.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
use OWC\PrefillGravityForms\Foundation\TeamsLogger;
1212
use OWC\PrefillGravityForms\GravityForms\GravityFormsSettings;
1313
use OWC\PrefillGravityForms\Traits\SessionTrait;
14-
1514
use TypeError;
15+
use WP_Screen;
1616
use function Yard\DigiD\Foundation\Helpers\resolve;
1717

1818
abstract class BaseController
@@ -36,6 +36,17 @@ public function __construct()
3636

3737
abstract public function handle(array $form): array;
3838

39+
protected function isBlockEditor(): bool
40+
{
41+
global $current_screen;
42+
43+
if (! $current_screen instanceof WP_Screen) {
44+
return false;
45+
}
46+
47+
return method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor();
48+
}
49+
3950
public function get(): array
4051
{
4152
return static::makeRequest();

src/PrefillGravityForms/Controllers/EnableUController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace OWC\PrefillGravityForms\Controllers;
46

57
class EnableUController extends BaseController
68
{
79
public function handle(array $form): array
810
{
11+
if ($this->isBlockEditor()) {
12+
return $form;
13+
}
14+
915
$bsn = $this->getBSN();
1016

1117
if (empty($bsn)) {

src/PrefillGravityForms/Controllers/PinkRoccadeController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace OWC\PrefillGravityForms\Controllers;
46

57
class PinkRoccadeController extends BaseController
68
{
79
public function handle(array $form): array
810
{
11+
if ($this->isBlockEditor()) {
12+
return $form;
13+
}
14+
915
$bsn = $this->getBSN();
1016

1117
if (empty($bsn)) {

src/PrefillGravityForms/Controllers/VrijBRPController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class VrijBRPController extends BaseController
88
{
99
public function handle(array $form): array
1010
{
11+
if ($this->isBlockEditor()) {
12+
return $form;
13+
}
14+
1115
$bsn = $this->getBSN();
1216

1317
if (empty($bsn)) {

src/PrefillGravityForms/Controllers/WeAreFrankController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class WeAreFrankController extends BaseController
88
{
99
public function handle(array $form): array
1010
{
11+
if ($this->isBlockEditor()) {
12+
return $form;
13+
}
14+
1115
$bsn = $this->getBSN();
1216

1317
if (empty($bsn)) {

0 commit comments

Comments
 (0)