当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::getAvailableLanguages方法代码示例

本文整理汇总了PHP中Alchemy\Phrasea\Application::getAvailableLanguages方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getAvailableLanguages方法的具体用法?PHP Application::getAvailableLanguages怎么用?PHP Application::getAvailableLanguages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Alchemy\Phrasea\Application的用法示例。


在下文中一共展示了Application::getAvailableLanguages方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: register

 public function register(Application $app)
 {
     $app['locale'] = $app->share(function (Application $app) {
         if (!$app['configuration.store']->isSetup()) {
             return 'en';
         }
         return $app['conf']->get(['languages', 'default'], 'en');
     });
     $app['locales.available'] = $app->share(function (Application $app) {
         $availableLanguages = PhraseaApplication::getAvailableLanguages();
         if ($app['configuration.store']->isSetup() && 0 < count((array) $app['conf']->get(['languages', 'available']))) {
             $languages = $app['conf']->get(['languages', 'available']);
             $enabledLanguages = $availableLanguages;
             foreach ($enabledLanguages as $code => $language) {
                 if (in_array($code, $languages)) {
                     continue;
                 }
                 unset($enabledLanguages[$code]);
             }
             if (0 === count($enabledLanguages)) {
                 $app['monolog']->error('Wrong language configuration, no language activated');
                 return $availableLanguages;
             }
             return $enabledLanguages;
         }
         return $availableLanguages;
     });
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:28,代码来源:LocaleServiceProvider.php

示例2: testSetLocale

 public function testSetLocale()
 {
     foreach (array_keys(Application::getAvailableLanguages()) as $locale) {
         $this->user->setLocale($locale);
         $this->assertEquals($this->user->getLocale(), $locale);
     }
     $this->user->setLocale(null);
     $this->assertEquals($this->user->getLocale(), null);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:9,代码来源:UserTest.php

示例3: testLocalesCustomizedWithError

 public function testLocalesCustomizedWithError()
 {
     $app = $this->loadApp();
     $app->register(new LocaleServiceProvider());
     $app['root.path'] = __DIR__ . '/../../../../../..';
     $app->register(new ConfigurationServiceProvider());
     $app['conf']->set(['languages', 'available'], ['en_US']);
     $app['monolog'] = $this->getMock('Psr\\Log\\LoggerInterface');
     $app['monolog']->expects($this->once())->method('error');
     $original = Application::getAvailableLanguages();
     $this->assertEquals($original, $app['locales.available']);
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:12,代码来源:LocaleServiceProviderTest.php

示例4: getInstallForm

 public function getInstallForm(Application $app, Request $request)
 {
     $warnings = [];
     $requirementsCollection = $this->getRequirementsCollection();
     foreach ($requirementsCollection as $requirements) {
         foreach ($requirements->getRequirements() as $requirement) {
             if (!$requirement->isFulfilled() && !$requirement->isOptional()) {
                 $warnings[] = $requirement->getTestMessage();
             }
         }
     }
     if ($request->getScheme() == 'http') {
         $warnings[] = $app->trans('It is not recommended to install Phraseanet without HTTPS support');
     }
     return $app['twig']->render('/setup/step2.html.twig', ['locale' => $app['locale'], 'available_locales' => Application::getAvailableLanguages(), 'available_templates' => ['en', 'fr'], 'warnings' => $warnings, 'error' => $request->query->get('error'), 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/', 'discovered_binaries' => \setup::discover_binaries(), 'rootpath' => realpath(__DIR__ . '/../../../../')]);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:16,代码来源:Setup.php

示例5: testDataboxTermsOfUseRoute

 public function testDataboxTermsOfUseRoute()
 {
     $this->setToken($this->userAccessToken);
     $databox_id = self::$DI['record_1']->get_sbas_id();
     $route = '/api/v1/databoxes/' . $databox_id . '/termsOfUse/';
     $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']);
     self::$DI['client']->request('GET', $route, $this->getParameters(), [], ['HTTP_Accept' => $this->getAcceptMimeType()]);
     $content = $this->unserialize(self::$DI['client']->getResponse()->getContent());
     $this->evaluateResponse200(self::$DI['client']->getResponse());
     $this->evaluateMeta200($content);
     $this->assertArrayHasKey('termsOfUse', $content['response']);
     foreach ($content['response']['termsOfUse'] as $terms) {
         $this->assertTrue(is_array($terms), 'Une bloc cgu est un objet');
         $this->assertArrayHasKey('locale', $terms);
         $this->assertTrue(in_array($terms['locale'], array_keys(Application::getAvailableLanguages())));
         $this->assertArrayHasKey('terms', $terms);
         break;
     }
     $route = '/api/v1/databoxes/24892534/termsOfUse/';
     $this->evaluateNotFoundRoute($route, ['GET']);
     $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']);
     $route = '/api/v1/databoxes/any_bad_id/termsOfUse/';
     $this->evaluateBadRequestRoute($route, ['GET']);
     $this->evaluateMethodNotAllowedRoute($route, ['POST', 'PUT', 'DELETE']);
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:25,代码来源:ApiTestCase.php

示例6: provideStemmData

 public function provideStemmData()
 {
     $stemms = [];
     $examples = ['fr' => ['word' => 'chevaux', 'stemm' => 'cheval'], 'en' => ['word' => 'consistency', 'stemm' => 'consistent'], 'de' => ['word' => 'aufeinanderfolgender', 'stemm' => 'aufeinanderfolg'], 'nl' => ['word' => 'lichamelijk', 'stemm' => 'licham']];
     foreach (Application::getAvailableLanguages() as $languageCode => $name) {
         $data = explode('_', $languageCode);
         $code = $data[0];
         if (!isset($examples[$code])) {
             $this->fail(sprintf('Missing stemm examples for language %s', $code));
         }
         $stemms[] = [$code, $examples[$code]['word'], $examples[$code]['stemm']];
     }
     return $stemms;
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:14,代码来源:SearchEngineAbstractTest.php

示例7: testCookieLocale

 /**
  * @covers Alchemy\Phrasea\Application
  */
 public function testCookieLocale()
 {
     foreach (array_keys(Application::getAvailableLanguages()) as $locale) {
         $client = $this->getClientWithCookie($this->getAppThatReturnLocale(), $locale);
         $client->request('GET', '/');
         $this->assertEquals($locale, $client->getResponse()->getContent());
     }
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:11,代码来源:ApplicationTest.php

示例8: setLocale

 /**
  * @param string $locale
  *
  * @throws InvalidArgumentException
  */
 public function setLocale($locale)
 {
     if (null !== $locale && !array_key_exists($locale, Application::getAvailableLanguages())) {
         throw new InvalidArgumentException(sprintf('Invalid locale %s.', $locale));
     }
     $this->locale = $locale;
     return $this;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:13,代码来源:User.php

示例9: provideLanguageCodes

 public function provideLanguageCodes()
 {
     $codes = [];
     foreach (Application::getAvailableLanguages() as $code => $language) {
         $data = explode('_', $code);
         $codes[] = [$data[0]];
     }
     return $codes;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:9,代码来源:fieldTest.php

示例10: updateUsers

 /**
  * Sets user entity from usr table.
  */
 private function updateUsers(EntityManager $em)
 {
     $em->getConnection()->executeUpdate('INSERT INTO Users
         (
             id,                     activity,               address,                admin,
             can_change_ftp_profil,  can_change_profil,      city,                   company,
             country,                email,                  fax,                    first_name,
             geoname_id,             guest,                  job,                    last_connection,
             last_name,              ldap_created,           locale,                 login,
             mail_locked,            last_model,             mail_notifications,     nonce,
             password,               push_list,              request_notifications,  salted_password,
             gender,                 phone,                  timezone,               zip_code,
             created,                updated
         )
         (
             SELECT
             usr_id,                 activite,               adresse,                create_db,
             canchgftpprofil,        canchgprofil,           ville,                  societe,
             pays,                   usr_mail,               fax,                    usr_prenom,
             geonameid,              invite,                 fonction,               last_conn,
             usr_nom,                ldap_created,           locale,                 usr_login,
             mail_locked,            NULL AS lastModel,      mail_notifications,     ' . ($this->hasField($em, 'nonce') ? 'nonce' : 'NULL AS nonce') . ',
             usr_password,           push_list,              request_notifications,  ' . ($this->hasField($em, 'salted_password') ? 'salted_password' : '0 AS salted_password') . ',
             usr_sexe,               tel,                    timezone,               cpostal,
             usr_creationdate,       usr_modificationdate
             FROM usr
         )');
     $em->getConnection()->executeUpdate('UPDATE Users SET geoname_id=NULL WHERE geoname_id=0');
     $em->getConnection()->executeUpdate('UPDATE Users SET locale=NULL WHERE locale NOT IN ("' . implode('", "', array_keys(Application::getAvailableLanguages())) . '")');
     $em->getConnection()->executeUpdate('UPDATE Users SET deleted=1, login=SUBSTRING(login, 11) WHERE login LIKE "(#deleted_%"');
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:34,代码来源:Upgrade39Users.php


注:本文中的Alchemy\Phrasea\Application::getAvailableLanguages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。