Example #1
0
 /**
  * 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();
 }
Example #2
0
 /**
  * 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;
 }