Esempio n. 1
0
 function execute(CommandContext $context)
 {
     $manager = Registry::getAccessManager();
     $user = $context->get('username');
     $pass = $context->get('pass');
     $user_obj = $manager->login($user, $pass);
     if (is_null($user_obj)) {
         $context->setError($manager->getError());
         return false;
     }
     $context->addParam("user", $user_obj);
     return true;
 }
Esempio n. 2
0
 function execute(CommandContext $context)
 {
     $msgSystem = Registry::getMessageSystem();
     $email = $context->get('email');
     $msg = $context->get('msg');
     $topic = $context->get('topic');
     $result = $msgSystem->send($email, $msg, $topic);
     if (!$result) {
         $context->setError($msgSystem->getError());
         return false;
     }
     return true;
 }
Esempio n. 3
0
 public function validate(CommandContext $context)
 {
     if (property_exists($this, 'params') && is_array(static::$params)) {
         $paramValidator = new ParamValidator();
         // Validate input parameters
         $validationErrors = $paramValidator->validate((array) $context, static::$params);
         if (!empty($validationErrors)) {
             $context->setError(current($validationErrors)[0]);
             return false;
         }
         // Set default values for optional parameters
         $newContext = $paramValidator->setDefaultValues((array) $context, static::$params);
         $context->exchangeArray($newContext);
     }
     return true;
 }