mirror of
https://github.com/processwire/processwire.git
synced 2025-08-08 07:47:00 +02:00
phpdoc update and hook example in wire/core/Users.php
This commit is contained in:
@@ -12,6 +12,14 @@
|
||||
|
||||
class PageComparison {
|
||||
|
||||
/**
|
||||
* Selector properties that the matches() method ignores
|
||||
*
|
||||
* @var string[]
|
||||
*
|
||||
*/
|
||||
protected $matchesIgnores = array('limit', 'start', 'sort', 'include');
|
||||
|
||||
/**
|
||||
* Is this page of the given type? (status, template, etc.)
|
||||
*
|
||||
@@ -231,7 +239,6 @@ class PageComparison {
|
||||
}
|
||||
|
||||
$matches = false;
|
||||
$ignores = array('limit', 'start', 'sort', 'include');
|
||||
|
||||
foreach($selectors as $selector) {
|
||||
|
||||
@@ -240,7 +247,7 @@ class PageComparison {
|
||||
|
||||
if(is_array($property)) $property = reset($property);
|
||||
if(strpos($property, '.')) list($property, $subproperty) = explode('.', $property, 2);
|
||||
if(in_array($property, $ignores)) continue;
|
||||
if(in_array($property, $this->matchesIgnores)) continue;
|
||||
|
||||
$matches = true;
|
||||
$value = $page->getUnformatted($property);
|
||||
|
@@ -156,10 +156,12 @@ class Users extends PagesType {
|
||||
*
|
||||
*/
|
||||
public function newUser() {
|
||||
return $this->wire()->pages->newPage(array(
|
||||
/** @var User $user */
|
||||
$user = $this->wire()->pages->newPage(array(
|
||||
'template' => 'user',
|
||||
'pageClass' => $this->getPageClass()
|
||||
));
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,6 +216,33 @@ class Users extends PagesType {
|
||||
return $qty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a User
|
||||
*
|
||||
* - This is the same as calling $user->save()
|
||||
* - If the user is new, it will be inserted. If existing, it will be updated.
|
||||
* - If you want to just save a particular field for the user, use `$user->save($fieldName)` instead.
|
||||
*
|
||||
* **Hook note:**
|
||||
* If you want to hook this method, please hook the `Users::saveReady`, `Users::saved`, or any one of
|
||||
* the `Pages::save*` hook methods instead, as this method will not capture users saved directly
|
||||
* through `$pages->save($user)`.
|
||||
* ~~~~~
|
||||
* // Example of hooking $pages->save() on User objects only
|
||||
* $wire->addHookBefore('Pages::save(<User>)', function(HookEvent $e) {
|
||||
* $user = $event->arguments(0);
|
||||
* });
|
||||
* ~~~~~
|
||||
*
|
||||
* @param Page $page
|
||||
* @return bool True on success
|
||||
* @throws WireException
|
||||
*
|
||||
*/
|
||||
public function ___save(Page $page) {
|
||||
return parent::___save($page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook called just before a user is saved
|
||||
*
|
||||
|
Reference in New Issue
Block a user