yii\di\ServiceLocator::has PHP 메소드

has() 공개 메소드

This method may return different results depending on the value of $checkInstance. - If $checkInstance is false (default), the method will return a value indicating whether the locator has the specified component definition. - If $checkInstance is true, the method will return a value indicating whether the locator has instantiated the specified component.
또한 보기: set()
public has ( string $id, boolean $checkInstance = false ) : boolean
$id string component ID (e.g. `db`).
$checkInstance boolean whether the method should check if the component is shared and instantiated.
리턴 boolean whether the locator has the specified component definition or has instantiated the component.
    public function has($id, $checkInstance = false)
    {
        return $checkInstance ? isset($this->_components[$id]) : isset($this->_definitions[$id]);
    }

Usage Example

예제 #1
0
 /**
  * Get twocheckout return class instance
  *
  * @access public
  * @return \yii\twocheckout\TwoCheckoutReturn
  */
 public function getReturn()
 {
     if (!$this->locator->has('return')) {
         $this->locator->set('return', '\\yii\\twocheckout\\TwoCheckoutReturn');
     }
     return $this->locator->get('return');
 }
All Usage Examples Of yii\di\ServiceLocator::has