Made UserCollectionInderface to extend Countable to get the count of existing users

This commit is contained in:
Matias Griese
2019-05-02 14:10:09 +03:00
parent fea9e53be3
commit 416c400367
3 changed files with 12 additions and 2 deletions

View File

@@ -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)

View File

@@ -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);
}
}

View File

@@ -9,7 +9,7 @@
namespace Grav\Common\User\Interfaces;
interface UserCollectionInterface
interface UserCollectionInterface extends \Countable
{
/**
* Load user account.