mirror of
https://github.com/getgrav/grav.git
synced 2026-07-07 02:23:45 +02:00
Made UserCollectionInderface to extend Countable to get the count of existing users
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
1. [](#new)
|
||||
* Added `Route::withoutParams()` methods
|
||||
* Added `Pages::setCheckMethod()` method to override page configuration in Admin Plugin
|
||||
* Added `Cache::clearCache('invalidate')` parameter for just invalidating the cache without deleting any cached files
|
||||
* Added `Cache::clearCache('invalidate')` parameter for just invalidating the cache without deleting any cached files
|
||||
* Made `UserCollectionInderface` to extend `Countable` to get the count of existing users
|
||||
1. [](#improved)
|
||||
* Flex admin: added default search options for flex objects
|
||||
1. [](#bugfix)
|
||||
|
||||
@@ -118,4 +118,13 @@ class UserCollection implements UserCollectionInterface
|
||||
|
||||
return $file_path && unlink($file_path);
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
// check for existence of a user account
|
||||
$account_dir = $file_path = Grav::instance()['locator']->findResource('account://');
|
||||
$accounts = glob($account_dir . '/*.yaml') ?: [];
|
||||
|
||||
return count($accounts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace Grav\Common\User\Interfaces;
|
||||
|
||||
interface UserCollectionInterface
|
||||
interface UserCollectionInterface extends \Countable
|
||||
{
|
||||
/**
|
||||
* Load user account.
|
||||
|
||||
Reference in New Issue
Block a user