| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Metricool\Features\AdminNotices\Notices; |
| 6 |
|
| 7 |
use Metricool\Features\AdminNotices\AbstractAdminNotice; |
| 8 |
use Metricool\Services\DashboardService; |
| 9 |
use Metricool\Support\Helpers\Storages\EnvironmentConfig; |
| 10 |
use Metricool\Traits\HasAllowlistControl; |
| 11 |
|
| 12 |
final class UpgradeNotice extends AbstractAdminNotice |
| 13 |
{ |
| 14 |
use HasAllowlistControl; |
| 15 |
|
| 16 |
public const IDENTIFIER = 'upgrade'; |
| 17 |
|
| 18 |
private DashboardService $dashboard; |
| 19 |
|
| 20 |
public function __construct(EnvironmentConfig $env, DashboardService $dashboard) |
| 21 |
{ |
| 22 |
parent::__construct($env); |
| 23 |
|
| 24 |
$this->dashboard = $dashboard; |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* @inheritDoc |
| 29 |
*/ |
| 30 |
protected function canDisplay(): bool |
| 31 |
{ |
| 32 |
return $this->dashboard->isUserOnDashboard() === false && |
| 33 |
$this->dashboard->isForcedLogin(); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* @inheritDoc |
| 38 |
*/ |
| 39 |
public function isSnoozable(): bool |
| 40 |
{ |
| 41 |
return false; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* @inheritDoc |
| 46 |
*/ |
| 47 |
public function getCtaUrl(): string |
| 48 |
{ |
| 49 |
return $this->env->getUrl('plugin.dashboard_url'); |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* @inheritDoc |
| 54 |
*/ |
| 55 |
public function getCtaLabel(): string |
| 56 |
{ |
| 57 |
return __('Sign in now!', 'metricool'); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* @inheritDoc |
| 62 |
*/ |
| 63 |
protected function getContentView(): string |
| 64 |
{ |
| 65 |
return 'admin/notices/upgrade-notice'; |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* @inheritDoc |
| 70 |
*/ |
| 71 |
protected function getContentVariables(): array |
| 72 |
{ |
| 73 |
return []; |
| 74 |
} |
| 75 |
} |
| 76 |
|