Create scool study module using ebre-escool study module.

@param StudyModuleAcademicPeriod $studyModule
@return mixed
@throws \Exception
481713
protected function createModule(StudyModuleAcademicPeriod $studyModule)
    {
        $module = ScoolModule::firstOrNew([
            'name'         => $studyModule->name,
            'study_id'     => $this->getScoolStudy()->id
        ]);
        if($studyModule->study_shortname != $this->getScoolStudy()->shortname) {
            throw new \LogicException(
                'study_shortname in Ebre-escool study module (' . $studyModule->study_shortname
                . ") doesn't match study shortname (" . $this->getScoolStudy()->shortname . ')');
        }
        $module->save();
        $module->order = $studyModule->order;
        $module->shortname = $studyModule->shortname;
        $module->description = $studyModule->description;
        return $module;
    }
309682
protected function _generateModule($oScaffold)
    {
        $oSmarty = $this->_getSmarty();
        $oSmarty->assign('oScaffold', $oScaffold);

        if ($oScaffold->sVendor) {
            $this->_generateVendorDir($oScaffold->sVendor);
        }

        $sModuleDir = $this->_getModuleDir($oScaffold->sVendor, $oScaffold->sModuleName);
        $this->_copyAndParseDir(
            $this->_sTemplatesDir, $sModuleDir, array(
                '_prefix_' => strtolower($oScaffold->sVendor . $oScaffold->sModuleName)
            )
        );
    }
396460
public static function submodule($submodule) {
		if (isset(self::$class_objects['submodule'][$submodule])) {
			return self::$class_objects['submodule'][$submodule];
		} else {
			$class = Application::get($submodule, ['class' => 1]);
			if (empty($class)) {
				Throw new Exception("You must indicate $submodule submodule!");
			}
			self::$class_objects['submodule'][$submodule] = new $class();
			return self::$class_objects['submodule'][$submodule];
		}
	}
1309945
function createModule(module) {
        var moduleInstance,
            moduleId;

        if (typeof module === 'function') {
            try {
                moduleInstance = module();
            } catch (ex) {
                if (module.getId) {
                    moduleId = module.getId();
                } else {
                    moduleId = module.name;
                }

                error('Failed to create an instance of module "' + moduleId + '".',
                      'Application will continue running without the module. ' +
                      'See following exception stack for more details.',
                      ex.stack);
            }
        } else {
            moduleInstance = module;
        }

        addOne(moduleInstances, moduleInstance);

        return moduleInstance;
    }
154147
protected function getEntitiesByModule()
    {
        // A master string tables array (one mst per module)
        $entitiesByModule = array();
        $modules = ModuleLoader::inst()->getManifest()->getModules();
        foreach ($modules as $module) {
            // we store the master string tables
            $processedEntities = $this->processModule($module);
            $moduleName = $module->getName();
            if (isset($entitiesByModule[$moduleName])) {
                $entitiesByModule[$moduleName] = array_merge_recursive(
                    $entitiesByModule[$moduleName],
                    $processedEntities
                );
            } else {
                $entitiesByModule[$moduleName] = $processedEntities;
            }

            // Extract all entities for "foreign" modules ('module' key in array form)
            // @see CMSMenu::provideI18nEntities for an example usage
            foreach ($entitiesByModule[$moduleName] as $fullName => $spec) {
                $specModuleName = $moduleName;

                // Rewrite spec if module is specified
                if (is_array($spec) && isset($spec['module'])) {
                    // Normalise name (in case non-composer name is specified)
                    $specModule = ModuleLoader::inst()->getManifest()->getModule($spec['module']);
                    if ($specModule) {
                        $specModuleName = $specModule->getName();
                    }
                    unset($spec['module']);

                    // If only element is defalt, simplify
                    if (count($spec) === 1 && !empty($spec['default'])) {
                        $spec = $spec['default'];
                    }
                }

                // Remove from source module
                if ($specModuleName !== $moduleName) {
                    unset($entitiesByModule[$moduleName][$fullName]);
                }

                // Write to target module
                if (!isset($entitiesByModule[$specModuleName])) {
                    $entitiesByModule[$specModuleName] = [];
                }
                $entitiesByModule[$specModuleName][$fullName] = $spec;
            }
        }
        return $entitiesByModule;
    }
584703
@Override
    public ApplicationDescriptor javaModule(String uri) {
        model.createChild("module").createChild("java").text(uri);
        return this;
    }
1351149
protected static function _getModuleCache(oxModule $oModule)
    {
        if (self::$_oModuleCache === null) {
            self::$_oModuleCache = oxNew('oxModuleCache', $oModule);
        }

        return self::$_oModuleCache;
    }
1108872
public AbstractPipelineModule createModule(final Class<? extends AbstractPipelineModule> moduleClass)
            throws DITAOTException {
        try {
            return moduleClass.newInstance();
        } catch (final Exception e) {
            final MessageBean msgBean = MessageUtils.getMessage("DOTJ005F", moduleClass.getName());
            final String msg = msgBean.toString();

            throw new DITAOTException(msgBean, e,msg);
        }
    }
