Register a binding if it hasn't already been registered.

@param string $id
@param null   $value
@param bool   $singleton
333342
public function bind_if( $id, $value = null, $singleton = false ) {
		if ( ! $this->bound( $id ) ) {
			$this->bind( $id, $value, $singleton );
		}
	}
640652
public function onSessionInit($value) {
        if(!$value->offsetExists("value")) {
            return;
        }

        $value = $value->offsetGet("value");

        foreach($this->getFormElements() as $name => $child) {
            if(!$value->offsetExists($name)) continue;

            $newvalue = $value->offsetGet($name);

            $child->setValue($newvalue);

            //check if child did some processing/initializing on object values - keep sync

            $childvalue = $child->getValue();

            if($newvalue !== $childvalue) {
                $value->offsetSet($name, $childvalue);
            }
        }
    }
1099234
public static function bindInstance($instance, $methodName, $args = null)
    {
        $helper = new self();
        return $helper->createClosure($methodName, $args)->bindTo($instance, get_class($instance));
    }
486783
public function set(string $id, $definition, $params = [])
    {
        return $this->register($id, $definition, $params);
    }
80155
public function bind($abstract, $concrete = null, $singleton = false)
    {
        if (is_array($abstract)) {
            list($abstract, $alias) = [key($abstract), current($abstract)];
            $this->alias($abstract, $alias);
        }

        $abstract = $this->filter($abstract);
        $concrete = $this->filter($concrete);

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

        $this->binds[$abstract] = compact('concrete', 'singleton');
        return $this;
    }
370140
public function offsetSet($id, $value)
    {
        if ($this->locked) {
            throw new BadMethodCallException('Setting values into a locked container is not allowed');
        }

        if ($value instanceof JuiceParam) {
            $this->values[$id] = $value->value;
            return;
        }

        if (is_callable($value) || $value instanceof JuiceDefinition) {
            $this->definitions[$id] = $value;
            return;
        }

        if (is_string($value) && '@' == $value[0]) {
            $this->aliases[$id] = substr($value, 1);
            return;
        }

        $this->values[$id] = $value;
    }
552660
public function share(string $id, Closure $value, array $tags = []): void
    {
        $value = function ($container) use ($value) {
            static $sharedValue;

            if ($sharedValue === null) {
                $sharedValue = $value($container);
            }

            return $sharedValue;
        };
        $this->set($id, $value, $tags);
    }
1259860
public function is_singleton( $id ) {
		if ( ! is_string( $id ) ) {
			throw new InvalidArgumentException( 'Invalid argument. Must be string.' );
		}

		if ( ! $this->bound( $id ) ) {
			return false;
		}

		$id = $this->get_class_prefix( $id );

		return $this->bindings[$id]['singleton'] === true;
	}
398496
public function registerDataProvider($id, $provider, $interface, $compatibilities, $listeners)
    {
        foreach ($compatibilities as $compatibility) {
            $this->providersByCompatibility[$provider][$compatibility['title']][$compatibility['gamemode']][$compatibility['script']] = $id;
        }

        $this->providerListeners[$id] = [];
        foreach ($listeners as $eventName => $method) {
            $this->providerListeners[$id][] = new ProviderListener($eventName, $provider, $method);
        }
        $this->providerInterfaces[$provider] = $interface;
        $this->providerById[$id] = $provider;
    }
1272957
public function register($identifier, $value)
    {
        if ($this->isRegistered($identifier)) {
            throw new RegistryException(
                RegistryException::DUPLICATE_REGISTRATION_ATTEMPT_TEXT . '(identifier: ' . $identifier . ')',
                RegistryException::DUPLICATE_REGISTRATION_ATTEMPT_CODE
            );
        }

        $this->registry[$this->section][$identifier] = $value;
    }
1133887
public function setPermissionState(int $id, bool $value): void
	{
		if ($this->isAjax()) {
			$permission = $this->orm->acl->getById($id);
			$permission->allowed = $value;
			$this->orm->persistAndFlush($permission);

			$this->flashNotifier->success('default.dataSaved');

			$this['permissionsList']->redrawItem($id);
		} else {
			$this->terminate();
		}
	}
498199
public function setRule ($identifier, callable $rule, $singleton = false)
		{
			if (! is_bool($singleton)) {
				throw new DependencyException('The singleton parameter must be boolean.');
			}

			if ($singleton) {
				$this->setSingletonRule($identifier, $rule);
			} else {
				$this->rules[$identifier] = new CallbackRule($this, $rule);
			}

			return $this;
		}
518378
public function setRoleParent(int $id, string $value): void
	{
		if ($this->isAjax()) {
			$role = $this->orm->aclRoles->getById($id);
			$role->parent = $value;
			$this->orm->persistAndFlush($role);

			$this->flashNotifier->success('default.dataSaved');
			$this['rolesList']->redrawItem($id);
		} else {
			$this->terminate();
		}
	}
489057
public function bind($id, $object, $immutable = true, $singleton = false)
    {
        if (isset($this->bindings[$id])) {
            if (isset($this->immutables[$id])) {
                throw new ConflictException($this->bindings[$id], new ConflictException($id));
            }

            unset($this->singletons[$id]);
            unset($this->immutables[$id]);
        }

        $this->bindings[$id] = $object;

        if ($immutable) {
            $this->immutables[$id] = true;
        }

        if ($singleton) {
            $this->singletons[$id] = true;
        }
    }
464407
public void setHeaderValue(String name,String value)
    {
        _fields.put(name,Collections.singletonList(value));
    }
424608
public function createExists($id, $value, $ttl = null)
    {
        return $this->create($id, $value, $ttl, true);
    }
1188371
public function singleton($key, $value)
    {
        $this->set($key, function ($c) use ($value) {
            static $object;

            if (null === $object) {
                $object = $value($c);
            }

            return $object;
        });
    }