mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 16:26:59 +02:00
Update HookEvent class to support named arguments directly from $event object
This commit is contained in:
@@ -119,8 +119,10 @@ class HookEvent extends WireData {
|
||||
*/
|
||||
public function argumentsByName($n = '') {
|
||||
|
||||
$names = $this->getArgumentNames();
|
||||
$arguments = $this->arguments();
|
||||
if(isset($arguments[$n])) return $arguments[$n];
|
||||
|
||||
$names = $this->getArgumentNames();
|
||||
|
||||
if($n) {
|
||||
$key = array_search($n, $names);
|
||||
@@ -222,6 +224,22 @@ class HookEvent extends WireData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get
|
||||
*
|
||||
* @param object|string $key
|
||||
* @return mixed|null
|
||||
*
|
||||
*/
|
||||
public function get($key) {
|
||||
$value = parent::get($key);
|
||||
if($value === null && !ctype_digit("$key") && array_key_exists($key, $this->data['arguments'])) {
|
||||
// allow named arguments to be accessed from get()
|
||||
$value = $this->data['arguments'][$key];
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string representing the HookEvent
|
||||
*
|
||||
|
@@ -264,6 +264,10 @@ class InputfieldFile extends Inputfield implements InputfieldItemList, Inputfiel
|
||||
// if given a Pagefile rather than a Pagefiles, use the Pagefiles instead
|
||||
$value = $value->pagefiles;
|
||||
}
|
||||
if($value instanceof Pagefiles) {
|
||||
$page = $value->page;
|
||||
if($page && $page->template->noLang) $this->noLang = true;
|
||||
}
|
||||
}
|
||||
return parent::setAttribute($key, $value);
|
||||
}
|
||||
|
Reference in New Issue
Block a user