1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-25 23:56:41 +02:00

Add an update to accommodate request in processwire/processwire-issues#648 for wording of warning message when a 3rd party hook has changed a page's name behind the scenes after it was saved

This commit is contained in:
Ryan Cramer
2018-08-06 11:31:35 -04:00
parent a1676b0adb
commit 683e24e010

View File

@@ -16,6 +16,7 @@
* @method InputfieldForm buildForm()
* @method bool processInput(InputfieldForm $form)
* @method array getAllowedTemplates($parent = null)
* @method string nameChangedWarning(Page $page, $namePrevious)
*
*/
@@ -1064,6 +1065,21 @@ class ProcessPageAdd extends Process implements ConfigurableModule, WirePageEdit
);
}
/**
* Hook called when the page's name changed during save
*
* @param Page $page
* @param $namePrevious
* @return string Warning message
*
*/
protected function ___nameChangedWarning(Page $page, $namePrevious) {
return sprintf(
$this->_('Warning, the name you selected "%1$s" has been changed to "%2$s".'),
$namePrevious, $page->name
);
}
/**
* Save the submitted page add form
*
@@ -1155,10 +1171,8 @@ class ProcessPageAdd extends Process implements ConfigurableModule, WirePageEdit
$this->createdPageMessage($this->page);
if($pageName != $this->page->name) {
$this->error(sprintf(
$this->_('Warning, the name you selected "%1$s" was already in use and has been changed to "%2$s".'),
$pageName, $this->page->name
));
$warning = $this->nameChangedWarning($this->page, $pageName);
if($warning) $this->warning($warning);
}
if($publishNow && $publishAdd) {