Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return types on services trait #36

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 6 additions & 27 deletions src/PasswordPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,15 @@
use craft\web\twig\variables\CraftVariable;
use craft\web\UrlManager;
use craft\web\View;

use craftpulse\passwordpolicy\assetbundles\passwordpolicy\PasswordPolicyAsset;
use craftpulse\passwordpolicy\models\SettingsModel;
use craftpulse\passwordpolicy\rules\UserRules;
use craftpulse\passwordpolicy\services\ServicesTrait;
use craftpulse\passwordpolicy\utilities\RetentionUtility;
use craftpulse\passwordpolicy\variables\PasswordPolicyVariable;

use Monolog\Formatter\LineFormatter;

use nystudio107\pluginvite\services\VitePluginService;
use nystudio107\pluginvite\services\ViteService;
use Psr\Log\LogLevel;
use Throwable;
use Yii;
use yii\base\Event;
use yii\base\InvalidRouteException;
use yii\log\Dispatcher;
Expand All @@ -55,10 +49,7 @@
* @package PasswordPolicy
* @since 5.0.0
*
* @property-read ViteService $vite
* @property RetentionService $retention
* @property PasswordService $passwords
*
* @method Settings getSettings()
*/
class PasswordPolicy extends Plugin
{
Expand All @@ -76,31 +67,27 @@ class PasswordPolicy extends Plugin

// Public Properties
// =========================================================================
/**
* @var null|SettingsModel
*/
public static ?SettingsModel $settings = null;
/**
* @var string
*/
public string $schemaVersion = '1.0.0';

/**
* @var bool
*/
public bool $hasCpSection = true;

/**
* @var bool
*/
public bool $hasCpSettings = true;

/**
* @var mixed|object|null
*/
public mixed $queue = null;

/**
* @var null|SettingsModel
*/
public static ?SettingsModel $settings = null;

public function init(): void
{
parent::init();
Expand All @@ -116,7 +103,6 @@ public function init(): void

// Install our global event handlers
$this->installEventHandlers();
$this->installCpEventHandlers();

// Register control panel events
if (Craft::$app->getRequest()->getIsCpRequest()) {
Expand Down Expand Up @@ -208,7 +194,7 @@ protected function settingsHtml(): ?string
{
return Craft::$app->getView()->renderTemplate(
'password-policy/_settings',
[ 'settings' => $this->getSettings() ]
['settings' => $this->getSettings()]
);
}

Expand Down Expand Up @@ -284,13 +270,6 @@ function(TemplateEvent $event) {
// Register Asset Bundle
$view->registerAssetBundle(PasswordPolicyAsset::class);

//$tagOptions = [
// 'depends' => [
// 'craftpulse\\passwordpolicy\\assetbundles\\passwordpolicy\\PasswordPolicyAsset'
// ],
//];
$manifestPath = '@craftpulse/passwordpolicy/web/assets/dist/';
$this->vite->manifestPath = rtrim(Yii::getAlias($manifestPath), '/\\');
//$this->vite->manifestPath = $manifestPath;
$this->vite->register('src/js/indicator.ts', false);
}
Expand Down
9 changes: 5 additions & 4 deletions src/services/ServicesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static function config(): array
'vite' => [
'assetClass' => PasswordPolicyAsset::class,
'checkDevServer' => true,
'useForAllRequests' => true,
'class' => VitePluginService::class,
'devServerInternal' => 'http://craft-password-policy-v5-buildchain-dev:3005',
'devServerPublic' => 'http://localhost:3005',
Expand All @@ -44,21 +45,21 @@ public static function config(): array
/**
* Returns the passwords service
*
* @return Events The events service
* @return Passwords The passwords service
* @throws InvalidConfigException
*/
public function getPasswords(): Events
public function getPasswords(): Passwords
{
return $this->get('passwords');
}

/**
* Returns the retention service
*
* @return Redirects The redirects service
* @return Retention The retention service
* @throws InvalidConfigException
*/
public function getRetention(): Redirects
public function getRetention(): Retention
{
return $this->get('retention');
}
Expand Down
Loading