1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* WellCommerce Open-Source E-Commerce Platform |
4
|
|
|
* |
5
|
|
|
* This file is part of the WellCommerce package. |
6
|
|
|
* |
7
|
|
|
* (c) Adam Piotrowski <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, |
10
|
|
|
* please view the LICENSE file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace WellCommerce\Bundle\CoreBundle\HttpKernel; |
14
|
|
|
|
15
|
|
|
use Doctrine\Common\Collections\Collection; |
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
17
|
|
|
use Symfony\Component\HttpKernel\Bundle\Bundle; |
18
|
|
|
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterControllerPass; |
19
|
|
|
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterDataGridPass; |
20
|
|
|
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterDataSetPass; |
21
|
|
|
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterEntityFactoryPass; |
22
|
|
|
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterFormBuilderPass; |
23
|
|
|
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterManagerPass; |
24
|
|
|
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterRepositoryPass; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Class AbstractWellCommerceBundle |
28
|
|
|
* |
29
|
|
|
* @author Adam Piotrowski <[email protected]> |
30
|
|
|
*/ |
31
|
|
|
abstract class AbstractWellCommerceBundle extends Bundle |
32
|
|
|
{ |
33
|
|
|
public function build(ContainerBuilder $container) |
34
|
|
|
{ |
35
|
|
|
parent::build($container); |
36
|
|
|
|
37
|
|
|
$container->addCompilerPass(new AutoRegisterRepositoryPass($this)); |
38
|
|
|
$container->addCompilerPass(new AutoRegisterEntityFactoryPass($this)); |
39
|
|
|
$container->addCompilerPass(new AutoRegisterDataSetPass($this)); |
40
|
|
|
$container->addCompilerPass(new AutoRegisterDataGridPass($this)); |
41
|
|
|
$container->addCompilerPass(new AutoRegisterFormBuilderPass($this)); |
42
|
|
|
$container->addCompilerPass(new AutoRegisterManagerPass($this)); |
43
|
|
|
$container->addCompilerPass(new AutoRegisterControllerPass($this)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public static function registerBundles(Collection $bundles, string $environment) |
47
|
|
|
{ |
48
|
|
|
/** |
49
|
|
|
* http://php.net/manual/en/language.oop5.late-static-bindings.php |
50
|
|
|
* Now not need override this method in child class by default |
51
|
|
|
* late static binding returned called instanse an not this(self) |
52
|
|
|
*/ |
53
|
|
|
|
54
|
|
|
$bundles->add(new static()); |
55
|
|
|
|
56
|
|
|
if($environment === 'dev'){ |
|
|
|
|
57
|
|
|
// add bundles for dev |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
This check looks for the bodies of
if
statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.These
if
bodies can be removed. If you have an empty if but statements in theelse
branch, consider inverting the condition.could be turned into
This is much more concise to read.