Gets a Forum Class for the JFusion Plugin

@param string $platform
@param string $instance name of the JFusion plugin used

@return Platform JFusion Thread class for the JFusion plugin
165257
public static function &getPlatform($platform, $instance)
	{
		static $instances;
		if (!isset($instances)) {
			$instances = array();
		}

		$platform = ucfirst(strtolower($platform));

		//only create a new thread instance if it has not been created before
		if (!isset($instances[$platform][$instance])) {
			$name = static::getNameFromInstance($instance);

			static::pluginAutoLoad($name);

			$class = '\JFusion\Plugins\\' . $name . '\Platform\\' . $platform . '\\Platform';
			if (!class_exists($class)) {
				$class = '\JFusion\Plugin\Platform\\' . $platform;
			}
			if (!class_exists($class)) {
				$class = '\JFusion\Plugin\Platform';
			}
			$instances[$platform][$instance] = new $class($instance);
		}
		return $instances[$platform][$instance];
	}
440538
protected function getConfigInstance($instance)
    {
        if (is_callable($instance)) {
            return call_user_func($instance, $this->app);
        } elseif (is_string($instance)) {
            return $this->app->make($instance);
        }

        return $instance;
    }
449511
protected function getForm(Instance $instance = null)
    {
        if($instance == null) {
            $instance = $this->getManager()->createNew();
        }
        
        return $this->createForm(
            $this->container->get('ringo_php_redmon.form.instance_type'),
            $instance
        );
    }
1114107
protected function showMessage(OutputInterface $output, $instance, $message)
    {
        $methodGet = $this->adapter->getDisplayNameMethod();

        $output->writeln([
            '',
            sprintf($message, strtolower($this->adapter->getShortName()), $instance->$methodGet()),
        ]);
    }
629386
public function getLanguagesInstance($instance = null)
	{
		$languages = false;
		if ($instance != '')
		{
			$languages = $this->scanFiles(ROOT_PATH . '/instances/' . $instance . '/locale', false);
			if (is_array($languages) && count($languages) > 0)
			{
				$locales = array();
				foreach ($languages as $index => $language)
				{
					require_once ROOT_PATH . '/instances/' . $instance . '/locale/' . $language["id"];
					if (isset($translations))
					{
						$locales[$language["id"]]["translations"] = $translations;
						unset($translations);
					}
					else
					{
						$locales[$language["id"]]["translations"] = null;
					}
				}

				$translation_keys = $this->getUniqueTranslationKeys($locales);
				if (is_array($translation_keys)) natcasesort($translation_keys);
				$this->assign("translation_keys", $translation_keys);
				if (is_array($translation_keys))
				{
					$total_keys = count($translation_keys);
					foreach($locales as $language => $value)
					{
						$locales[$language]["total_keys"]				= $total_keys;
						$locales[$language]["translated_keys"]			= count($locales[$language]["translations"]);
						$locales[$language]["translated_percentage"]	= number_format(($locales[$language]["translated_keys"] / $locales[$language]["total_keys"]) * 100, 2, ",", ".")."%";
					}

				}
			}
		}
		return($locales);
	}
569261
public function multiton($alias, $instance = '__default__', array $args = [])
	{
		if (1 === func_num_args())
		{
			$multitons = [];
			foreach ($this->sharedDefinitions as $name => $value)
			{
				if (0 === strpos($name, $alias.'::'))
				{
					$multitons[substr($name, strlen($alias)+2)] = $value;
				}
			}
			return $multitons;
		}

		$name = $alias.'::'.$instance;

		// It is a singleton with a special name
		if ($this->hasShared($name))
		{
			return $this->sharedDefinitions[$name];
		}

		// Disable singleton so the resolved concrete does not gets stored
		if ($this->has($alias) and isset($this->sharedDefinitions[$alias]))
		{
			$previousSingletonSetting = $this->sharedDefinitions[$alias];
			unset($this->sharedDefinitions[$alias]);
			$this->definitions[$alias] = $previousSingletonSetting;
		}

		$concrete = $this->sharedDefinitions[$name] = $this->get($alias, $args);

		// Reset to the previous value
		if (isset($previousSingletonSetting))
		{
			unset($this->definitions[$alias]);
			$this->sharedDefinitions[$alias] = $previousSingletonSetting;
		}

		return $concrete;
	}
858811
public function oauthClientClass($instance = false)
	{
		if (! isset($this->oauth_client_class)) {
			throw new \InvalidArgumentException(static::class . ' does not implement an OAuth Client class definition.');
		}

		return $instance ? new  $this->oauth_client_class : $this->oauth_client_class;
	}
956936
public static function &getUser($instance)
	{
		static $instances;
		if (!isset($instances)) {
			$instances = array();
		}
		//only create a new user instance if it has not been created before
		if (!isset($instances[$instance])) {
			$name = static::getNameFromInstance($instance);

			static::pluginAutoLoad($name);

			$class = '\JFusion\Plugins\\' . $name . '\User';
			if (!class_exists($class)) {
				$class = '\JFusion\Plugin\User';
			}
			$instances[$instance] = new $class($instance);
		}
		return $instances[$instance];
	}
23794
public function getEqualByInstance(CollectionInstanceInterface $instance_in)
    {
        $this->rewind();
        while (!empty($this->current())) {
            if ($this->hasEqualArrays($this->current()->toArray(), $instance_in->toArray())) {
                return $this->current();
            }
            $this->next();
        }
        return null;
    }
