Registers a widget in the container

@param string $name
@param string|array|\Closure $definition
@param bool $shared

@return $this

@see \Phalcon\DI\Service
494201
public function set($name, $definition, $shared = false)
    {
        /** @var $widget \Phalcon\DI\Service */
        $widget = $this->getDI()->get('\Phalcon\DI\Service', [$name, $definition, $shared]);
        $this->_widgets[$name] = $widget;

        return $this;
    }
1180139
private function register(string $id, bool $shared, Closure $registrationCallback)
    {
        // Check if correct service is provided.
        $this->validateId($id);
        $id = $this->normalize($id);

        // Clean up previous bindings, if any.
        unset($this->instances[$id], $this->shared[$id], $this->keys[$id]);

        // Register service with provided callback.
        $registrationCallback($id);

        // Mark service as shared when needed.
        $this->shared[$id] = $shared ?: null;

        // Save service key to make it recognizable by container.
        $this->keys[$id] = true;
    }
285104
public function register(string $name, Closure $definition)
    {
        $this->registrar->set($name, $definition);
    }
289305
public function set($name, $definition, $shared = true)
    {
        if (true === $this->has($name)) {
            throw new Exception('Service "' . $name . '" already registered');
        }

        switch (true) {
            case is_array($definition):
                $provider = new ServiceProvider($definition);
                $provider->register($name, $this);
                break;

            default:
                $this->payload[$name] = new Factory($this, $definition, $shared);
                $this->payload[$name]->setName($name);
        }

        return $this;
    }
1139461
public static function setShared($name, $definition, $locked = false)
    {
        if (isset(self::$services[$name]) && self::$services[$name]->isLocked()) {
            throw new ServiceLockedException(sprintf('Service "%s" is locked.', $name));
        }

        self::$services[$name] = new Service($name, $definition, true, $locked);
    }
83015
public function register(ShortcodeInterface $shortcode, ?string $name = null): ManagerInterface
    {
        $name = $name ?: $shortcode->getName();

        if (!$name) {
            throw RegisterException::blank();
        } elseif ($this->isRegistered($name)) {
            throw RegisterException::duplicate($name);
        }

        if ($shortcode instanceof ContainerAwareInterface) {
            $shortcode->bind($this);
        }

        $this->shortcodes[$name] = $shortcode;

        return $this;
    }
1163648
public static function register(string $name, $config)
    {
        if (\array_key_exists($name, static::$faucets)) {
            throw new ClientAlreadyRegisteredException("[{$name}] is already exists in the sink.");
        }

        static::$configs[$name] = $config;
    }
1010419
public function register($name, $component)
    {
        // Closure
        if ($component instanceof \Closure) {
            $component = new ComponentDefine($component);
        }

        if ($component instanceof ComponentDefine) {
            $component->setContainer($this);
        }
        elseif (method_exists($component, 'raikiri') && ! $component instanceof ProphecySubjectInterface) {
            $component->setContainer($this);
        }

        $this->components[$name] = $component;
    }
1237807
public function register($name)
    {
        if (class_exists($name)) {
            $this->sidebars[] = $name;
        } else {
            throw new LogicException('Sidebar [' . $name . '] does not exist');
        }

        return $this;
    }
617198
public function register($name, $callback)
    {
        if (! isset($this->registered_menus[$name])) {
            $this->registered_menus[$name] = [];
        }

        $this->registered_menus[$name][] = $callback;

        return $this;
    }
453840
public function set($name, $service, $shared = true)
    {
        return $this->setService($name, $service, $shared);
    }
878510
public function bind($abstract, $concrete = null, $shared = false)
		{
			// If the given types are actually an array, we will assume an alias is being
			// defined and will grab this "real" abstract class name and register this
			// alias with the container so that it can be used as a shortcut for it.
			if (Arrays::is($abstract)) {
				list($abstract, $alias) = $this->extractAlias($abstract);

				$this->alias($abstract, $alias);
			}

			// If no concrete type was given, we will simply set the concrete type to the
			// abstract type. This will allow concrete type to be registered as shared
			// without being forced to state their classes in both of the parameter.
			$this->dropStaleInstances($abstract);

			if (is_null($concrete)) {
				$concrete = $abstract;
			}

			// If the factory is not a Closure, it means it is just a class name which is
			// is bound into this container to the abstract type and we will just wrap
			// it up inside a Closure to make things more convenient when extending.
			if ( ! $concrete instanceof Closure) {
				$concrete = $this->getClosure($abstract, $concrete);
			}

			$bound = $this->bound($abstract);

			$this->bindings[$abstract] = compact('concrete', 'shared');

			// If the abstract type was already bound in this container, we will fire the
			// rebound listener so that any objects which have already gotten resolved
			// can have their copy of the object updated via the listener callbacks.
			if ($bound) {
				$this->rebound($abstract);
			}
		}
125228
protected function _set($name, $definition, $type)
    {
        if ($definition instanceof Closure) {
            $definition = $definition->bindTo($this, get_class($this));
        }
        $this->_definitions[$name] = compact('definition', 'type');
    }
15757
public function registerPartial(string $name, string $partial): Handlebars
    {
        $this->runtime->addPartial($name, $partial);
        return $this;
    }
859268
public function setShared(string $name, bool $flag)
    {
        if (isset($this->services[$name]) && ! $this->allowOverride) {
            throw ContainerModificationsNotAllowedException::fromExistingService($name);
        }
        $this->shared[$name] = $flag;
    }
338516
public static function create($name, $definition)
    {
        if (preg_match('/^(.*?)KEY\s*\((.*?)\)/', $definition, $matches)) {
            return new self([
                'name' => $name,
                'columns' => preg_split('/\s*,\s*/', $matches[2]),
                'type' => trim($matches[1])
            ]);
        } else {
            throw new \InvalidArgumentException("Invalid index definition '$definition'");
        }
    }
688702
static public function widget($name=null)
	{
	    if ($name = static::findClass($name, 'widget')) {
	        $id = 'widget' . ($name ? '.' . $name : '');
	        if (!static::has($id)) {
	            static::setShared($id, function () use ($name) {
	                if ($name instanceof \Wslim\View\Widget) {
	                    return $name::instance();
	                } else {
	                    return new $name;
	                }
	            });
	        }
	        return static::get($id);
	    }
	    return null;
	}