mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
lazy loading of users service
This commit is contained in:
parent
8b9790417d
commit
b0d602d13c
|
|
@ -72,7 +72,7 @@ class BaseController
|
|||
$container->view->set('userentitiesForSidebar', $this->getDatabase()->userentities()->where('show_in_sidebar_menu = 1')->orderBy('name'));
|
||||
try
|
||||
{
|
||||
$usersService = new UsersService();
|
||||
$usersService = $this->getUsersService();
|
||||
if (defined('GROCY_USER_ID'))
|
||||
{
|
||||
$container->view->set('userSettings', $usersService->GetUserSettings(GROCY_USER_ID));
|
||||
|
|
@ -122,5 +122,16 @@ class BaseController
|
|||
return $this->userfieldsService;
|
||||
}
|
||||
|
||||
private $usersService = null;
|
||||
|
||||
protected function getUsersService()
|
||||
{
|
||||
if($this->usersService == null)
|
||||
{
|
||||
$this->usersService = new UsersService();
|
||||
}
|
||||
return $this->usersService;
|
||||
}
|
||||
|
||||
protected $AppContainer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
namespace Grocy\Controllers;
|
||||
|
||||
use \Grocy\Services\BatteriesService;
|
||||
use \Grocy\Services\UsersService;
|
||||
use \Grocy\Services\UserfieldsService;
|
||||
|
||||
class BatteriesController extends BaseController
|
||||
{
|
||||
|
|
@ -12,7 +10,6 @@ class BatteriesController extends BaseController
|
|||
{
|
||||
parent::__construct($container);
|
||||
$this->BatteriesService = new BatteriesService();
|
||||
#$this->UserfieldsService = new UserfieldsService();
|
||||
}
|
||||
|
||||
protected $BatteriesService;
|
||||
|
|
@ -20,7 +17,7 @@ class BatteriesController extends BaseController
|
|||
|
||||
public function Overview(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
|
||||
{
|
||||
$usersService = new UsersService();
|
||||
$usersService = $this->getUsersService();
|
||||
$nextXDays = $usersService->GetUserSettings(GROCY_USER_ID)['batteries_due_soon_days'];
|
||||
|
||||
return $this->renderPage($response, 'batteriesoverview', [
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user