Skip to content

Commit

Permalink
Merge pull request #6141 from kurozumi/customize-bundle
Browse files Browse the repository at this point in the history
CustomizeディレクトリからSymfony Bundleをインストールできるよう修正
  • Loading branch information
dotani1111 authored Jun 24, 2024
2 parents 2791d1f + 6350e49 commit 614013d
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Eccube/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ public function registerBundles(): iterable
}
}
}

$customizeBundles = $this->getProjectDir().'/app/Customize/Resource/config/bundles.php';
if (file_exists($customizeBundles)) {
$contents = require $customizeBundles;
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
yield new $class();
}
}
}
}

/**
Expand Down
57 changes: 57 additions & 0 deletions tests/Eccube/Tests/CustomizeBundleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Eccube\Tests;

use Customize\Bundle\CustomizeBundle;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Filesystem\Filesystem;

class CustomizeBundleTest extends KernelTestCase
{
public function tearDown(): void
{
$fs = new Filesystem();
$fs->remove(__DIR__.'/../../../app/Customize/Bundle');
$fs->remove(__DIR__.'/../../../app/Customize/Resource/config/bundles.php');

parent::tearDown();
}

public function testContainsCustomizeBundle()
{
$fs = new Filesystem();
$originDir = __DIR__.'/../../Fixtures/Customize';
$targetDir = __DIR__.'/../../../app/Customize';
$fs->mirror($originDir, $targetDir);

$kernel = static::bootKernel();
$bundleNames = [];
foreach ($kernel->getBundles() as $bundle) {
$bundleNames[] = get_class($bundle);
}

self::assertContains(CustomizeBundle::class, $bundleNames);
}

public function testNotContainsCustomizeBundle()
{
$kernel = static::bootKernel();
$bundleNames = [];
foreach ($kernel->getBundles() as $bundle) {
$bundleNames[] = get_class($bundle);
}

self::assertNotContains(CustomizeBundle::class, $bundleNames);
}
}
21 changes: 21 additions & 0 deletions tests/Fixtures/Customize/Bundle/CustomizeBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Customize\Bundle;

use Customize\DependencyInjection\CustomizeExtension;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class CustomizeBundle extends Bundle
{
}
16 changes: 16 additions & 0 deletions tests/Fixtures/Customize/Resource/config/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return [
Customize\Bundle\CustomizeBundle::class => ['all' => true],
];

0 comments on commit 614013d

Please sign in to comment.