correctly set request parameters for MailApi
This commit is contained in:
parent
e89c3ad550
commit
333c45773f
2 changed files with 109 additions and 9 deletions
|
|
@ -36,8 +36,8 @@
|
|||
);
|
||||
|
||||
// Set ToplevelAgent
|
||||
$this->response->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
|
||||
$this->response->addParam(\nre\configs\AppConfig::$defaults['intermediate-mail']);
|
||||
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
|
||||
$this->request->addParam(\nre\configs\AppConfig::$defaults['intermediate-mail']);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -46,11 +46,24 @@
|
|||
/**
|
||||
* Use a ToplevelAgent for HTML-mail
|
||||
*/
|
||||
public function setHTML()
|
||||
public function setHTML($html=true)
|
||||
{
|
||||
$this->response->clearParams();
|
||||
$this->response->addParam(\nre\configs\AppConfig::$defaults['toplevel-htmlmail']);
|
||||
$this->response->addParam(\nre\configs\AppConfig::$defaults['intermediate-mail']);
|
||||
// Save params
|
||||
$params = $this->request->getParams(1);
|
||||
|
||||
// Set ToplevelAgent
|
||||
$this->request->clearParams();
|
||||
if($html) {
|
||||
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-htmlmail']);
|
||||
}
|
||||
else {
|
||||
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
|
||||
}
|
||||
|
||||
// Restore params
|
||||
if(!empty($params)) {
|
||||
$this->addParams($params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -59,8 +72,17 @@
|
|||
*/
|
||||
public function setMessage($messageAgent)
|
||||
{
|
||||
$this->response->clearParams(2);
|
||||
$this->response->addParam($messageAgent);
|
||||
// Save params
|
||||
$params = $this->request->getParams(3);
|
||||
|
||||
// Set messageAgent
|
||||
$this->request->clearParams(2);
|
||||
$this->request->addParam($messageAgent);
|
||||
|
||||
// Restore params
|
||||
if(!empty($params)) {
|
||||
$this->addParams($params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -71,7 +93,19 @@
|
|||
*/
|
||||
public function setParams($params)
|
||||
{
|
||||
$this->response->addParams($params);
|
||||
// Add placeholder params
|
||||
for($i=3; $i<count($this->request->getParams()); $i++) {
|
||||
$this->request->addParam(null);
|
||||
}
|
||||
|
||||
// Set params
|
||||
call_user_func_array(
|
||||
array(
|
||||
$this->request,
|
||||
'addParams'
|
||||
),
|
||||
$params
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -95,6 +129,13 @@
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
// Set response
|
||||
$this->response->clearParams();
|
||||
foreach($this->request->getParams() as &$param) {
|
||||
$this->response->addParam($param);
|
||||
}
|
||||
|
||||
// Run
|
||||
try {
|
||||
$exception = parent::run();
|
||||
|
||||
|
|
@ -122,6 +163,25 @@
|
|||
return $this->response->getOutput();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add multiple request params.
|
||||
*
|
||||
* @param array $params Request params to add
|
||||
*/
|
||||
private function addParams($params)
|
||||
{
|
||||
call_user_func_array(
|
||||
array(
|
||||
$this->request,
|
||||
'addParams'
|
||||
),
|
||||
$params
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,46 @@
|
|||
*/
|
||||
class MailRequest extends \nre\core\Request
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add a parameter.
|
||||
*
|
||||
* @param mixed $value Value of parameter
|
||||
*/
|
||||
public function addParam($value)
|
||||
{
|
||||
$this->params[] = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add multiple parameters.
|
||||
*
|
||||
* @param mixed $value1 Value of first parameter
|
||||
* @param mixed … Values of further parameters
|
||||
*/
|
||||
public function addParams($value1)
|
||||
{
|
||||
$this->params = array_merge(
|
||||
$this->params,
|
||||
func_get_args()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete all stored parameters (from offset on).
|
||||
*
|
||||
* @param int $offset Offset-index
|
||||
*/
|
||||
public function clearParams($offset=0)
|
||||
{
|
||||
$this->params = array_slice($this->params, 0, $offset);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue