Skip to content
Draft
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
7 changes: 6 additions & 1 deletion src/Cp/Cp.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use CraftCms\Cms\Auth\Passkeys\Passkeys;
use CraftCms\Cms\Cms;
use CraftCms\Cms\Config\GeneralConfig;
use CraftCms\Cms\Cp\Events\CpDataResolving;
use CraftCms\Cms\Edition;
use CraftCms\Cms\Element\Contracts\ElementInterface;
use CraftCms\Cms\Field\Fields;
Expand Down Expand Up @@ -165,7 +166,7 @@ private static function craftData(): array
];
}

return $data + [
$data += [
'allowAdminChanges' => $generalConfig->allowAdminChanges,
'allowUpdates' => $generalConfig->allowUpdates,
'allowUppercaseInSlug' => $generalConfig->allowUppercaseInSlug,
Expand Down Expand Up @@ -217,6 +218,10 @@ private static function craftData(): array
'userIsAdmin' => $currentUser->admin,
'username' => $currentUser->username,
];

event($event = new CpDataResolving($data));

return $event->data;
}

private static function datepickerOptions(Locale $formattingLocale, Locale $locale): array
Expand Down
12 changes: 12 additions & 0 deletions src/Cp/Events/CpDataResolving.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace CraftCms\Cms\Cp\Events;

class CpDataResolving
{
public function __construct(
public array $data = [],
) {}
}
4 changes: 2 additions & 2 deletions yii2-adapter/legacy/elements/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use craft\elements\actions\NewChild;
use craft\elements\actions\Restore;
use craft\elements\conditions\categories\CategoryCondition;
use craft\elements\db\CategoryQuery;
use craft\gql\interfaces\elements\Category as CategoryInterface;
use craft\models\CategoryGroup;
use craft\records\Category as CategoryRecord;
Expand All @@ -39,6 +38,7 @@
use CraftCms\Cms\Twig\Attributes\AllowedInSandbox;
use CraftCms\Cms\User\Elements\User;
use CraftCms\RulesetValidation\Attributes\Ruleset;
use CraftCms\Yii2Adapter\Element\Queries\CategoryQuery;
use CraftCms\Yii2Adapter\Validation\LegacyElementRules;
use GraphQL\Type\Definition\Type;
use Illuminate\Support\Collection;
Expand Down Expand Up @@ -155,7 +155,7 @@ public static function hasStatuses(): bool
*/
public static function find(): CategoryQuery
{
return new CategoryQuery(static::class);
return new CategoryQuery();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions yii2-adapter/legacy/elements/GlobalSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
namespace craft\elements;

use craft\behaviors\FieldLayoutBehavior;
use craft\elements\db\GlobalSetQuery;
use craft\records\GlobalSet as GlobalSetRecord;
use craft\validators\HandleValidator;
use craft\validators\UniqueValidator;
Expand All @@ -21,6 +20,7 @@
use CraftCms\Cms\Twig\Attributes\AllowedInSandbox;
use CraftCms\Cms\User\Elements\User;
use CraftCms\RulesetValidation\Attributes\Ruleset;
use CraftCms\Yii2Adapter\Element\Queries\GlobalSetQuery;
use CraftCms\Yii2Adapter\Validation\LegacyElementRules;
use Illuminate\Support\Facades\Log;
use yii\base\InvalidConfigException;
Expand Down Expand Up @@ -145,7 +145,7 @@ public function canDelete(User $user): bool
*/
public static function find(): GlobalSetQuery
{
return new GlobalSetQuery(static::class);
return new GlobalSetQuery();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions yii2-adapter/legacy/elements/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

use Craft;
use craft\elements\conditions\tags\TagCondition;
use craft\elements\db\TagQuery;
use craft\gql\interfaces\elements\Tag as TagInterface;
use craft\helpers\Db;
use craft\models\TagGroup;
Expand All @@ -21,6 +20,7 @@
use CraftCms\Cms\Twig\Attributes\AllowedInSandbox;
use CraftCms\Cms\User\Elements\User;
use CraftCms\RulesetValidation\Attributes\Ruleset;
use CraftCms\Yii2Adapter\Element\Queries\TagQuery;
use CraftCms\Yii2Adapter\Validation\LegacyElementRules;
use GraphQL\Type\Definition\Type;
use yii\base\InvalidConfigException;
Expand Down Expand Up @@ -108,7 +108,7 @@ public static function isLocalized(): bool
*/
public static function find(): TagQuery
{
return new TagQuery(static::class);
return new TagQuery();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions yii2-adapter/legacy/web/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,13 @@ private function runLaravelAction(string $route, array $params = []): ?BaseRespo
return null;
}

$payload = $request->merge($params)->all();
$query = array_merge($request->query(), $params);

unset($payload['action'], $payload['p']);
unset($query['action'], $query['p']);

$internalRequest = $request->duplicate(
query: [],
request: $payload,
query: $params,
request: $request->post(),
server: array_merge($request->server->all(), [
'REQUEST_URI' => $actionUri,
'HTTP_X_CRAFT_LEGACY_ACTION_BRIDGE' => '1',
Expand Down
12 changes: 9 additions & 3 deletions yii2-adapter/legacy/web/twig/variables/Cp.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,21 @@ public static function registerEvents(): void

Event::listen(function(RegisterCpSettings $event) {
if (\yii\base\Event::hasHandlers(self::class, self::EVENT_REGISTER_CP_SETTINGS)) {
$yiiEvent = new RegisterCpSettingsEvent(['settings' => &$event->settings]);
$yiiEvent = new RegisterCpSettingsEvent(['settings' => $event->settings]);

\yii\base\Event::trigger(self::class, self::EVENT_REGISTER_CP_SETTINGS, $yiiEvent);

$event->settings = $yiiEvent->settings;
}
});

Event::listen(function(RegisterReadonlyCpSettings $event) {
if (\yii\base\Event::hasHandlers(self::class, self::EVENT_REGISTER_READ_ONLY_CP_SETTINGS)) {
$yiiEvent = new RegisterCpSettingsEvent(['settings' => &$event->settings]);
$yiiEvent = new RegisterCpSettingsEvent(['settings' => $event->settings]);

\yii\base\Event::trigger(self::class, self::EVENT_REGISTER_READ_ONLY_CP_SETTINGS, $yiiEvent);

$event->settings = $yiiEvent->settings;
}
});

Expand All @@ -178,9 +182,11 @@ public static function registerEvents(): void

Event::listen(function(FormActionsResolving $event) {
if (\yii\base\Event::hasHandlers(self::class, self::EVENT_REGISTER_FORM_ACTIONS)) {
$yiiEvent = new FormActionsEvent(['formActions' => &$event->formActions]);
$yiiEvent = new FormActionsEvent(['formActions' => $event->formActions]);

\yii\base\Event::trigger(self::class, self::EVENT_REGISTER_FORM_ACTIONS, $yiiEvent);

$event->formActions = $yiiEvent->formActions;
}
});
}
Expand Down
10 changes: 5 additions & 5 deletions yii2-adapter/resources/templates/settings/categories/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

{% import '_includes/forms.twig' as forms %}

{% set headlessMode = app.config.craft.general.headlessMode %}
{% set headlessMode = craft.app.config.general.headlessMode %}

{% if readOnly %}
{% set contentNotice = readOnlyNotice() %}
Expand All @@ -35,7 +35,7 @@
id: 'name',
name: 'name',
value: categoryGroup.name,
errors: categoryGroup.errors.get('name'),
errors: categoryGroup.getErrors('name'),
autofocus: true,
required: true,
disabled: readOnly,
Expand All @@ -50,7 +50,7 @@
autocorrect: false,
autocapitalize: false,
value: categoryGroup.handle,
errors: categoryGroup.errors.get('handle'),
errors: categoryGroup.getErrors('handle'),
required: true,
disabled: readOnly,
}) }}
Expand All @@ -62,7 +62,7 @@
name: 'maxLevels',
value: categoryGroup.maxLevels,
size: 5,
errors: categoryGroup.errors.get('maxLevels'),
errors: categoryGroup.getErrors('maxLevels'),
disabled: readOnly,
}) }}

