getPluginConstantPrefix(); if ($name === null) { return $prefix; } $cname = $prefix . '_' . $name; return defined($cname) ? constant($cname) : null; } /** * Get a new instance of a plugin class from string (supports namespaces, too). * * @param string $name * @param mixed $parameter,... Parameters to the method * @return mixed */ public function getPluginClassInstance($name) { $fqn = $this->getPluginConstant(self::$PLUGIN_CONST_NS) . '\\' . $name; $parameters = array_slice(func_get_args(), 1); return new $fqn(...$parameters); } /** * Get the functions instance. * * @return mixed */ public function getCore() { return call_user_func([$this->getPluginConstant(self::$PLUGIN_CONST_NS) . '\\Core', 'getInstance']); } /** * Get the plugins' constant prefix. Will be overwritten by the UtilsProvider class. * * @return string */ public function getPluginConstantPrefix() { if (defined('CONSTANT_PREFIX')) { return constant('CONSTANT_PREFIX'); } else { // @codeCoverageIgnoreStart error_log(__FILE__ . ': Something went wrong with a newly installed plugin.'); exit(1); // @codeCoverageIgnoreEnd } } }