コード例 #1
0
 /**
  * @inheritdoc
  */
 protected function setUp()
 {
     new \yii\web\Application(['id' => 'unit', 'basePath' => __DIR__, 'bootstrap' => ['log', 'multilingual'], 'controllerNamespace' => 'DevGroup\\Multilingual\\tests\\controllers', 'components' => ['log' => ['traceLevel' => 10, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['info']]]], 'request' => ['cookieValidationKey' => 'wefJDF8sfdsfSDefwqdxj9oq', 'scriptFile' => __DIR__ . '/index.php', 'scriptUrl' => '/index.php'], 'cache' => ['class' => '\\yii\\caching\\DummyCache'], 'urlManager' => ['class' => \DevGroup\Multilingual\components\UrlManager::className()], 'multilingual' => ['class' => \DevGroup\Multilingual\Multilingual::className(), 'default_language_id' => 1, 'handlers' => [['class' => \DevGroup\Multilingual\DefaultGeoProvider::className(), 'default' => ['country' => ['name' => 'Russia', 'iso' => 'ru']]]]], 'filedb' => ['class' => 'yii2tech\\filedb\\Connection', 'path' => __DIR__ . '/data']]]);
     try {
         Yii::$app->set('db', ['class' => Connection::className(), 'dsn' => 'mysql:host=localhost;dbname=multilingual.dev', 'username' => 'root', 'password' => '7896321']);
         Yii::$app->getDb()->open();
         $lines = explode(';', file_get_contents(__DIR__ . '/migrations/mysql.sql'));
         foreach ($lines as $line) {
             if (trim($line) !== '') {
                 Yii::$app->getDb()->pdo->exec($line);
             }
         }
     } catch (\Exception $e) {
         Yii::$app->clear('db');
     }
     if (Yii::$app->get('db', false) === null) {
         $this->markTestSkipped();
     } else {
         parent::setUp();
     }
 }
コード例 #2
0
if ($city === null) {
    ?>
        <?php 
    echo Multilingual::t('widget', 'We could not identify your city.');
    ?>
        <?php 
    echo Multilingual::t('widget', 'Please, choose one from the list:');
    ?>
    <?php 
} else {
    ?>
        <?php 
    echo Multilingual::t('widget', 'We have identified your city as "{name}".', ['name' => $city->getName()]);
    ?>
        <?php 
    echo Multilingual::t('widget', 'Please, confirm or select another city:');
    ?>
    <?php 
}
?>
    <ul>
        <?php 
foreach ($allCites as $item) {
    ?>
            <?php 
    if (empty($city) || $item->getId() !== $city->getId()) {
        ?>
                <li><?php 
        echo Html::a($item->getName(), ArrayHelper::merge([Yii::$app->requestedRoute], Yii::$app->request->getQueryParams(), ['multilingual-city-id' => $item->getId()]));
        ?>
</li>
コード例 #3
0
<?php

$params = (require __DIR__ . '/params.php');
$config = ['id' => 'basic', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log', 'multilingual'], 'components' => ['request' => ['cookieValidationKey' => '19wRK6yuUnGqL-dtBRZpye2Txxchj61J'], 'cache' => ['class' => 'yii\\caching\\FileCache', 'as lazy' => ['class' => 'DevGroup\\TagDependencyHelper\\LazyCache']], 'user' => ['identityClass' => 'app\\models\\User', 'enableAutoLogin' => true], 'errorHandler' => ['errorAction' => 'site/error'], 'mailer' => ['class' => 'yii\\swiftmailer\\Mailer', 'useFileTransport' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'db' => require __DIR__ . '/db.php', 'urlManager' => ['class' => \DevGroup\Multilingual\components\UrlManager::className(), 'excludeRoutes' => ['newsletter/index', 'newsletter/test'], 'rules' => ['' => 'post/index']], 'multilingual' => ['class' => \DevGroup\Multilingual\Multilingual::className(), 'default_language_id' => 1, 'handlers' => [['class' => \DevGroup\Multilingual\DefaultGeoProvider::className(), 'default' => ['country' => ['name' => 'England', 'iso' => 'en']]]]], 'filedb' => ['class' => 'yii2tech\\filedb\\Connection', 'path' => __DIR__ . '/data'], 'i18n' => ['translations' => ['admin' => ['class' => 'yii\\i18n\\PhpMessageSource'], 'yii2tech-admin' => ['class' => 'yii\\i18n\\PhpMessageSource']]], 'assetManager' => ['bundles' => ['yii\\web\\JqueryAsset' => false]]], 'modules' => ['dynagrid' => ['class' => '\\kartik\\dynagrid\\Module', 'dynaGridOptions' => ['gridOptions' => ['export' => false]]], 'gridview' => ['class' => '\\kartik\\grid\\Module']], 'params' => $params];
if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = ['class' => 'yii\\debug\\Module', 'allowedIPs' => ['192.168.33.1', '127.0.0.1', '::1']];
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = ['class' => 'yii\\gii\\Module', 'allowedIPs' => ['192.168.33.1', '127.0.0.1', '::1']];
}
return $config;
コード例 #4
0
ファイル: console.php プロジェクト: serhiobb/RGK-test
<?php

Yii::setAlias('@tests', dirname(__DIR__) . '/tests/codeception');
$params = (require __DIR__ . '/params.php');
$db = (require __DIR__ . '/db.php');
$config = ['id' => 'basic-console', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log', 'gii'], 'controllerNamespace' => 'app\\commands', 'modules' => ['gii' => 'yii\\gii\\Module'], 'components' => ['cache' => ['class' => 'yii\\caching\\FileCache'], 'log' => ['targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'authManager' => ['class' => 'yii\\rbac\\PhpManager', 'defaultRoles' => ['admin', 'author']], 'multilingual' => ['class' => \DevGroup\Multilingual\Multilingual::className(), 'handlers' => [['class' => \DevGroup\Multilingual\DefaultGeoProvider::className(), 'default' => ['country' => ['name' => 'England', 'iso' => 'en']]]]], 'db' => $db], 'params' => $params];
if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = ['class' => 'yii\\gii\\Module'];
}
return $config;
コード例 #5
0
<?php