Expand All @@ -82,7 +82,7 @@
<hr>

{% set siteRows = [] %}
{% set siteErrors = categoryGroup.errors.get('siteSettings') %}
{% set siteErrors = categoryGroup.getErrors('siteSettings') %}

{% for site in Sites.getAllSites() %}
{% set siteSettings = categoryGroup.siteSettings[site.id] ?? null %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "_layouts/cp" %}
{% set title = "Category Groups"|t('yii2-adapter') %}
{% set readOnly = not app.config.craft.general.allowAdminChanges %}
{% set readOnly = not craft.app.config.general.allowAdminChanges %}

{% do registerLegacyAsset('CraftCms\\Cms\\View\\LegacyAssets\\AdminTableAsset') -%}

Expand Down
4 changes: 2 additions & 2 deletions yii2-adapter/resources/templates/settings/globals/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
id: 'name',
name: 'name',
value: globalSet.name,
errors: globalSet.errors.get('name'),
errors: globalSet.getErrors('name'),
autofocus: true,
required: true,
disabled: readOnly,
Expand All @@ -50,7 +50,7 @@
autocorrect: false,
autocapitalize: false,
value: globalSet.handle,
errors: globalSet.errors.get('handle'),
errors: globalSet.getErrors('handle'),
required: true,
disabled: readOnly,
}) }}
Expand Down
4 changes: 2 additions & 2 deletions yii2-adapter/resources/templates/settings/tags/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
id: 'name',
name: 'name',
value: tagGroup.name,
errors: tagGroup.errors.get('name'),
errors: tagGroup.getErrors('name'),
autofocus: true,
required: true,
disabled: readOnly,
Expand All @@ -48,7 +48,7 @@
autocorrect: false,
autocapitalize: false,
value: tagGroup.handle,
errors: tagGroup.errors.get('handle'),
errors: tagGroup.getErrors('handle'),
required: true,
disabled: readOnly,
}) }}
Expand Down
2 changes: 1 addition & 1 deletion yii2-adapter/resources/templates/settings/tags/index.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "_layouts/cp" %}
{% set title = "Tag Groups"|t('yii2-adapter') %}
{% set readOnly = not app.config.craft.general.allowAdminChanges %}
{% set readOnly = not craft.app.config.general.allowAdminChanges %}

{% do registerLegacyAsset('CraftCms\\Cms\\View\\LegacyAssets\\AdminTableAsset') -%}

Expand Down
23 changes: 23 additions & 0 deletions yii2-adapter/src/Database/DeprecatedTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace CraftCms\Yii2Adapter\Database;

/**
* This class provides constants for defining Craft’s deprecated database table names.
*/
readonly class DeprecatedTable
{
public const string CATEGORIES = 'categories';

public const string CATEGORYGROUPS = 'categorygroups';

public const string CATEGORYGROUPS_SITES = 'categorygroups_sites';

public const string TAGGROUPS = 'taggroups';

public const string TAGS = 'tags';

public const string GLOBALSETS = 'globalsets';
}
Loading
Loading