correctly set request parameters for MailApi
This commit is contained in:
parent
c93d8ad779
commit
598eac39ee
2 changed files with 109 additions and 9 deletions
|
|
@ -36,8 +36,8 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set ToplevelAgent
|
// Set ToplevelAgent
|
||||||
$this->response->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
|
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
|
||||||
$this->response->addParam(\nre\configs\AppConfig::$defaults['intermediate-mail']);
|
$this->request->addParam(\nre\configs\AppConfig::$defaults['intermediate-mail']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -46,11 +46,24 @@
|
||||||
/**
|
/**
|
||||||
* Use a ToplevelAgent for HTML-mail
|
* Use a ToplevelAgent for HTML-mail
|
||||||
*/
|
*/
|
||||||
public function setHTML()
|
public function setHTML($html=true)
|
||||||
{
|
{
|
||||||
$this->response->clearParams();
|
// Save params
|
||||||
$this->response->addParam(\nre\configs\AppConfig::$defaults['toplevel-htmlmail']);
|
$params = $this->request->getParams(1);
|
||||||
$this->response->addParam(\nre\configs\AppConfig::$defaults['intermediate-mail']);
|
|
||||||
|
// 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)
|
public function setMessage($messageAgent)
|
||||||
{
|
{
|
||||||
$this->response->clearParams(2);
|
// Save params
|
||||||
$this->response->addParam($messageAgent);
|
$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)
|
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()
|
public function run()
|
||||||
{
|
{
|
||||||
|
// Set response
|
||||||
|
$this->response->clearParams();
|
||||||
|
foreach($this->request->getParams() as &$param) {
|
||||||
|
$this->response->addParam($param);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run
|
||||||
try {
|
try {
|
||||||
$exception = parent::run();
|
$exception = parent::run();
|
||||||
|
|
||||||
|
|
@ -122,6 +163,25 @@
|
||||||
return $this->response->getOutput();
|
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
|
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