Inpsyde\MultilingualPress\MultilingualPress::resolve PHP Method

resolve() public static method

Resolve a shared value or factory callback from the container.
Since: 3.0.0
public static resolve ( string $name ) : mixed
$name string The name of a value or factory callback.
return mixed The value or factory callback.
    public static function resolve($name)
    {
        if (!static::$container instanceof Container) {
            throw new BadMethodCallException(sprintf('Cannot resolve "%s". MultilingualPress has not yet been initialised.', $name));
        }
        return static::$container[$name];
    }

Usage Example

Example #1
0
 /**
  * Constructor. Sets up the properties.
  *
  * @since 3.0.0
  */
 public function __construct()
 {
     parent::__construct('Mlp_Widget', __('Language Switcher', 'multilingual-press'), ['classname' => 'mlp_widget', 'description' => __('MultilingualPress Translations', 'multilingual-press'), 'customize_selective_refresh' => true]);
     // TODO: With WordPress 4.6 + 2, inject an asset manager instance.
     if (!isset($this->asset_manager)) {
         $this->asset_manager = MultilingualPress::resolve('multilingualpress.asset_manager');
     }
     // TODO: With WordPress 4.6 + 2, inject a view instance.
     if (!isset($this->view)) {
         $this->view = new WidgetView();
     }
     // Enqueue style if front end and widget is active (ei.e., it appears in a sidebar) or if in Customizer preview.
     if (!is_admin() && is_active_widget(false, false, $this->id_base) || is_customize_preview()) {
         $this->enqueue_style();
     }
 }
All Usage Examples Of Inpsyde\MultilingualPress\MultilingualPress::resolve