PHP Method Yii::configure Code Examples

This page contains top rated real world PHP examples of method Yii::configure extracted from open source projects. You can rate examples to help us improve the quality of examples
Example #1
Show file File: Classifier.php Project: opus-online/yii2-classifier
0
 /**
  * @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();
 }
Example #2
Show file File: Daemon.php Project: vitprog/yii2-wamp-server
0
 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;
 }
Example #3
Show file File: CurrentColumn.php Project: hiqdev/hipanel-core
0
 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]);
                     });
                 }')]])]);
 }
Example #4
Show file File: Module.php Project: rocketyang/admap
0
 public function init()
 {
     parent::init();
     //$this->params['foo'] = 'bar';
     // ...  other initialization code ...
     \Yii::configure($this, require __DIR__ . '/config.php');
 }
Example #5
Show file File: EmailColumn.php Project: hiqdev/hipanel-core
0
 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'])])]);
 }
Example #6
Show file File: DepControl.php Project: Choate/coderelease
0
 /**
  * @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;
 }
Example #7
Show file File: Module.php Project: pham186/yii2
0
 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();
 }
Example #8
Show file File: Module.php Project: m-zain/firstphp
0
 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');
 }
Example #9
Show file File: Configurator.php Project: ekup/yii2-installer
0
 /**
  * @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]);
     }
 }
Example #10
Show file File: CollectionMgr.php Project: yariksav/yii2-actives
0
 /**
  * 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;
 }
Example #11
Show file File: Image.php Project: romka-chev/yii2-yandex-fotki
0
 /**
  * @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;
 }
Example #12
Show file File: Module.php Project: vfokov/tims2
0
 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');
 }
Example #13
Show file File: Author.php Project: romka-chev/yii2-yandex-fotki
0
 /**
  * @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;
 }
Example #14
Show file File: Point.php Project: romka-chev/yii2-yandex-fotki
0
 /**
  * @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;
 }
Example #15
Show file File: Module.php Project: HEXA-UA/supervisor-manager
0
 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();
 }
Example #16
Show file File: AlbumsCollection.php Project: romka-chev/yii2-yandex-fotki
0
 /**
  * @inheritdoc
  */
 public function loadWithData($data, $fast = false)
 {
     $factory = $this->getYandexFotki()->getFactory();
     $attributes = ['urn' => ArrayHelper::getValue($data, 'id'), 'author' => ArrayHelper::getValue($data, $this->getAuthorParser('authors.0', $factory->getAuthorModel(), $fast)), 'title' => ArrayHelper::getValue($data, 'title'), 'updatedAt' => ArrayHelper::getValue($data, $this->getDateParser('updated', $this->getYandexFotki()->getFormatter())), 'linkSelf' => ArrayHelper::getValue($data, 'links.self'), 'linkNext' => ArrayHelper::getValue($data, 'links.next'), 'linkAlternate' => ArrayHelper::getValue($data, 'links.alternate'), 'albums' => ArrayHelper::getValue($data, $this->getAlbumsParser('entries', $factory->getAlbumModel(), $fast))];
     if ($fast) {
         \Yii::configure($this, $attributes);
     } else {
         $this->load([$this->formName() => $attributes]);
     }
     return $this;
 }
Example #17
Show file File: Album.php Project: romka-chev/yii2-yandex-fotki
0
 /**
  * @inheritdoc
  */
 public function loadWithData($data, $fast = false)
 {
     $factory = $this->getYandexFotki()->getFactory();
     $attributes = ['urn' => ArrayHelper::getValue($data, 'id'), 'id' => ArrayHelper::getValue($data, $this->getIdParser()), 'author' => ArrayHelper::getValue($data, $this->getAuthorParser('authors.0', $factory->getAuthorModel(), $fast)), 'title' => ArrayHelper::getValue($data, 'title'), 'summary' => ArrayHelper::getValue($data, 'summary'), 'isProtected' => ArrayHelper::getValue($data, 'isProtected'), 'publishedAt' => ArrayHelper::getValue($data, $this->getDateParser('published', $this->getYandexFotki()->getFormatter())), 'updatedAt' => ArrayHelper::getValue($data, $this->getDateParser('updated', $this->getYandexFotki()->getFormatter())), 'editedAt' => ArrayHelper::getValue($data, $this->getDateParser('edited', $this->getYandexFotki()->getFormatter())), 'linkSelf' => ArrayHelper::getValue($data, 'links.self'), 'linkEdit' => ArrayHelper::getValue($data, 'links.edit'), 'linkPhotos' => ArrayHelper::getValue($data, 'links.photos'), 'linkCover' => ArrayHelper::getValue($data, 'links.cover'), 'linkYmapsml' => ArrayHelper::getValue($data, 'links.ymapsml'), 'linkAlternate' => ArrayHelper::getValue($data, 'links.alternate'), 'parentId' => ArrayHelper::getValue($data, $this->getAlbumIdParser())];
     if ($fast) {
         \Yii::configure($this, $attributes);
     } else {
         $this->load([$this->formName() => $attributes]);
     }
     return $this;
 }
