Kernel::getLogDir()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * Donut Social Network - Yet another experimental social network.
5
 * Copyright (C) 2016-2018, Dejan Angelov <[email protected]>
6
 *
7
 * This file is part of Donut Social Network.
8
 *
9
 * Donut Social Network is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation, either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * Donut Social Network is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with Donut Social Network.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 * @package Donut Social Network
23
 * @copyright Copyright (C) 2016-2018, Dejan Angelov <[email protected]>
24
 * @license https://github.com/angelov/donut/blob/master/LICENSE
25
 * @author Dejan Angelov <[email protected]>
26
 */
27
28
namespace AppBundle;
29
30
use Angelov\Donut\Core\CommandBus\AutoconfigureCommandHandlersCompilerPass;
31
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
32
use Symfony\Component\Config\Loader\LoaderInterface;
33
use Symfony\Component\Config\Resource\FileResource;
34
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
35
use Symfony\Component\DependencyInjection\ContainerBuilder;
36
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
37
use Symfony\Component\Routing\RouteCollectionBuilder;
38
39
class Kernel extends BaseKernel
40
{
41
    use MicroKernelTrait;
42
43
    const CONFIG_EXTS = '.{php,xml,yaml,yml}';
44
45
    public function getCacheDir()
46
    {
47
        return $this->getProjectDir().'/var/cache/'.$this->environment;
48
    }
49
50
    public function getLogDir()
51
    {
52
        return $this->getProjectDir().'/var/log';
53
    }
54
55
    public function registerBundles()
56
    {
57
        $contents = require $this->getProjectDir().'/config/bundles.php';
58
        foreach ($contents as $class => $envs) {
59
            if (isset($envs['all']) || isset($envs[$this->environment])) {
60
                yield new $class();
0 ignored issues
show
Bug Best Practice introduced by
The expression yield new $class() returns the type Generator which is incompatible with the return type mandated by Symfony\Component\HttpKe...face::registerBundles() of Symfony\Component\HttpKe...dleInterface[]|iterable.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
61
            }
62
        }
63
    }
64
65
    protected function build(ContainerBuilder $container)
66
    {
67
        $container->addCompilerPass(new AutoconfigureCommandHandlersCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1000);
68
    }
69
70
    protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
71
    {
72
        $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
73
        // Feel free to remove the "container.autowiring.strict_mode" parameter
74
        // if you are using symfony/dependency-injection 4.0+ as it's the default behavior
75
        $container->setParameter('container.autowiring.strict_mode', true);
76
        $container->setParameter('container.dumper.inline_class_loader', true);
77
        $confDir = $this->getProjectDir().'/config';
78
79
        $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
80
        $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
81
        $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
82
        $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
83
    }
84
85
    protected function configureRoutes(RouteCollectionBuilder $routes)
86
    {
87
        $confDir = $this->getProjectDir().'/config';
88
89
        $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
90
        $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
91
        $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
92
    }
93
}
94