protected function initialiseModules()
    {
        $this->modules = array();
        $exceptions = array();

        foreach ($this->registerModules($this->environment) as $module) {
            if ($this->isSafeMode() && ! $module->isCoreModule()) {
                continue;
            }

            $name = $module->getName();

            if (isset($this->modules[$name])) {
                throw new \LogicException(sprintf('Trying to register two modules with the same name "%s"', $name));
            }

            $module->boot($this->getContainer());

            $this->modules[$module->getName()] = $module;
        }

        // Go through registered modules and execute post-boot actions
        foreach ($this->modules as $module) {
            $module->postBoot($this->getContainer());
        }

        return $this->modules;
    }