當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Form::translate方法代碼示例

本文整理匯總了PHP中Icinga\Web\Form::translate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Form::translate方法的具體用法?PHP Form::translate怎麽用?PHP Form::translate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Icinga\Web\Form的用法示例。


在下文中一共展示了Form::translate方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: isValidUserBackend

 /**
  * Validate the configuration by creating a backend and requesting the user count
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidUserBackend(Form $form)
 {
     try {
         $dbUserBackend = new DbUserBackend(ResourceFactory::createResource($form->getResourceConfig()));
         if ($dbUserBackend->select()->where('is_active', true)->count() < 1) {
             $form->addError($form->translate('No active users found under the specified database backend'));
             return false;
         }
     } catch (Exception $e) {
         $form->addError(sprintf($form->translate('Using the specified backend failed: %s'), $e->getMessage()));
         return false;
     }
     return true;
 }
開發者ID:hsanjuan,項目名稱:icingaweb2,代碼行數:21,代碼來源:DbBackendForm.php

示例2: isValidResource

 /**
  * Validate the resource configuration by trying to connect with it
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidResource(Form $form)
 {
     $result = ResourceFactory::createResource(new ConfigObject($form->getValues()))->inspect();
     if ($result->hasError()) {
         $form->addError(sprintf('%s (%s)', $form->translate('Connectivity validation failed, connection to the given resource not possible.'), $result->getError()));
     }
     // TODO: display diagnostics in $result->toArray() to the user
     return !$result->hasError();
 }
開發者ID:bebehei,項目名稱:icingaweb2,代碼行數:16,代碼來源:LdapResourceForm.php

示例3: isValidUserBackend

 /**
  * Validate the configuration by creating a backend and requesting the user count
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidUserBackend(Form $form)
 {
     $backend = new DbUserBackend(ResourceFactory::createResource($form->getResourceConfig()));
     $result = $backend->inspect();
     if ($result->hasError()) {
         $form->addError(sprintf($form->translate('Using the specified backend failed: %s'), $result->getError()));
     }
     // TODO: display diagnostics in $result->toArray() to the user
     return !$result->hasError();
 }
開發者ID:bebehei,項目名稱:icingaweb2,代碼行數:17,代碼來源:DbBackendForm.php

示例4: isValidResource

 /**
  * Validate the resource configuration by trying to connect with it
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidResource(Form $form)
 {
     try {
         $resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
         $resource->getConnection()->getConnection();
     } catch (Exception $e) {
         $form->addError($form->translate('Connectivity validation failed, connection to the given resource not possible.'));
         return false;
     }
     return true;
 }
開發者ID:hsanjuan,項目名稱:icingaweb2,代碼行數:18,代碼來源:DbResourceForm.php

示例5: isValidResource

 /**
  * Validate the resource configuration by trying to connect with it
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidResource(Form $form)
 {
     try {
         $resource = ResourceFactory::createResource(new ConfigObject($form->getValues()));
         $resource->bind();
     } catch (Exception $e) {
         $msg = $form->translate('Connectivity validation failed, connection to the given resource not possible.');
         if ($error = $e->getMessage()) {
             $msg .= ' (' . $error . ')';
         }
         $form->addError($msg);
         return false;
     }
     return true;
 }
開發者ID:kain64,項目名稱:icingaweb2,代碼行數:22,代碼來源:LdapResourceForm.php

示例6: isValidIdoInstance

 /**
  * Return whether a single icinga instance is writing to the given resource
  *
  * @param   Form            $form
  * @param   ConfigObject    $resourceConfig
  *
  * @return  bool                                True if it's a single instance, false if none
  *                                              or multiple instances are writing to it
  */
 public static function isValidIdoInstance(Form $form, ConfigObject $resourceConfig)
 {
     $db = ResourceFactory::createResource($resourceConfig);
     $rowCount = $db->select()->from('icinga_instances')->count();
     if ($rowCount === 0) {
         $form->warning($form->translate('There is currently no icinga instance writing to the IDO. Make sure ' . 'that a icinga instance is configured and able to write to the IDO.'));
         return false;
     } elseif ($rowCount > 1) {
         $form->warning($form->translate('There is currently more than one icinga instance writing to the IDO. You\'ll see all objects from all' . ' instances without any differentation. If this is not desired, consider setting up a separate IDO' . ' for each instance.'));
         return false;
     }
     return true;
 }
開發者ID:bebehei,項目名稱:icingaweb2,代碼行數:22,代碼來源:BackendConfigForm.php

示例7: isValidUserBackend

 /**
  * Validate the configuration by creating a backend and requesting the user count
  *
  * @param   Form    $form   The form to fetch the configuration values from
  *
  * @return  bool            Whether validation succeeded or not
  */
 public static function isValidUserBackend(Form $form)
 {
     try {
         $ldapUserBackend = UserBackend::create(null, new ConfigObject($form->getValues()));
         $ldapUserBackend->assertAuthenticationPossible();
     } catch (AuthenticationException $e) {
         if (($previous = $e->getPrevious()) !== null) {
             $form->addError($previous->getMessage());
         } else {
             $form->addError($e->getMessage());
         }
         return false;
     } catch (Exception $e) {
         $form->addError(sprintf($form->translate('Unable to validate authentication: %s'), $e->getMessage()));
         return false;
     }
     return true;
 }
開發者ID:hsanjuan,項目名稱:icingaweb2,代碼行數:25,代碼來源:LdapBackendForm.php

示例8: isValidIdoInstance

 /**
  * Validate the ido instance availability
  *
  * @param   Form            $form
  * @param   ConfigObject    $resourceConfig
  *
  * @return  bool                                Whether validation succeeded or not
  */
 public static function isValidIdoInstance(Form $form, ConfigObject $resourceConfig)
 {
     $resource = ResourceFactory::createResource($resourceConfig);
     $result = $resource->select()->from('icinga_instances', array('instance_name'));
     $instances = $result->fetchAll();
     if (count($instances) === 1) {
         return true;
     } elseif (count($instances) > 1) {
         $form->warning($form->translate('IDO instance validation failed, because there are multiple instances available.'));
         return false;
     }
     $form->error($form->translate('IDO instance validation failed, because there is no IDO instance available.'));
     return false;
 }
開發者ID:xert,項目名稱:icingaweb2,代碼行數:22,代碼來源:BackendConfigForm.php


注:本文中的Icinga\Web\Form::translate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。