Пример #1
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();
 }
Пример #2
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;
 }
Пример #3
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]);
                     });
                 }')]])]);
 }
Пример #4
0
 public function init()
 {
     parent::init();
     //$this->params['foo'] = 'bar';
     // ...  other initialization code ...
     \Yii::configure($this, require __DIR__ . '/config.php');
 }
Пример #5
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'])])]);
 }
Пример #6
0
 /**
  * @param array $config
  *
  * @since 1.0
  * @author Choate <*****@*****.**>
  * @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
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();
 }
Пример #8
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');
 }
Пример #9
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]);
     }
 }
Пример #10
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;
 }
Пример #11
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;
 }
Пример #12
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');
 }
Пример #13
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;
 }
Пример #14
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;
 }
Пример #15
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();
 }
 /**
  * @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;
 }
Пример #17
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;
 }
 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);
     }
 }
 /**
  * @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;
 }
Пример #20
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';*/
 }
Пример #21
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;
 }
Пример #22
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();
 }
Пример #23
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);
     }
 }
Пример #24
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;
     });
 }
 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']);
 }
 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']);
 }
Пример #27
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';
 }
Пример #28
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');
 }
Пример #29
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;
         }
     }
 }
 public function init()
 {
     Yii::configure($this, Yii::$app->params['emailTaskConsumer']);
 }