Skip to content

Commit

Permalink
Add LazyWidgetManager to replace ineffective WidgetManager.
Browse files Browse the repository at this point in the history
Changed the registration of widgets - now is used improved `LazyWidgetManager` and all widgets extend `BaseLazyWidget` class.

remp/crm#2075
  • Loading branch information
lubos-michalik committed Oct 6, 2022
1 parent 8e6277e commit 5c9bc9c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/ClvModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Crm\ApplicationModule\Commands\CommandsContainerInterface;
use Crm\ApplicationModule\Criteria\ScenariosCriteriaStorage;
use Crm\ApplicationModule\CrmModule;
use Crm\ApplicationModule\Widget\WidgetManagerInterface;
use Crm\ApplicationModule\Widget\LazyWidgetManagerInterface;
use Crm\ClvModule\Commands\ComputeClvCommand;
use Crm\ClvModule\Components\CustomerLifetimeValue\CustomerLifetimeValue;
use Crm\ClvModule\Models\Scenarios\CustomerLifetimeValueCriteria;
Expand All @@ -17,11 +17,11 @@ public function registerCommands(CommandsContainerInterface $commandsContainer)
$commandsContainer->registerCommand($this->getInstance(ComputeClvCommand::class));
}

public function registerWidgets(WidgetManagerInterface $widgetManager)
public function registerLazyWidgets(LazyWidgetManagerInterface $widgetManager)
{
$widgetManager->registerWidget(
'admin.user.detail.box',
$this->getInstance(CustomerLifetimeValue::class),
CustomerLifetimeValue::class,
1800
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Components/CustomerLifetimeValue/CustomerLifetimeValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace Crm\ClvModule\Components\CustomerLifetimeValue;

use Crm\ApplicationModule\Widget\BaseWidget;
use Crm\ApplicationModule\Widget\WidgetManager;
use Crm\ApplicationModule\Widget\BaseLazyWidget;
use Crm\ApplicationModule\Widget\LazyWidgetManager;
use Crm\ClvModule\Repositories\CustomerLifetimeValuesRepository;

/**
* This widget displays customer lifetime value thermometer in user details
*
* @package Crm\ClvModule\Components
*/
class CustomerLifetimeValue extends BaseWidget
class CustomerLifetimeValue extends BaseLazyWidget
{
private const DEFAULT_THERMOMETER_HEIGHT_PX = 200;
private const MIN_THERMOMETER_QUARTILE_HEIGHT_PX = 30;
Expand All @@ -22,10 +22,10 @@ class CustomerLifetimeValue extends BaseWidget
private $customerLifetimeValuesRepository;

public function __construct(
WidgetManager $widgetManager,
LazyWidgetManager $lazyWidgetManager,
CustomerLifetimeValuesRepository $customerLifetimeValuesRepository
) {
parent::__construct($widgetManager);
parent::__construct($lazyWidgetManager);
$this->customerLifetimeValuesRepository = $customerLifetimeValuesRepository;
}

Expand Down

0 comments on commit 5c9bc9c

Please sign in to comment.