本文整理汇总了PHP中Yii::configure方法的典型用法代码示例。如果您正苦于以下问题:PHP Yii::configure方法的具体用法?PHP Yii::configure怎么用?PHP Yii::configure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Yii
的用法示例。
在下文中一共展示了Yii::configure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param array $config
* @throws \yii\base\InvalidConfigException
* @internal param array $params
*/
public function __construct($config = [])
{
$this->app = \Yii::$app;
$this->language = $this->app->language;
\Yii::configure($this, $config);
$this->init();
}
示例2: __construct
function __construct(array $config)
{
if (static::$_instance !== null) {
throw new \Exception();
}
$providerOptions = ArrayHelper::getValue($config, 'server.provider', []);
$internalOptions = ArrayHelper::getValue($config, 'server.internal', []);
$cacheConfig = ArrayHelper::getValue($config, 'server.cache', []);
$yiiAppClass = ArrayHelper::getValue($config, 'server.yiiAppClass', 'vitprog\\wamp\\server\\YiiWampApplication');
$providerClass = ArrayHelper::getValue($providerOptions, 'class', '\\Thruway\\Transport\\RatchetTransportProvider');
$internalClass = ArrayHelper::getValue($internalOptions, 'class', '\\vitprog\\wamp\\server\\InternalClient');
$cacheClass = ArrayHelper::getValue($cacheConfig, 'class', '\\yii\\caching\\FileCache');
$realm = ArrayHelper::getValue($config, 'server.realm', 'realm1');
$basePath = ArrayHelper::getValue($config, 'yii.basePath', null);
if ($basePath == null) {
die('yii.basePath not set');
}
if (ArrayHelper::getValue($config, 'yii.vendorPath', null) == null) {
$config['yii']['vendorPath'] = realpath($basePath . '/vendor');
}
if (ArrayHelper::getValue($config, 'yii.runtimePath', null) == null) {
$config['yii']['runtimePath'] = realpath($basePath . '/runtime');
}
$app = new $yiiAppClass($config['yii']);
$this->cache = \Yii::createObject($cacheClass, $cacheConfig);
$this->router = new Router();
$this->provider = new $providerClass(ArrayHelper::getValue($providerOptions, 'address', 'localhost'), ArrayHelper::getValue($providerOptions, 'port', '8080'));
$this->router->addTransportProvider($this->provider);
$this->internal = new $internalClass($realm);
\Yii::configure($this->internal, $internalOptions);
$this->router->addInternalClient($this->internal);
\Yii::$app->setComponents(['wampDeamon' => $this, 'wampRouter' => $this->router, 'wampInternal' => $this->internal, 'wampCache' => $this->cache]);
static::$_instance = $this;
}
示例3: init
public function init()
{
parent::init();
$request = AH::merge(['wrapper' => 'results', 'term' => 'search:term'], $this->uses);
$requests = [];
$back_request = [];
foreach ($request as $k => $v) {
if ($k === 'term') {
$requests[] = $v;
} elseif (is_array($v)) {
$requests[] = "{$k}:" . json_encode($v);
$back_request[] = "{$k}:" . json_encode($v);
} else {
$requests[] = "{$k}:'{$v}'";
$back_request[] = "{$k}:'{$v}'";
}
}
\Yii::configure($this, ['format' => 'html', 'filterInputOptions' => ['id' => 'id'], 'filter' => Select2::widget(['attribute' => 'id', 'model' => $this->grid->filterModel, 'url' => Url::toRoute(['list']), 'settings' => ['ajax' => ['data' => new JsExpression('function(term,page) { return {' . implode(', ', $requests) . '}; }')], 'initSelection' => new JsExpression('function (elem, callback) {
var id=$(elem).val();
$.ajax("' . Url::toRoute(['list']) . '?id=" + id, {
dataType: "json",
data : {' . implode(', ', $back_request) . '}
}).done(function(data) {
callback(data.results[0]);
});
}')]])]);
}
示例4: init
public function init()
{
parent::init();
//$this->params['foo'] = 'bar';
// ... other initialization code ...
\Yii::configure($this, require __DIR__ . '/config.php');
}
示例5: init
public function init()
{
parent::init();
\Yii::configure($this, ['attribute' => 'email', 'label' => \Yii::t('hipanel', 'Email'), 'format' => 'html', 'value' => function ($model) {
return Html::a($model->client ?: $model->login, ['/client/contact/view', 'id' => $model->client ? $model->client_id : $model->id]);
}, 'filterInputOptions' => ['email' => 'email'], 'filter' => Select2::widget(['attribute' => 'email', 'model' => $this->grid->filterModel, 'url' => Url::toRoute(['/client/contact/email-list'])])]);
}
示例6: run
/**
* @param array $config
*
* @since 1.0
* @author Choate <choate.yao@gmail.com>
* @return DepControl
* @throws \yii\base\InvalidConfigException
*/
public static function run(array $config = [])
{
$object = \Yii::createObject(array_merge($config, ['class' => DepControl::className()]));
if (!empty($config)) {
\Yii::configure($object, $config);
}
return $object;
}
示例7: init
public function init()
{
parent::init();
// custom initialization code goes here
\Yii::configure($this, require __DIR__ . '/config/config.php');
$this->modules = ['front' => ['class' => 'app\\modules\\post\\modules\\front\\Module'], 'admin' => ['class' => 'app\\modules\\post\\modules\\admin\\Module']];
$this->registerTranslations();
}
示例8: init
public function init()
{
parent::init();
if (\Yii::$app instanceof \yii\console\Application) {
$this->controllerNamespace = 'app\\modules\\api\\commands';
}
\Yii::configure($this, require __DIR__ . '/config/config.php');
}
示例9: loadConfig
/**
* @param string $path
* @throws InvalidConfigException
*/
public function loadConfig($path)
{
if (file_exists($path)) {
$config = (require $path);
\Yii::configure($this, $config);
} else {
throw new InvalidConfigException('installer', 'Конфигурационный файл не найден [{f}]', ['f' => $path]);
}
}
示例10: load
/**
* Prepare and merge actions for particular object
* @param array $value Items options
* @return array List of prepared object for particular active object
*/
public function load(array $newItems)
{
if (!$newItems || !is_array($newItems)) {
return;
}
$collection = [];
foreach ($newItems as $name => $item) {
if ($item === '*') {
// if exists char "*" than load previous steps
if ($this->_collection) {
foreach ($this->_collection as $key => $existedItem) {
$collection[$key] = $existedItem;
}
}
// } else if ($item === '-') {
// unset($this->_collection[$name]);
} else {
if (is_string($item) && is_int($name)) {
if (!preg_match('/^([\\w\\.]+)(:(\\w*))?(:(.*))?$/', $item, $matches)) {
throw new CException(Yii::t('zii', 'The column must be specified in the format of "Name:Type:Label", where "Type" and "Label" are optional.'));
}
$name = $matches[1];
$item = [];
if (isset($matches[3]) && $matches[3] !== '') {
$item['type'] = $matches[3];
}
if (isset($matches[5])) {
$item['text'] = $matches[5];
}
}
}
if (is_array($item)) {
// if only necessary to add params
if (substr($name, 0, 1) === '+') {
$name = substr($name, 1, strlen($name) - 1);
$instance = $this->_collection[$name];
Yii::configure($instance, $item);
} else {
// create new component
if (empty($item['name'])) {
$item['name'] = $name;
}
$instance = $this->createObject($item);
}
if ($instance) {
$collection[$name] = $instance;
}
}
// Remove control if returns false
if (!$item && $name && (isset($collection[$name]) || isset($this->_collection[$name]))) {
unset($collection[$name]);
unset($this->_collection[$name]);
}
}
$this->_collection = $collection;
return $this->_collection;
}
示例11: loadWithData
/**
* @inheritdoc
*/
public function loadWithData($data, $fast = false)
{
$attributes = ['href' => ArrayHelper::getValue($data, 'href'), 'height' => ArrayHelper::getValue($data, 'height'), 'width' => ArrayHelper::getValue($data, 'width'), 'byteSize' => ArrayHelper::getValue($data, 'bytesize'), 'size' => ArrayHelper::getValue($data, 'size')];
if ($fast) {
\Yii::configure($this, $attributes);
} else {
$this->load([$this->formName() => $attributes]);
}
return $this;
}
示例12: init
public function init()
{
parent::init();
$authManager = Yii::$app->getAuthManager();
if (!$authManager instanceof DbManager) {
throw new InvalidConfigException('You should configure "authManager" component of this Yii2 application to use this module.');
}
// initialize the module with the configuration loaded from config.php
\Yii::configure($this, require __DIR__ . '/config/config.php');
}
示例13: loadWithData
/**
* @inheritdoc
*/
public function loadWithData($data, $fast = false)
{
$attributes = ['name' => ArrayHelper::getValue($data, 'name'), 'uid' => ArrayHelper::getValue($data, $this->getUidParser())];
if ($fast) {
\Yii::configure($this, $attributes);
} else {
$this->load([$this->formName() => $attributes]);
}
return $this;
}
示例14: loadWithData
/**
* @inheritdoc
*/
public function loadWithData($data, $fast = false)
{
$attributes = ['zoomLevel' => ArrayHelper::getValue($data, 'zoomlevel'), 'type' => ArrayHelper::getValue($data, 'type'), 'mapType' => ArrayHelper::getValue($data, 'maptype'), 'coordinates' => ArrayHelper::getValue($data, $this->getCoordinatesParser('coordinates'))];
if ($fast) {
\Yii::configure($this, $attributes);
} else {
$this->load([$this->formName() => $attributes]);
}
return $this;
}
示例15: init
public function init()
{
parent::init();
Event::on(Supervisor::className(), Supervisor::EVENT_CONFIG_CHANGED, function () {
exec('supervisorctl update', $output, $status);
});
\Yii::configure($this, require __DIR__ . '/config.php');
$this->params['supervisorConnection'] = array_merge($this->params['supervisorConnection'], $this->authData);
$this->registerIoC();
}