Skip to content

Commit

Permalink
Merge pull request #36 from craftpulse/develop-v5
Browse files Browse the repository at this point in the history
fix: return types on services trait
  • Loading branch information
michtio authored Jan 7, 2025
2 parents 30f1f7d + bd954bc commit b5b4dfe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
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

0 comments on commit b5b4dfe

Please sign in to comment.