-
-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CompilerPass to check if framework_bundle.property_access is enab…
…led (#1124)
- Loading branch information
Showing
6 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
fixtures/Bridge/Symfony/Application/config_property_access_disabled.yml
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,23 @@ | ||
# | ||
# This file is part of the Alice package. | ||
# | ||
# (c) Nelmio <hello@nelm.io> | ||
# | ||
# For the full copyright and license information, please view the LICENSE | ||
# file that was distributed with this source code. | ||
# | ||
|
||
framework: | ||
annotations: | ||
enabled: false | ||
secret: NelmioAliceBundleSecret | ||
serializer: | ||
enabled: true | ||
router: | ||
resource: ~ | ||
strict_requirements: '%kernel.debug%' | ||
utf8: true | ||
test: ~ | ||
session: | ||
enabled: false | ||
property_access: false |
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
28 changes: 28 additions & 0 deletions
28
src/Bridge/Symfony/DependencyInjection/Compiler/CheckBundleDependenciesPass.php
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,28 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Alice package. | ||
* | ||
* (c) Nelmio <hello@nelm.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nelmio\Alice\Bridge\Symfony\DependencyInjection\Compiler; | ||
|
||
use LogicException; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class CheckBundleDependenciesPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
if (!$container->has('property_accessor')) { | ||
throw new LogicException('NelmioAliceBundle requires framework_bundle.property_access to be enabled.'); | ||
} | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
tests/Bridge/Symfony/DependencyInjection/CheckBundleDependenciesPassTest.php
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,37 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Alice package. | ||
* | ||
* (c) Nelmio <hello@nelm.io> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nelmio\Alice\Bridge\Symfony\DependencyInjection; | ||
|
||
use LogicException; | ||
use Nelmio\Alice\Symfony\KernelFactory; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @coversNothing | ||
* | ||
* @group integration | ||
*/ | ||
class CheckBundleDependenciesPassTest extends TestCase | ||
{ | ||
public function testPropertyAccessDisabled(): void | ||
{ | ||
static::expectException(LogicException::class); | ||
static::expectExceptionMessage('NelmioAliceBundle requires framework_bundle.property_access to be enabled.'); | ||
|
||
$kernel = KernelFactory::createKernel( | ||
__DIR__.'/../../../../fixtures/Bridge/Symfony/Application/config_property_access_disabled.yml', | ||
); | ||
$kernel->boot(); | ||
} | ||
} |
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