use DevGroup\Multilingual\models\Language;
use DevGroup\Multilingual\Multilingual;
use yii\bootstrap\Modal;
use yii\helpers\Html;
/** @var \yii\web\View $this */
/** @var Language[] $languages */
/** @var integer $currentLanguageId */
/** @var \DevGroup\Multilingual\Multilingual $multilingual */
$modal = Modal::begin(['header' => Html::tag('h4', Multilingual::t('widget', 'Please, confirm language'))]);
?>
    <p>
        <?php 
echo Multilingual::t('widget', 'Your language is "{name}". Please, confirm or select another language:', ['name' => $languages[$currentLanguageId]->name]);
?>
    </p>
    <ul>
        <?php 
foreach ($languages as $language) {
    ?>
            <?php 
    if ($language->id !== $currentLanguageId) {
        ?>
                <li>
                    <a href="<?php 
        echo $multilingual->translateCurrentRequest($language->id);
        ?>
">
                        <?php 
        echo $language->name;
コード例 #6
0
<?php

Yii::setAlias('@tests', dirname(__DIR__) . '/tests');
$params = (require __DIR__ . '/params.php');
$db = (require __DIR__ . '/db.php');
$config = ['id' => 'basic-console', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'controllerNamespace' => 'app\\commands', 'controllerMap' => ['deferred' => ['class' => 'DevGroup\\DeferredTasks\\commands\\DeferredController']], 'components' => ['cache' => ['class' => 'yii\\caching\\FileCache'], 'log' => ['targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'db' => $db, 'mutex' => ['class' => 'yii\\mutex\\MysqlMutex', 'autoRelease' => false], 'urlManager' => ['class' => \DevGroup\Multilingual\components\UrlManager::className(), 'excludeRoutes' => ['newsletter/index', 'newsletter/test'], 'rules' => ['' => 'post/index'], 'scriptUrl' => '', 'baseUrl' => '', 'forceScheme' => 'http', 'forcePort' => 80, 'hostInfo' => 'http://demo.yii2-multilingual.dev'], 'multilingual' => ['class' => \DevGroup\Multilingual\Multilingual::className(), 'default_language_id' => 1, 'handlers' => [['class' => \DevGroup\Multilingual\DefaultGeoProvider::className(), 'default' => ['country' => ['name' => 'Russia', 'iso' => 'ru']]]]], 'filedb' => ['class' => 'yii2tech\\filedb\\Connection', 'path' => __DIR__ . '/data'], 'mailer' => ['class' => 'yii\\swiftmailer\\Mailer', 'transport' => ['class' => 'Swift_SmtpTransport', 'host' => 'smtp.yandex.ru', 'port' => 465, 'encryption' => 'ssl', 'username' => '*****@*****.**', 'password' => 'z6jNK3MdjfJ49g6rJ']]], 'params' => $params];
if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = ['class' => 'yii\\gii\\Module'];
}
return $config;
コード例 #7
0
ファイル: web.php プロジェクト: serhiobb/RGK-test
<?php

$params = (require __DIR__ . '/params.php');
$config = ['id' => 'basic', 'basePath' => dirname(__DIR__), 'bootstrap' => ['log'], 'modules' => ['news' => 'app\\modules\\news\\Module', 'pages' => 'app\\modules\\pages\\Module', 'event' => ['class' => 'DevGroup\\EventsSystem\\Module', 'manageControllerBehaviors' => ['access' => ['class' => 'yii\\filters\\AccessControl', 'rules' => [['allow' => true, 'roles' => ['@']]]], 'verbs' => ['class' => 'yii\\filters\\VerbFilter', 'actions' => ['delete' => ['POST']]]]], 'admin' => 'DevGroup\\AdminUtils\\AdminModule'], 'components' => ['request' => ['cookieValidationKey' => 'a8s7f87asdf87safasf7s87adf68sadfu'], 'cache' => ['class' => 'yii\\caching\\FileCache'], 'user' => ['identityClass' => 'app\\models\\User', 'enableAutoLogin' => true], 'errorHandler' => ['errorAction' => 'site/error'], 'mailer' => ['class' => 'yii\\swiftmailer\\Mailer', 'useFileTransport' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'db' => require __DIR__ . '/db.php', 'authManager' => ['class' => 'yii\\rbac\\PhpManager', 'defaultRoles' => ['admin', 'author']], 'urlManager' => ['enablePrettyUrl' => true, 'showScriptName' => false], 'multilingual' => ['class' => \DevGroup\Multilingual\Multilingual::className(), 'handlers' => [['class' => \DevGroup\Multilingual\DefaultGeoProvider::className(), 'default' => ['country' => ['name' => 'England', 'iso' => 'en']]]]], 'filedb' => ['class' => 'yii2tech\\filedb\\Connection', 'path' => __DIR__ . '/data']], 'params' => $params];
if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = ['class' => 'yii\\debug\\Module'];
    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = ['class' => 'yii\\gii\\Module'];
}
return $config;