Example #18
Show file File: m160418_201842_page_data.php Project: lav45/yii2-translated-behavior-demo
0
 public function up()
 {
     $docs = $this->getDocs();
     rsort($docs);
     foreach ($docs as $path) {
         $data = $this->parseData($path);
         $model = $this->getPostModel($data['slug']);
         Yii::configure($model, $data);
         $model->save(false);
     }
 }
Example #19
Show file File: AddressBinding.php Project: romka-chev/yii2-yandex-fotki
0
 /**
  * @inheritdoc
  */
 public function loadWithData($data, $fast = false)
 {
     $factory = $this->getYandexFotki()->getFactory();
     $attributes = ['organizationId' => ArrayHelper::getValue($data, 'organizationId'), 'address' => ArrayHelper::getValue($data, 'address'), 'point' => ArrayHelper::getValue($data, $this->getPointParser('geo', $factory->getPointModel(), $fast))];
     if ($fast) {
         \Yii::configure($this, $attributes);
     } else {
         $this->load([$this->formName() => $attributes]);
     }
     return $this;
 }
Example #20
Show file File: Module.php Project: novikas/yii2-flexform
0
 public function init()
 {
     parent::init();
     if (isset($this->module)) {
         $this->templateController = $this->module->id . "/" . $this->templateController;
     }
     \Yii::configure($this, require __DIR__ . '/flex_config.php');
     //Это не обязательно если у приложения и модуля одна тема
     /*$this->layoutPath = '@app/themes/modern/layouts';
       $this->layout = 'main';*/
 }
Example #21
Show file File: SMSimple.php Project: ostashevdv/yii2-smsimple
0
 public function __construct($config = [])
 {
     if (!empty($config)) {
         \Yii::configure($this, $config);
     }
     $GLOBALS['xmlrpc_internalencoding'] = $this->encoding;
     $GLOBALS['xmlrpc_defencoding'] = $this->encoding;
     $this->xmlrpc = new \PhpXmlRpc\Client($this->url);
     $this->xmlrpc->return_type = 'phpvals';
     $this->xmlrpc->request_charset_encoding = $this->encoding;
 }
Example #22
Show file File: Module.php Project: aka-VoV/yii2-announcement
0
 public function init()
 {
     parent::init();
     if ($this->getIsBackend() === true) {
         $this->setViewPath('@vov/announcement/backend/views');
         // инициализация модуля с помощью конфигурации, загруженной из config/main.php
         \Yii::configure($this, require __DIR__ . '/backend/config/main.php');
     } else {
         $this->setViewPath('@vov/announcement/frontend/views');
         \Yii::configure($this, require __DIR__ . '/frontend/config/main.php');
     }
     $this->registerTranslations();
 }
Example #23
Show file File: Module.php Project: fg/yii2-modular
0
 public function init()
 {
     parent::init();
     $configPath = realpath($this->getBasePath() . DIRECTORY_SEPARATOR . 'config');
     $config = (require $configPath . DIRECTORY_SEPARATOR . 'web.php');
     $localConfigPath = realpath($configPath . DIRECTORY_SEPARATOR . 'local' . DIRECTORY_SEPARATOR . 'web.php');
     if ($localConfigPath) {
         $config = ArrayHelper::merge($config, require $localConfigPath);
     }
     if ($configPath) {
         \Yii::configure($this, $config);
     }
 }
Example #24
Show file File: Przelewy24ComponentTest.php Project: merigold/yii2-p24
0
 public function setUp()
 {
     parent::setUp();
     Yii::configure(Yii::$app, ['components' => ['user' => ['class' => 'yii\\web\\User', 'identityClass' => 'common\\models\\User'], 'p24' => ['class' => \merigold\przelewy24\src\Przelewy24Component::className(), 'merchant_id' => $this->merchant_id, 'pos_id' => $this->merchant_id, 'CRC' => $this->CRC]]]);
     Yii::$container->set('HTTP_Request2', function () {
         $response = new HTTP_Request2_Response("HTTP/1.1 200 OK", true);
         $response->appendBody($this->succesresponse);
         $mockAdapter = new HTTP_Request2_Adapter_Mock();
         $mockAdapter->addResponse($response);
         $stub = new HTTP_Request2(\merigold\przelewy24\src\Przelewy24Component::TEST_URL, HTTP_Request2::METHOD_POST);
         $stub->setAdapter($mockAdapter);
         return $stub;
     });
 }
