Skip to content

Commit

Permalink
Update ECS for Craft 4
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Mar 5, 2022
1 parent 0a74786 commit 42def75
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion ecs.php
Expand Up @@ -15,5 +15,5 @@
__FILE__,
]);

$containerConfigurator->import(SetList::CRAFT_CMS_3);
$containerConfigurator->import(SetList::CRAFT_CMS_4);
};
2 changes: 1 addition & 1 deletion src/console/ErrorHandler.php
Expand Up @@ -20,7 +20,7 @@ class ErrorHandler extends \yii\console\ErrorHandler
/**
* @event ExceptionEvent The event that is triggered before handling an exception.
*/
const EVENT_BEFORE_HANDLE_EXCEPTION = 'beforeHandleException';
public const EVENT_BEFORE_HANDLE_EXCEPTION = 'beforeHandleException';

/**
* @inheritdoc
Expand Down
10 changes: 5 additions & 5 deletions src/controllers/ElementsController.php
Expand Up @@ -601,7 +601,7 @@ private function _contextMenu(
ElementInterface $element,
bool $isMultiSiteElement,
bool $isUnpublishedDraft,
array $propSiteIds
array $propSiteIds,
): ?string {
$showDrafts = !$isUnpublishedDraft;

Expand Down Expand Up @@ -631,7 +631,7 @@ private function _addlButtons(
bool $enablePreview,
bool $isCurrent,
bool $isUnpublishedDraft,
bool $isDraft
bool $isDraft,
): string {
$components = [];

Expand Down Expand Up @@ -698,7 +698,7 @@ private function _prepareEditor(
string $containerId,
callable $contentFn,
callable $sidebarFn,
callable $jsSettingsFn
callable $jsSettingsFn,
) {
$fieldLayout = $element->getFieldLayout();
$form = $fieldLayout?->createForm($element, !$canSave, [
Expand All @@ -722,7 +722,7 @@ private function _editorContent(
ElementInterface $element,
bool $isUnpublishedDraft,
bool $canSave,
?FieldLayoutForm $form
?FieldLayoutForm $form,
): string {
$components = [];

Expand Down Expand Up @@ -757,7 +757,7 @@ private function _editorSidebar(
bool $canSave,
bool $isCurrent,
bool $isMultiSiteElement,
bool $canEditMultipleSites
bool $canEditMultipleSites,
): string {
$components = [];

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/PreviewController.php
Expand Up @@ -112,7 +112,7 @@ public function actionPreview(
int $siteId,
?int $draftId = null,
?int $revisionId = null,
?int $userId = null
?int $userId = null,
): Response {
// Make sure a token was used to get here
$this->requireToken();
Expand Down
8 changes: 4 additions & 4 deletions src/elements/conditions/assets/FileSizeConditionRule.php
Expand Up @@ -21,10 +21,10 @@
*/
class FileSizeConditionRule extends BaseNumberConditionRule implements ElementConditionRuleInterface
{
const UNIT_B = 'B';
const UNIT_KB = 'KB';
const UNIT_MB = 'MB';
const UNIT_GB = 'GB';
public const UNIT_B = 'B';
public const UNIT_KB = 'KB';
public const UNIT_MB = 'MB';
public const UNIT_GB = 'GB';

/**
* @var string The size unit
Expand Down
2 changes: 1 addition & 1 deletion src/fields/conditions/RelationalFieldConditionRule.php
Expand Up @@ -21,7 +21,7 @@ class RelationalFieldConditionRule extends BaseElementSelectConditionRule implem
{
use FieldConditionRuleTrait;

const OPERATOR_RELATED_TO = 'relatedTo';
public const OPERATOR_RELATED_TO = 'relatedTo';

/**
* @inheritdoc
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/Cp.php
Expand Up @@ -258,7 +258,7 @@ public static function elementHtml(
bool $showThumb = true,
bool $showLabel = true,
bool $showDraftName = true,
bool $single = false
bool $single = false,
): string {
$isDraft = $element->getIsDraft();
$isRevision = !$isDraft && $element->getIsRevision();
Expand Down Expand Up @@ -437,7 +437,7 @@ public static function elementPreviewHtml(
bool $showStatus = true,
bool $showThumb = true,
bool $showLabel = true,
bool $showDraftName = true
bool $showDraftName = true,
): string {
if (empty($elements)) {
return '';
Expand Down
4 changes: 2 additions & 2 deletions src/services/Drafts.php
Expand Up @@ -119,7 +119,7 @@ public function createDraft(
?string $name = null,
?string $notes = null,
array $newAttributes = [],
bool $provisional = false
bool $provisional = false,
): ElementInterface {
// Make sure the canonical element isn't a draft or revision
if ($canonical->getIsDraft() || $canonical->getIsRevision()) {
Expand Down Expand Up @@ -458,7 +458,7 @@ public function insertDraftRow(
?int $creatorId = null,
?int $canonicalId = null,
bool $trackChanges = false,
bool $provisional = false
bool $provisional = false,
): int {
Db::insert(Table::DRAFTS, [
'canonicalId' => $canonicalId,
Expand Down
18 changes: 9 additions & 9 deletions src/services/ElementSources.php
Expand Up @@ -30,21 +30,21 @@ class ElementSources extends Component
/**
* @event DefineSourceTableAttributesEvent The event that is triggered when defining the available table attributes for a source.
*/
const EVENT_DEFINE_SOURCE_TABLE_ATTRIBUTES = 'defineSourceTableAttributes';
public const EVENT_DEFINE_SOURCE_TABLE_ATTRIBUTES = 'defineSourceTableAttributes';

/**
* @event DefineSourceSortOptionsEvent The event that is triggered when defining the available sort options for a source.
*/
const EVENT_DEFINE_SOURCE_SORT_OPTIONS = 'defineSourceSortOptions';
public const EVENT_DEFINE_SOURCE_SORT_OPTIONS = 'defineSourceSortOptions';

const TYPE_HEADING = 'heading';
const TYPE_NATIVE = 'native';
const TYPE_CUSTOM = 'custom';
public const TYPE_HEADING = 'heading';
public const TYPE_NATIVE = 'native';
public const TYPE_CUSTOM = 'custom';

const CONTEXT_FIELD = 'field';
const CONTEXT_INDEX = 'index';
const CONTEXT_MODAL = 'modal';
const CONTEXT_SETTINGS = 'settings';
public const CONTEXT_FIELD = 'field';
public const CONTEXT_INDEX = 'index';
public const CONTEXT_MODAL = 'modal';
public const CONTEXT_SETTINGS = 'settings';

/**
* Filters out any unnecessary headings from a given source list.
Expand Down
4 changes: 2 additions & 2 deletions src/services/Gql.php
Expand Up @@ -458,7 +458,7 @@ public function executeQuery(
string $query,
?array $variables = null,
?string $operationName = null,
bool $debugMode = false
bool $debugMode = false,
): array {
$event = new ExecuteGqlQueryEvent([
'schemaId' => $schema->id,
Expand Down Expand Up @@ -1243,7 +1243,7 @@ private function _getCacheKey(
mixed $rootValue,
mixed $context,
?array $variables = null,
?string $operationName = null
?string $operationName = null,
): ?string {
// No cache key, if explicitly disabled
$generalConfig = Craft::$app->getConfig()->getGeneral();
Expand Down
4 changes: 2 additions & 2 deletions src/web/Controller.php
Expand Up @@ -253,7 +253,7 @@ public function asFailure(
public function asSuccess(
?string $message = null,
array $data = [],
?string $redirect = null
?string $redirect = null,
): ?YiiResponse {
if ($this->request->getAcceptsJson()) {
return $this->asJson($data + array_filter([
Expand Down Expand Up @@ -320,7 +320,7 @@ public function asModelSuccess(
?string $message = null,
?string $modelName = null,
array $data = [],
?string $redirect = null
?string $redirect = null,
): YiiResponse {
$data += array_filter([
'modelName' => $modelName,
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/gql/PrepareQueryTest.php
Expand Up @@ -94,13 +94,13 @@ protected function _after()
$this->_userGroup->delete();
}

const VOLUME_UID = 'volume-uid';
const CATEGORY_GROUP_UID = 'categoryGroup-uid';
const SECTION_UID = 'section-uid';
const ENTRY_TYPE_UID = 'entryType-uid';
const GLOBAL_SET_UID = 'globalSet-uid';
const TAG_GROUP_UID = 'tagGroup-uid';
const USER_GROUP_UID = 'userGroup-uid';
public const VOLUME_UID = 'volume-uid';
public const CATEGORY_GROUP_UID = 'categoryGroup-uid';
public const SECTION_UID = 'section-uid';
public const ENTRY_TYPE_UID = 'entryType-uid';
public const GLOBAL_SET_UID = 'globalSet-uid';
public const TAG_GROUP_UID = 'tagGroup-uid';
public const USER_GROUP_UID = 'userGroup-uid';

/**
* Test relational field query preparation
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/helpers/UrlHelperTest.php
Expand Up @@ -23,13 +23,13 @@
*/
class UrlHelperTest extends Unit
{
const ABSOLUTE_URL = 'http://craftcms.com/';
const ABSOLUTE_URL_HTTPS = 'https://craftcms.com/';
const ABSOLUTE_URL_WWW = 'http://www.craftcms.com/';
const ABSOLUTE_URL_HTTPS_WWW = 'https://www.craftcms.com/';
const NON_ABSOLUTE_URL = 'craftcms.com/';
const NON_ABSOLUTE_URL_WWW = 'www.craftcms.com/';
const PROTOCOL_RELATIVE_URL = '//craftcms.com/';
public const ABSOLUTE_URL = 'http://craftcms.com/';
public const ABSOLUTE_URL_HTTPS = 'https://craftcms.com/';
public const ABSOLUTE_URL_WWW = 'http://www.craftcms.com/';
public const ABSOLUTE_URL_HTTPS_WWW = 'https://www.craftcms.com/';
public const NON_ABSOLUTE_URL = 'craftcms.com/';
public const NON_ABSOLUTE_URL_WWW = 'www.craftcms.com/';
public const PROTOCOL_RELATIVE_URL = '//craftcms.com/';

/**
* @var UnitTester
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/helpers/dbhelper/DbHelperTest.php
Expand Up @@ -29,7 +29,7 @@
*/
class DbHelperTest extends Unit
{
const MULTI_PARSEPARAM_NOT = [
public const MULTI_PARSEPARAM_NOT = [
'or',
[
'!=',
Expand All @@ -43,7 +43,7 @@ class DbHelperTest extends Unit
],
];

const MULTI_PARSEPARAM = ['foo' => ['field_1', 'field_2']];
public const MULTI_PARSEPARAM = ['foo' => ['field_1', 'field_2']];

/**
* @var UnitTester
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/search/SearchQueryTest.php
Expand Up @@ -26,7 +26,7 @@
*/
class SearchQueryTest extends Unit
{
const DEFAULT_SEARCH_QUERY_TERM_CONFIG = [
public const DEFAULT_SEARCH_QUERY_TERM_CONFIG = [
'exclude' => false,
'exact' => false,
'subLeft' => false,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/web/ViewTest.php
Expand Up @@ -118,7 +118,7 @@ public function testPrivateResolveTemplate(
string $basePath,
string $name,
?array $defaultTemplateExtensions = null,
?array $indexTemplateFilenames = null
?array $indexTemplateFilenames = null,
) {
// If the data wants to set something custom? Set it as a prop.
if ($defaultTemplateExtensions !== null) {
Expand Down

0 comments on commit 42def75

Please sign in to comment.