mirror of
https://github.com/processwire/processwire.git
synced 2025-08-16 11:44:42 +02:00
Fix issue processwire/processwire-issues#1325
This commit is contained in:
@@ -594,6 +594,8 @@ class PagesType extends Wire implements \IteratorAggregate, \Countable {
|
|||||||
/**
|
/**
|
||||||
* Get the PHP class name used by Page objects of this type
|
* Get the PHP class name used by Page objects of this type
|
||||||
*
|
*
|
||||||
|
* If returned class is not namespaced then `ProcessWire` namespace can be assumed.
|
||||||
|
*
|
||||||
* #pw-group-family
|
* #pw-group-family
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
@@ -604,7 +606,7 @@ class PagesType extends Wire implements \IteratorAggregate, \Countable {
|
|||||||
if($this->pageClass && !$this->template->pageClass) {
|
if($this->pageClass && !$this->template->pageClass) {
|
||||||
$this->template->pageClass = $this->pageClass;
|
$this->template->pageClass = $this->pageClass;
|
||||||
}
|
}
|
||||||
return $this->template->getPageClass(false);
|
return $this->template->getPageClass(true);
|
||||||
}
|
}
|
||||||
if($this->pageClass) return $this->pageClass;
|
if($this->pageClass) return $this->pageClass;
|
||||||
return 'Page';
|
return 'Page';
|
||||||
|
@@ -35,6 +35,14 @@ class Users extends PagesType {
|
|||||||
*/
|
*/
|
||||||
protected $guestUser = null;
|
protected $guestUser = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validated custom page class cache for getPageClass method
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected $validPageClass = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct
|
* Construct
|
||||||
*
|
*
|
||||||
@@ -134,14 +142,32 @@ class Users extends PagesType {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function newUser() {
|
public function newUser() {
|
||||||
$template = $this->wire('templates')->get('user');
|
return $this->wire()->pages->newPage(array(
|
||||||
$pageClass = $template ? $template->getPageClass(false) : 'User';
|
|
||||||
if($pageClass !== 'User' && strpos($pageClass, 'User') === false) $pageClass = 'User';
|
|
||||||
return $this->wire('pages')->newPage(array(
|
|
||||||
'template' => 'user',
|
'template' => 'user',
|
||||||
'pageClass' => $pageClass
|
'pageClass' => $this->getPageClass()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the PHP class name used by Page objects of this type
|
||||||
|
*
|
||||||
|
* #pw-internal
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function getPageClass() {
|
||||||
|
$pageClass = parent::getPageClass();
|
||||||
|
if($pageClass !== 'User' && $pageClass !== 'ProcessWire\User' && $pageClass !== $this->validPageClass) {
|
||||||
|
if(wireInstanceOf($pageClass, 'User')) {
|
||||||
|
$this->validPageClass = $pageClass;
|
||||||
|
} else {
|
||||||
|
$this->error("Class '$pageClass' disregarded because it does not extend 'User'");
|
||||||
|
$pageClass = 'User';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $pageClass;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook called just before a user is saved
|
* Hook called just before a user is saved
|
||||||
|
Reference in New Issue
Block a user