src/sms/Sms.php
public function set($id, $definition)
    {
        unset($this->_gateways[$id]);

        if ($definition === null) {
            unset($this->_definitions[$id]);
            return;
        }

        if (is_object($definition) || is_callable($definition, true)) {
            // an object, a class name, or a PHP callable
            $this->_definitions[$id] = $definition;
        } elseif (is_array($definition)) {
            // a configuration array
            if (isset($definition['class'])) {
                $this->_definitions[$id] = $definition;
            } else {
                throw new InvalidConfigException("The configuration for the \"$id\" gateway must contain a \"class\" element.");
            }
        } else {
            throw new InvalidConfigException("Unexpected configuration type for the \"$id\" gateway: " . gettype($definition));
        }
    }
public function set($id, $definition)
    {
        unset($this->_gateways[$id]);

        if ($definition === null) {
            unset($this->_definitions[$id]);
            return;
        }

        if (is_object($definition) || is_callable($definition, true)) {
            // an object, a class name, or a PHP callable
            $this->_definitions[$id] = $definition;
        } elseif (is_array($definition)) {
            // a configuration array
            if (isset($definition['class'])) {
                $this->_definitions[$id] = $definition;
            } else {
                throw new InvalidConfigException("The configuration for the \"$id\" gateway must contain a \"class\" element.");
            }
        } else {
            throw new InvalidConfigException("Unexpected configuration type for the \"$id\" gateway: " . gettype($definition));
        }
    }
public function set ( $ id , $ definition ) { unset ( $ this -> _gateways [ $ id ] ) ; if ( $ definition === null ) { unset ( $ this -> _definitions [ $ id ] ) ; return ; } if ( is_object ( $ definition ) || is_callable ( $ definition , true ) ) { // an object, a class name, or a PHP callable $ this -> _definitions [ $ id ] = $ definition ; } elseif ( is_array ( $ definition ) ) { // a configuration array if ( isset ( $ definition [ 'class' ] ) ) { $ this -> _definitions [ $ id ] = $ definition ; } else { throw new InvalidConfigException ( "The configuration for the \"$id\" gateway must contain a \"class\" element." ) ; } } else { throw new InvalidConfigException ( "Unexpected configuration type for the \"$id\" gateway: " . gettype ( $ definition ) ) ; } }
Registers a gateway definition with this locator.

For example,

```php
// a class name
$locator->set('cache', 'yii\caching\FileCache');

// a configuration array
$locator->set('db', [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=127.0.0.1;dbname=demo',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
]);

// an anonymous function
$locator->set('cache', function ($params) {
return new \yii\caching\FileCache;
});

// an instance
$locator->set('cache', new \yii\caching\FileCache);
```

If a filesystem definition with the same ID already exists, it will be overwritten.

@param string $id filesystem ID (e.g. `db`).
@param mixed $definition the filesystem definition to be registered with this locator.
It can be one of the following:

- a class name
- a configuration array: the array contains name-value pairs that will be used to
initialize the property values of the newly created object when [[get()]] is called.
The `class` element is required and stands for the the class of the object to be created.
- a PHP callable: either an anonymous function or an array representing a class method (e.g. `['Foo', 'bar']`).
The callable will be called by [[get()]] to return an object associated with the specified filesystem ID.
- an object: When [[get()]] is called, this object will be returned.

@throws InvalidConfigException if the definition is an invalid configuration array
Registers a gateway definition with this locator .