diff --git a/wire/core/Permission.php b/wire/core/Permission.php index 637a30e8..b9767fa3 100644 --- a/wire/core/Permission.php +++ b/wire/core/Permission.php @@ -52,8 +52,19 @@ class Permission extends Page { */ public function __construct(Template $tpl = null) { parent::__construct($tpl); - if(is_null($tpl)) $this->template = $this->wire('templates')->get('permission'); - $this->parent = $this->wire('pages')->get($this->wire('config')->permissionsPageID); + if(!$tpl) $this->template = $this->wire()->templates->get('permission'); + $this->_parent_id = $this->wire()->config->permissionsPageID; + } + + /** + * Wired to API + * + */ + public function wired() { + parent::wired(); + $template = $this->wire()->templates->get('permission'); + if($template !== $this->template && (!$this->template || $this->template->name === 'permission')) $this->template = $template; + $this->_parent_id = $this->wire()->config->permissionsPageID; } /** diff --git a/wire/core/Role.php b/wire/core/Role.php index 806f26f0..4b659088 100644 --- a/wire/core/Role.php +++ b/wire/core/Role.php @@ -30,8 +30,16 @@ class Role extends Page { */ public function __construct(Template $tpl = null) { parent::__construct($tpl); - if(is_null($tpl)) $this->template = $this->getPredefinedTemplate(); - $this->parent = $this->getPredefinedParent(); + } + + /** + * Wired to API + * + */ + public function wired() { + parent::wired(); + if(!$this->template) $this->template = $this->getPredefinedTemplate(); + if(!$this->_parent) $this->setParent($this->getPredefinedParent()); } /** diff --git a/wire/core/User.php b/wire/core/User.php index ec210892..ba3a63a3 100644 --- a/wire/core/User.php +++ b/wire/core/User.php @@ -45,11 +45,22 @@ class User extends Page { * */ public function __construct(Template $tpl = null) { + if(!$tpl) $this->template = $this->wire()->templates->get('user'); + $this->_parent_id = $this->wire()->config->usersPageID; parent::__construct($tpl); - if(is_null($tpl)) { - $this->template = $this->wire('templates')->get('user'); - } - if(!$this->parent_id) $this->set('parent_id', $this->wire('config')->usersPageID); + } + + /** + * Wired to API + * + * @throws WireException + * + */ + public function wired() { + parent::wired(); + $template = $this->wire()->templates->get('user'); + if($template !== $this->template && (!$this->template || $this->template->name === 'user')) $this->template = $template; + $this->_parent_id = $this->wire()->config->usersPageID; } /** diff --git a/wire/modules/LanguageSupport/Language.php b/wire/modules/LanguageSupport/Language.php index 74ff9dcd..f45fed3b 100644 --- a/wire/modules/LanguageSupport/Language.php +++ b/wire/modules/LanguageSupport/Language.php @@ -30,9 +30,17 @@ class Language extends Page { */ public function __construct(Template $tpl = null) { parent::__construct($tpl); - if(is_null($tpl)) { - $this->template = $this->wire('templates')->get('language'); - } + if(!$tpl) $this->template = $this->wire()->templates->get('language'); + } + + /** + * Wired to API + * + */ + public function wired() { + parent::wired(); + $template = $this->wire()->templates->get('language'); + if($template !== $this->template && (!$this->template || $this->template->name === 'language')) $this->template = $template; } /**