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; }
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; }
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; }