Example #25
Show file File: PhotoComponentTest.php Project: romka-chev/yii2-yandex-fotki
0
 public function testBatchCreate()
 {
     $factory = $this->getComponent()->getFactory();
     $photoComponent = $this->getComponent()->getPhotos();
     /** @var CreatePhotoOptions $options */
     $options1 = \Yii::configure($factory->getCreatePhotoOptions(), ['image' => __DIR__ . '/../../assets/test.png', 'title' => 'testBatchCreate1_title', 'summary' => 'testBatchCreate1_summary']);
     /** @var CreatePhotoOptions $options */
     $options2 = \Yii::configure($factory->getCreatePhotoOptions(), ['image' => __DIR__ . '/../../assets/test.png', 'title' => 'testBatchCreate2_title', 'summary' => 'testBatchCreate2_summary']);
     $models = $photoComponent->batchCreate([$options1, $options2]);
     $titles = array_values(ArrayHelper::getColumn($models, 'title'));
     $summaries = array_values(ArrayHelper::getColumn($models, 'summary'));
     $this->assertArraySubset($titles, ['testBatchCreate1_title', 'testBatchCreate2_title']);
     $this->assertArraySubset($summaries, ['testBatchCreate1_summary', 'testBatchCreate2_summary']);
 }
Example #26
Show file File: AlbumComponentTest.php Project: romka-chev/yii2-yandex-fotki
0
 public function testBatchCreate()
 {
     $factory = $this->getComponent()->getFactory();
     $albumComponent = $this->getComponent()->getAlbums();
     /** @var \romkaChev\yandexFotki\models\options\album\CreateAlbumOptions $options */
     $options1 = \Yii::configure($factory->getCreateAlbumOptions(), ['title' => 'testBatchCreate1_title', 'summary' => 'testBatchCreate1_summary']);
     /** @var \romkaChev\yandexFotki\models\options\album\CreateAlbumOptions $options */
     $options2 = \Yii::configure($factory->getCreateAlbumOptions(), ['title' => 'testBatchCreate2_title', 'summary' => 'testBatchCreate2_summary']);
     $models = $albumComponent->batchCreate([$options1, $options2]);
     $titles = array_values(ArrayHelper::getColumn($models, 'title'));
     $summaries = array_values(ArrayHelper::getColumn($models, 'summary'));
     $this->assertArraySubset($titles, ['testBatchCreate1_title', 'testBatchCreate2_title']);
     $this->assertArraySubset($summaries, ['testBatchCreate1_summary', 'testBatchCreate2_summary']);
 }
Example #27
Show file File: AdminModule.php Project: vinhhx/yii2_basic_startup
0
 public function init()
 {
     parent::init();
     // custom initialization code goes here
     // initialize the module with the configuration loaded from config.php
     // Load configuration files
     \Yii::configure($this, require Yii::getAlias('@app') . '/config/module-admin-config.php');
     // Set Components
     \Yii::$app->setComponents(['authManager' => ['class' => '\\yii\\rbac\\DbManager', 'cache' => 'cache'], 'user' => ['class' => '\\yii\\web\\User', 'identityClass' => 'app\\models\\User', 'enableAutoLogin' => false, 'loginUrl' => '/admin/default/login', 'idParam' => '__admin', 'authTimeoutParam' => '__adminExpire', 'absoluteAuthTimeoutParam' => '__adminAbsoluteExpire', 'returnUrlParam' => '__adminReturnUrl'], 'urlManager' => ['class' => 'yii\\web\\urlManager', 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => []]]);
     // Customer Error Page
     \Yii::$app->errorHandler->errorAction = 'admin/default/error';
     // Set default layout
     $this->layout = 'admin';
     Yii::$app->language = 'vi';
 }
Example #28
Show file File: Module.php Project: portalsway2/APEDevices
0
 public function init()
 {
     parent::init();
     \Yii::configure($this, require __DIR__ . '/config.php');
     $this->registerGlobalComponents();
     $modules = $this->getModules();
     $stateMachineConfigs = [];
     foreach ($modules as $key => $value) {
         $module = $this->getModule($key);
         if ($module instanceof StateMachineAwareInterface) {
             $stateMachineConfigs = array_merge($stateMachineConfigs, $module->getStateMachineConfig());
         }
     }
     $factory = new Factory($stateMachineConfigs);
     $this->set('stateMachineFactory', $factory);
     Yii::$container->set('SM\\Factory\\FactoryInterface', $factory);
     Yii::$container->set('stateMachineFactory', 'SM\\Factory\\FactoryInterface');
 }
Example #29
Show file File: StageCollection.php Project: yariksav/yii2-actives
0
 /**
  * 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;
     }
     foreach ($newItems as $name => $item) {
         if (isset($this->_collection[$name])) {
             if ($item === false) {
                 unset($this->_collection[$name]);
             } else {
                 if (is_array($item)) {
                     Yii::configure($this->_collection[$name], $item);
                 }
             }
             continue;
         }
         if (is_string($item) && is_int($name)) {
             if (!preg_match('/^([\\w\\.]+)(:(\\w*))?(:(.*))?$/', $item, $matches)) {
                 throw new yii\base\Exception(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 (is_array($item)) {
             // if only necessary to add params
             if (empty($item['name'])) {
                 $item['name'] = $name;
             }
         }
         $instance = $this->createObject($item);
         if ($instance) {
             $this->_collection[$name] = $instance;
         }
     }
 }
Example #30
Show file File: EmailTaskController.php Project: highestgoodlikewater/yii2-mailqueue
0
 public function init()
 {
     Yii::configure($this, Yii::$app->params['emailTaskConsumer']);
 }