1341051
protected static function validate_course_module($cmmixed, $throwexception = true) {
        $cm = $cmmixed;
        if (!is_object($cm)) {
            $cmrecord = get_coursemodule_from_id(null, $cmmixed);
            $modinfo = get_fast_modinfo($cmrecord->course);
            $cm = $modinfo->get_cm($cmmixed);
        } else if (!$cm instanceof cm_info) {
            // Assume we got a course module record.
            $modinfo = get_fast_modinfo($cm->course);
            $cm = $modinfo->get_cm($cm->id);
        }

        if (!$cm->uservisible) {
            if ($throwexception) {
                throw new require_login_exception('Course module is hidden');
            } else {
                return false;
            }
        }

        return true;
    }
667648
public function setModule($module)
        {
            if (null !== $module && !is_string($module)) {
                throw new Exception(
                    'Invalid argument: $module must be a string or null'
                );
            }

            $this->_module    = $module;
            $this->_hrefCache = null;

            return $this;
        }
1213552
public function createModuleZips()
	{
		$path = $this->current . "/modules";

		// Get every module
		$hdl = opendir($path);

		while ($entry = readdir($hdl))
		{
			// Only folders
			$p = $path . "/" . $entry;

			if (substr($entry, 0, 1) == '.')
			{
				continue;
			}

			if (!is_file($p))
			{
				$this->say("Packaging Module " . $entry);

				// Package file
				$zip = new \ZipArchive(JPATH_BASE . "/dist", \ZipArchive::CREATE);

				$zip->open(JPATH_BASE . '/dist/zips/' . $entry . '.zip', \ZipArchive::CREATE);

				$this->say("Module " . $p);

				// Process the files to zip
				$this->addFiles($zip, $p);

				// Close the zip archive
				$zip->close();
			}
		}

		closedir($hdl);
	}
1328922
private function _setModule()
	{
		if (preg_match('/^[a-z0-9_-]+$/', $this->_requestVars[0])) {
			$this->_module = $this->_requestVars[0];
        } else {
        	$this->_module = $this->_requestVars[0] = self::DEFAULT_MODULE;
        }

        return $this;
	}
168043
protected function createSubmodule(StudySubModule $srcSubmodule)
    {
        //First Or new
        $id = $this->SubModuleAlreadyExists($srcSubmodule);
        if ($id != null) {
            $submodule = Submodule::findOrFail($id);
        } else {
            $submodule = new Submodule();
        }

        $submodule->name = $srcSubmodule->name;
        $submodule->order = $srcSubmodule->order;
        $submodule->type = $this->mapTypes($srcSubmodule->type->id);
        $submodule->save();
        $submodule->altnames = [
            'shortname'   => $srcSubmodule->shortname,
            'description' => $srcSubmodule->description
        ];

        $submodule->addModule($this->getScoolModule());
        return $submodule;
    }
685036
public function getModule()
    {
        $method = ArrayHelper::getValue($this->parentWidget->settings, 'queryRole', 'all');
        $relationship = ArrayHelper::getValue($this->parentWidget->settings, 'relationship', false);
        if ($method === 'children') {
            return $relationship->child;
        } elseif ($method === 'parents') {
            return $relationship->parent;
        }

        return false;
    }
843501
public function getClassByModule($module): ?string
    {
        if ($module instanceof Module || $module instanceof ModuleModel) {
            return Module::findClass($module->type);
        }

        if (\is_string($module)) {
            return Module::findClass($module);
        }

        return null;
    }
1116067
public function addModule($moduleName, $modulePath = null, $namespace = null, $moduleContainerClass = null, array $moduleInfo = [])
    {
        if (is_null($namespace)) {
            $namespace = 'Modules\\'.$moduleName;
        }

        $namespace = trim($namespace, '\\');

        $customModuleClass = "\\$namespace\\ModuleContainer";

        if ($moduleName == 'App') {
            $customModuleClass = $this->applicationContainerClass;
        }

        if (is_null($moduleContainerClass) or class_exists($customModuleClass)) {
            $moduleContainerClass = $customModuleClass;
        }

        if (!class_exists($moduleContainerClass)) {
            $moduleContainerClass = class_exists($this->defaultContainerClass)
                ? $this->defaultContainerClass
                : \KodiCMS\ModulesLoader\ModuleContainer::class;
        }

        $moduleContainer = new $moduleContainerClass($moduleName, $modulePath, $namespace, $moduleInfo);

        $this->registerModule($moduleContainer);

        return $this;
    }
14265
protected function create_course_module() {
        global $CFG;
        require_once($CFG->dirroot.'/course/modlib.php');
        list($module, $context, $cw, $cm, $data) = prepare_new_moduleinfo_data($this->course, $this->module->name, $this->section);

        $data->coursemodule = $data->id = add_course_module($data);
        $this->cm = $data;
    }