575547
protected function get_roleid_options($instance, $context) {
        if ($instance->id) {
            $roles = get_default_enrol_roles($context, $instance->roleid);
        } else {
            $roles = get_default_enrol_roles($context, $this->get_config('roleid'));
        }
        return $roles;
    }
302750
public function get_instance_name($instance) {
        global $DB;

        if (empty($instance)) {
            $enrol = $this->get_name();
            return get_string('pluginname', 'enrol_'.$enrol);
        } else if (empty($instance->name)) {
            $enrol = $this->get_name();
            $course = $DB->get_record('course', array('id'=>$instance->customint1));
            if ($course) {
                $coursename = format_string(get_course_display_name_for_list($course));
            } else {
                // Use course id, if course is deleted.
                $coursename = $instance->customint1;
            }
            return get_string('pluginname', 'enrol_' . $enrol) . ' (' . $coursename . ')';
        } else {
            return format_string($instance->name);
        }
    }
914968
public function get($instanceName) {
		if (!isset($this->objectInstances[$instanceName]) || $this->objectInstances[$instanceName] == null) {
			$this->instantiateComponent($instanceName);
		}
		return $this->objectInstances[$instanceName];
	}
986357
public static function getInstance(): MessageHelper {
		if (empty(self::$instance)) {
			self::$instance = new MessageHelper();
		}

		return self::$instance;
	}
877446
private function get_forum_record() : stdClass {
        $forumdbdatamapper = $this->related['legacydatamapperfactory']->get_forum_data_mapper();
        return $forumdbdatamapper->to_legacy_object($this->forum);
    }
1000994
public static JasperDesign getJasperDesign(final Instance _instance)
        throws EFapsException
    {
        final Checkout checkout = new Checkout(_instance);
        final InputStream source = checkout.execute();
        JasperDesign jasperDesign = null;
        try {
            JasperUtil.LOG.debug("Loading JasperDesign for :{}", _instance);
            final DefaultJasperReportsContext reportContext = DefaultJasperReportsContext.getInstance();
            final JRXmlLoader loader = new JRXmlLoader(reportContext,
                            JRXmlDigesterFactory.createDigester(reportContext));
            jasperDesign = loader.loadXML(source);
        } catch (final ParserConfigurationException e) {
            throw new EFapsException(JasperUtil.class, "getJasperDesign", e);
        } catch (final SAXException e) {
            throw new EFapsException(JasperUtil.class, "getJasperDesign", e);
        } catch (final JRException e) {
            throw new EFapsException(JasperUtil.class, "getJasperDesign", e);
        }
        return jasperDesign;
    }
372119
public function enrol_page_hook(stdClass $instance) {
        global $CFG, $OUTPUT, $SESSION, $USER;

        if ($instance->password === '') {
            return null;
        }

        if (isset($USER->enrol['tempguest'][$instance->courseid]) and $USER->enrol['tempguest'][$instance->courseid] > time()) {
            // no need to show the guest access when user can already enter course as guest
            return null;
        }

        require_once("$CFG->dirroot/enrol/guest/locallib.php");
        $form = new enrol_guest_enrol_form(NULL, $instance);
        $instanceid = optional_param('instance', 0, PARAM_INT);

        if ($instance->id == $instanceid) {
            if ($data = $form->get_data()) {
                // add guest role
                $context = context_course::instance($instance->courseid);
                $USER->enrol_guest_passwords[$instance->id] = $data->guestpassword; // this is a hack, ideally we should not add stuff to $USER...
                if (isset($USER->enrol['tempguest'][$instance->courseid])) {
                    remove_temp_course_roles($context);
                }
                load_temp_course_role($context, $CFG->guestroleid);
                $USER->enrol['tempguest'][$instance->courseid] = ENROL_MAX_TIMESTAMP;

                // go to the originally requested page
                if (!empty($SESSION->wantsurl)) {
                    $destination = $SESSION->wantsurl;
                    unset($SESSION->wantsurl);
                } else {
                    $destination = "$CFG->wwwroot/course/view.php?id=$instance->courseid";
                }
                redirect($destination);
            }
        }

        ob_start();
        $form->display();
        $output = ob_get_clean();

        return $OUTPUT->box($output, 'generalbox');
    }
988174
private function findInstanceByCallbackType($instanceName) {
		// Note: we execute the code in another thread. Always.
		// This prevent crashing the main thread.
		try {
			$fullyQualifiedClassName = MoufReflectionProxy::getReturnTypeFromCode($this->declaredInstances[$instanceName]["code"], $this->getScope() == self::SCOPE_ADMIN);
			unset($this->declaredInstances[$instanceName]["error"]);
			unset($this->declaredInstances[$instanceName]["constructor"]);
			unset($this->declaredInstances[$instanceName]["fieldProperties"]);
			unset($this->declaredInstances[$instanceName]["setterProperties"]);
			unset($this->declaredInstances[$instanceName]["fieldBinds"]);
			unset($this->declaredInstances[$instanceName]["setterBinds"]);
			$this->declaredInstances[$instanceName]["class"] = $fullyQualifiedClassName;
		} catch (\Exception $e) {
			$this->declaredInstances[$instanceName]["error"] = $e->getMessage();
			unset($this->declaredInstances[$instanceName]["class"]);
			$fullyQualifiedClassName = null;
		}
		return $fullyQualifiedClassName;
	}