Add the request type to the action

This commit is contained in:
Joas Schilling 2015-09-01 10:46:08 +02:00
parent f0ecfa6e6c
commit 3bdfef9107
2 changed files with 11 additions and 2 deletions

View File

@ -34,6 +34,9 @@ class Action implements IAction {
/** @var string */
protected $link;
/** @var string */
protected $requestType;
/** @var string */
protected $icon;
@ -44,6 +47,7 @@ class Action implements IAction {
$this->label = '';
$this->labelParsed = '';
$this->link = '';
$this->requestType = '';
$this->icon = '';
}
@ -93,14 +97,18 @@ class Action implements IAction {
/**
* @param string $link
* @param string $requestType
* @return $this
* @throws \InvalidArgumentException if the link is invalid
* @since 8.2.0
*/
public function setLink($link) {
public function setLink($link, $requestType) {
if (!is_string($link) || $link === '' || isset($link[256])) {
throw new \InvalidArgumentException('The given link is invalid');
}
if (!in_array($requestType, ['GET', 'POST', 'PUT', 'DELETE'])) {
throw new \InvalidArgumentException('The given request type is invalid');
}
$this->link = $link;
return $this;
}

View File

@ -62,11 +62,12 @@ interface IAction {
/**
* @param string $link
* @param string $requestType
* @return $this
* @throws \InvalidArgumentException if the link is invalid
* @since 8.2.0
*/
public function setLink($link);
public function setLink($link, $requestType);
/**
* @return string