public function registerAssetBundle($name)
    {
        if (($bundle = $this->getAssetBundleFromView($name)) === false) {
            return $bundle;
        }

        $config = $this->getConfig();

        if (!($module = $config->getModule($name))) {
            $module = $config->addModule($name);
        }

        $options = $bundle->jsOptions;

        if (!isset($options['position'])) {
            $options['position'] = View::POS_END;
        }

        $options['baseUrl'] = $bundle->baseUrl;

        $module->setOptions($options);

        // TODO: think about optimization
        foreach ($bundle->depends as $dependency) {
            if (($dependency = $this->registerAssetBundle($dependency)) !== false) {
                $module->addDependency($dependency);
            }
        }

        $this->importJsFilesFromBundle($bundle, $module);

        return $module;
    }