has() public method

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.
See also: 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.
return boolean whether the locator has the specified component definition or has instantiated the component.
コード例 #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');
 }
コード例 #2
0
 /**
  * This method is used to add conditions to query
  *
  * @param string $attribute
  * @param string|array $value
  * @return $this
  */
 public function setAttribute($attribute, $value)
 {
     $query = $this->getQueryInstance();
     if ($this->locator->has($attribute)) {
         /** @var QueryHandlerInterface $specialHandler */
         $specialHandler = $this->locator->get($attribute);
         list($query->query, $query->filter, $query->aggregations) = $specialHandler->handle(['query' => $query->query, 'filter' => $query->filter, 'aggregations' => $query->aggregations, 'value' => $value]);
     } elseif ($this->isValidAttribute($attribute)) {
         $filter = new Term([$attribute => $value]);
         $query->filter->addMust($filter);
     }
     return $this;
 }