/** * Resolves (named) binding for given type. * * @param string $type_ * @param string $name_ * * @return \Components\Binding_Type_Abstract * * @throws \Components\Binding_Exception If failed to resolve binding. */ public function getBinding($type_, $name_ = null) { $hashCode = Binding_Builder::createHashCode($type_, $name_); if (isset($this->m_bindings[$hashCode])) { return $this->m_bindings[$hashCode]; } if ($native = Primitive::asNative($type_)) { $hashCode = Binding_Builder::createHashCode($native, $name_); if (isset($this->m_bindings[$hashCode])) { return $this->m_bindings[$hashCode]; } } if (false === $this->m_initialized) { throw new Binding_Exception('inject/binding/module', 'Not initialized.'); } return null; }
/** * The combination of binding type+name is unique, therefore we use * this key as the bindings hashcode for identification in binding * configuration. * * @see \Components\Object::hashCode() hashCode */ public function hashCode() { if (null === $this->m_hashCode) { $this->m_hashCode = Binding_Builder::createHashCode($this->m_type, $this->m_name); } return $this->m_hashCode; }