Skip to content

Commit

Permalink
chore: ECS code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Aug 19, 2024
1 parent d0aff57 commit 79268f9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
38 changes: 19 additions & 19 deletions src/Retour.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ protected function installEventListeners()
Event::on(
ClearCaches::class,
ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
function (RegisterCacheOptionsEvent $event) {
function(RegisterCacheOptionsEvent $event) {
Craft::debug(
'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS',
__METHOD__
Expand All @@ -301,7 +301,7 @@ function (RegisterCacheOptionsEvent $event) {
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_INSTALL_PLUGIN,
function (PluginEvent $event) {
function(PluginEvent $event) {
if ($event->plugin === $this) {
// Invalidate our caches after we've been installed
$this->clearAllCaches();
Expand All @@ -328,7 +328,7 @@ protected function installGlobalEventListeners()
Event::on(
CraftVariable::class,
CraftVariable::EVENT_INIT,
function (Event $event) {
function(Event $event) {
/** @var CraftVariable $variable */
$variable = $event->sender;
$variable->set('retour', [
Expand All @@ -338,7 +338,7 @@ function (Event $event) {
}
);

$prepareRedirectOnElementChange = function (ElementEvent $event) {
$prepareRedirectOnElementChange = function(ElementEvent $event) {
/** @var Element $element */
$element = $event->element;
if ($element !== null && !$element->propagating && !$event->isNew && $element->getUrl() !== null) {
Expand All @@ -361,7 +361,7 @@ function (Event $event) {
}
};

$insertRedirectOnElementChange = function (ElementEvent $event) {
$insertRedirectOnElementChange = function(ElementEvent $event) {
/** @var Element $element */
$element = $event->element;
if ($element !== null && !$event->isNew && $element->getUrl() !== null) {
Expand All @@ -379,7 +379,7 @@ function (Event $event) {
Event::on(
Elements::class,
Elements::EVENT_BEFORE_SAVE_ELEMENT,
function (ElementEvent $event) use ($prepareRedirectOnElementChange) {
function(ElementEvent $event) use ($prepareRedirectOnElementChange) {
Craft::debug(
'Elements::EVENT_BEFORE_SAVE_ELEMENT',
__METHOD__
Expand All @@ -391,7 +391,7 @@ function (ElementEvent $event) use ($prepareRedirectOnElementChange) {
Event::on(
Elements::class,
Elements::EVENT_AFTER_SAVE_ELEMENT,
function (ElementEvent $event) use ($insertRedirectOnElementChange) {
function(ElementEvent $event) use ($insertRedirectOnElementChange) {
Craft::debug(
'Elements::EVENT_AFTER_SAVE_ELEMENT',
__METHOD__
Expand All @@ -403,7 +403,7 @@ function (ElementEvent $event) use ($insertRedirectOnElementChange) {
Event::on(
Elements::class,
Elements::EVENT_BEFORE_UPDATE_SLUG_AND_URI,
function (ElementEvent $event) use ($prepareRedirectOnElementChange) {
function(ElementEvent $event) use ($prepareRedirectOnElementChange) {
Craft::debug(
'Elements::EVENT_BEFORE_UPDATE_SLUG_AND_URI',
__METHOD__
Expand All @@ -415,7 +415,7 @@ function (ElementEvent $event) use ($prepareRedirectOnElementChange) {
Event::on(
Elements::class,
Elements::EVENT_AFTER_UPDATE_SLUG_AND_URI,
function (ElementEvent $event) use ($insertRedirectOnElementChange) {
function(ElementEvent $event) use ($insertRedirectOnElementChange) {
Craft::debug(
'Elements::EVENT_AFTER_UPDATE_SLUG_AND_URI',
__METHOD__
Expand All @@ -428,7 +428,7 @@ function (ElementEvent $event) use ($insertRedirectOnElementChange) {
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_LOAD_PLUGINS,
function () {
function() {
// Install these only after all other plugins have loaded
$request = Craft::$app->getRequest();
// Only respond to non-console site requests
Expand All @@ -445,7 +445,7 @@ function () {
Event::on(
Fields::class,
Fields::EVENT_REGISTER_FIELD_TYPES,
function (RegisterComponentTypesEvent $event) {
function(RegisterComponentTypesEvent $event) {
$event->types[] = ShortLinkField::class;
}
);
Expand All @@ -454,7 +454,7 @@ function (RegisterComponentTypesEvent $event) {
Event::on(
Gql::class,
Gql::EVENT_REGISTER_GQL_TYPES,
function (RegisterGqlTypesEvent $event) {
function(RegisterGqlTypesEvent $event) {
Craft::debug(
'Gql::EVENT_REGISTER_GQL_TYPES',
__METHOD__
Expand All @@ -466,7 +466,7 @@ function (RegisterGqlTypesEvent $event) {
Event::on(
Gql::class,
Gql::EVENT_REGISTER_GQL_QUERIES,
function (RegisterGqlQueriesEvent $event) {
function(RegisterGqlQueriesEvent $event) {
Craft::debug(
'Gql::EVENT_REGISTER_GQL_QUERIES',
__METHOD__
Expand All @@ -482,7 +482,7 @@ function (RegisterGqlQueriesEvent $event) {
Event::on(
Gql::class,
Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS,
function (RegisterGqlSchemaComponentsEvent $event) {
function(RegisterGqlSchemaComponentsEvent $event) {
Craft::debug(
'Gql::EVENT_REGISTER_GQL_SCHEMA_COMPONENTS',
__METHOD__
Expand Down Expand Up @@ -512,7 +512,7 @@ protected function installSiteEventListeners()
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_SITE_URL_RULES,
function (RegisterUrlRulesEvent $event) {
function(RegisterUrlRulesEvent $event) {
Craft::debug(
'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
__METHOD__
Expand All @@ -535,7 +535,7 @@ protected function installCpEventListeners()
Event::on(
Dashboard::class,
Dashboard::EVENT_REGISTER_WIDGET_TYPES,
function (RegisterComponentTypesEvent $event) {
function(RegisterComponentTypesEvent $event) {
/** @var User $user */
$user = Craft::$app->getUser();
if ($currentUser = $user->getIdentity()) {
Expand All @@ -549,7 +549,7 @@ function (RegisterComponentTypesEvent $event) {
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_CP_URL_RULES,
function (RegisterUrlRulesEvent $event) {
function(RegisterUrlRulesEvent $event) {
Craft::debug(
'UrlManager::EVENT_REGISTER_CP_URL_RULES',
__METHOD__
Expand All @@ -565,7 +565,7 @@ function (RegisterUrlRulesEvent $event) {
Event::on(
UserPermissions::class,
UserPermissions::EVENT_REGISTER_PERMISSIONS,
function (RegisterUserPermissionsEvent $event) {
function(RegisterUserPermissionsEvent $event) {
Craft::debug(
'UserPermissions::EVENT_REGISTER_PERMISSIONS',
__METHOD__
Expand All @@ -587,7 +587,7 @@ protected function handleSiteRequest()
Event::on(
ErrorHandler::class,
ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION,
function (ExceptionEvent $event) {
function(ExceptionEvent $event) {
Craft::debug(
'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION',
__METHOD__
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function actionImportCsvColumns()
}
$hasErrors = false;
// If we have headers, then we have a file, so parse it
/** @phpstan-ignore-next-line */
if ($csv && $headers) {
switch (VersionHelper::getLeagueCsvVersion()) {
case 8:
Expand Down Expand Up @@ -372,7 +373,7 @@ protected function importCsvApi8(AbstractCsv $csv, array $columns, array $header
$columns = ArrayHelper::filterEmptyStringsFromArray($columns);
$rowIndex = 1;
/** @phpstan-ignore-next-line */
$csv->each(function ($row) use ($headers, $columns, &$rowIndex, &$hasErrors) {
$csv->each(function($row) use ($headers, $columns, &$rowIndex, &$hasErrors) {
$redirectConfig = [
'id' => 0,
];
Expand Down
3 changes: 1 addition & 2 deletions src/controllers/RedirectsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ public function actionEditRedirect(
string $defaultUrl = '',
int $siteId = 0,
StaticRedirectsModel $redirect = null
): Response
{
): Response {
$variables = [];
PermissionHelper::controllerPermissionCheck('retour:redirects');

Expand Down
2 changes: 1 addition & 1 deletion src/translations/en/retour.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,5 @@
'Some errors occured .' => 'Some errors occured .',
'Some errors occured importing the CSV file.' => 'Some errors occured importing the CSV file.',
'Select the priority that will determine the order of mathching the redirect.' => 'Select the priority that will determine the order of mathching the redirect.',
'Excluded URI: {uri} due to match of pattern: {pattern}' => 'Excluded URI: {uri} due to match of pattern: {pattern}'
'Excluded URI: {uri} due to match of pattern: {pattern}' => 'Excluded URI: {uri} due to match of pattern: {pattern}',
];

0 comments on commit 79268f9

Please sign in to comment.