-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from rikwillems/pr/issue-225
issue 225
- Loading branch information
Showing
10 changed files
with
332 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Force Login module for Magento2. | ||
* | ||
* (c) bitExpert AG | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace BitExpert\ForceCustomerLogin\Model; | ||
|
||
use BitExpert\ForceCustomerLogin\Api\Repository\WhitelistRepositoryInterface; | ||
use BitExpert\ForceCustomerLogin\Model\WhitelistDefaultPool; | ||
|
||
/** | ||
* Class WhitelistEntryDefaultInstaller | ||
* | ||
* @package BitExpert\ForceCustomerLogin\Model | ||
* @codingStandardsIgnoreFile | ||
*/ | ||
class WhitelistDefaultInstaller | ||
{ | ||
private WhitelistDefaultPool $whitelistDefaultPool; | ||
private WhitelistRepositoryInterface $whitelistRepository; | ||
|
||
/** | ||
* Installer constructor | ||
*/ | ||
public function __construct( | ||
WhitelistDefaultPool $whitelistDefaultPool, | ||
WhitelistRepositoryInterface $whitelistRepository, | ||
) { | ||
$this->whitelistDefaultPool = $whitelistDefaultPool; | ||
$this->whitelistRepository = $whitelistRepository; | ||
} | ||
|
||
public function install(): void | ||
{ | ||
foreach ($this->whitelistDefaultPool->getEntries() as $route => $data) { | ||
$this->whitelistRepository->createEntry( | ||
null, | ||
$data['label'], | ||
$route, | ||
$data['strategy'] ?: 'default', | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Force Login module for Magento2. | ||
* | ||
* (c) bitExpert AG | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace BitExpert\ForceCustomerLogin\Model; | ||
|
||
/** | ||
* Class WhitelistEntryDefaultPool | ||
* | ||
* @package BitExpert\ForceCustomerLogin\Model | ||
* @codingStandardsIgnoreFile | ||
*/ | ||
class WhitelistDefaultPool | ||
{ | ||
private array $entries = []; | ||
|
||
/** | ||
* Pool constructor | ||
* | ||
* @param array[] $entries | ||
*/ | ||
public function __construct( | ||
array $entries = [] | ||
) { | ||
$this->entries = $entries; | ||
} | ||
|
||
/** | ||
* Get default entries from pool | ||
* | ||
* @return array[string, array] | ||
*/ | ||
public function getEntries(): array | ||
{ | ||
return $this->entries; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace BitExpert\ForceCustomerLogin\Test\DataProviders; | ||
|
||
class WhitelistDataProvider | ||
{ | ||
public static function get(): array | ||
{ | ||
return [ | ||
'default' => [ | ||
[ | ||
'/url1' => [ | ||
'label' => 'label 1', | ||
'strategy' => '', | ||
], | ||
'/url2' => [ | ||
'label' => 'label 2', | ||
'strategy' => 'regex-all', | ||
], | ||
], | ||
], | ||
]; | ||
} | ||
} |
Oops, something went wrong.