From e7ebbb2cfb16e6b16917ec11519e9a694230c179 Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Fri, 23 Aug 2024 08:58:17 +0800 Subject: [PATCH 01/30] Enforce PSR-12 on Winter CMS core files This commit changes the PHP code sniffer to use PSR-12 rules, as that ruleset will pick up a lot of the code style issues being flagged in PRs recently. In order to set the baseline, all current core files have been reformatted to fit the ruleset. --- bootstrap/app.php | 2 +- bootstrap/autoload.php | 6 +- config/app.php | 2 +- modules/backend/ServiceProvider.php | 4 +- modules/backend/behaviors/FormController.php | 15 +- .../behaviors/ImportExportController.php | 49 ++--- modules/backend/behaviors/ListController.php | 16 +- .../backend/behaviors/RelationController.php | 151 ++++++------- .../backend/behaviors/ReorderController.php | 27 +-- .../behaviors/UserPreferencesModel.php | 6 +- .../TranscodeFilter.php | 4 +- .../partials/_export_columns.php | 4 +- .../partials/_manage_pivot.php | 2 +- .../partials/_pivot_form.php | 4 +- modules/backend/classes/AuthManager.php | 9 +- modules/backend/classes/BackendController.php | 34 +-- modules/backend/classes/Controller.php | 60 ++---- .../backend/classes/ControllerBehavior.php | 4 +- modules/backend/classes/FilterScope.php | 8 +- modules/backend/classes/FormField.php | 35 ++-- modules/backend/classes/FormTabs.php | 4 +- modules/backend/classes/FormWidgetBase.php | 5 +- modules/backend/classes/ListColumn.php | 11 +- modules/backend/classes/MainMenuItem.php | 4 +- modules/backend/classes/NavigationManager.php | 4 +- modules/backend/classes/QuickActionItem.php | 4 +- modules/backend/classes/ReportWidgetBase.php | 4 +- modules/backend/classes/SideMenuItem.php | 4 +- modules/backend/classes/Skin.php | 6 +- modules/backend/classes/WidgetBase.php | 6 +- modules/backend/classes/WidgetManager.php | 4 +- modules/backend/console/CreateController.php | 4 +- modules/backend/console/CreateFormWidget.php | 4 +- .../backend/console/CreateReportWidget.php | 4 +- modules/backend/console/WinterPasswd.php | 4 +- modules/backend/controllers/AccessLogs.php | 4 +- modules/backend/controllers/Auth.php | 4 +- modules/backend/controllers/Files.php | 10 +- modules/backend/controllers/Index.php | 4 +- modules/backend/controllers/Media.php | 4 +- modules/backend/controllers/Preferences.php | 4 +- modules/backend/controllers/UserGroups.php | 4 +- modules/backend/controllers/UserRoles.php | 4 +- modules/backend/controllers/Users.php | 4 +- modules/backend/controllers/index/index.php | 2 +- modules/backend/controllers/media/index.php | 2 +- .../backend/controllers/preferences/index.php | 2 +- .../backend/controllers/usergroups/create.php | 2 +- .../backend/controllers/usergroups/update.php | 2 +- .../backend/controllers/userroles/create.php | 2 +- .../backend/controllers/userroles/update.php | 2 +- modules/backend/controllers/users/create.php | 2 +- .../backend/controllers/users/myaccount.php | 2 +- modules/backend/controllers/users/update.php | 2 +- ...017_10_01_000010_Db_Backend_User_Roles.php | 9 +- .../backend/database/seeds/DatabaseSeeder.php | 6 +- .../backend/database/seeds/SeedSetupAdmin.php | 4 +- modules/backend/facades/Backend.php | 4 +- modules/backend/facades/BackendAuth.php | 4 +- modules/backend/facades/BackendMenu.php | 4 +- modules/backend/formwidgets/CodeEditor.php | 4 +- modules/backend/formwidgets/ColorPicker.php | 4 +- modules/backend/formwidgets/DataTable.php | 4 +- modules/backend/formwidgets/DatePicker.php | 10 +- modules/backend/formwidgets/FileUpload.php | 21 +- modules/backend/formwidgets/IconPicker.php | 4 +- .../backend/formwidgets/MarkdownEditor.php | 4 +- modules/backend/formwidgets/MediaFinder.php | 7 +- modules/backend/formwidgets/NestedForm.php | 4 +- .../backend/formwidgets/PermissionEditor.php | 13 +- modules/backend/formwidgets/RecordFinder.php | 16 +- modules/backend/formwidgets/Relation.php | 3 +- modules/backend/formwidgets/Repeater.php | 14 +- modules/backend/formwidgets/RichEditor.php | 8 +- modules/backend/formwidgets/Sensitive.php | 4 +- modules/backend/formwidgets/TagList.php | 2 +- .../codeeditor/partials/_codeeditor.php | 2 +- .../relation/partials/_relation.php | 2 +- .../repeater/partials/_repeater.php | 8 +- .../repeater/partials/_repeater_item.php | 2 +- .../richeditor/partials/_richeditor.php | 2 +- modules/backend/helpers/Backend.php | 18 +- .../helpers/exception/DecompileException.php | 4 +- modules/backend/lang/be/lang.php | 10 +- modules/backend/lang/ca/lang.php | 10 +- modules/backend/lang/cs/lang.php | 10 +- modules/backend/lang/da/lang.php | 10 +- modules/backend/lang/el/lang.php | 11 +- modules/backend/lang/et/lang.php | 10 +- modules/backend/lang/fa/lang.php | 11 +- modules/backend/lang/fi/lang.php | 10 +- modules/backend/lang/fr/lang.php | 10 +- modules/backend/lang/hu/lang.php | 10 +- modules/backend/lang/it/lang.php | 10 +- modules/backend/lang/ja/lang.php | 2 +- modules/backend/lang/kr/lang.php | 10 +- modules/backend/lang/lt/lang.php | 10 +- modules/backend/lang/lv/lang.php | 6 +- modules/backend/lang/nb-no/lang.php | 10 +- modules/backend/lang/pl/lang.php | 4 +- modules/backend/lang/pt-br/lang.php | 10 +- modules/backend/lang/pt-pt/lang.php | 10 +- modules/backend/lang/sk/lang.php | 10 +- modules/backend/lang/tr/lang.php | 10 +- modules/backend/lang/vn/lang.php | 10 +- modules/backend/lang/zh-cn/lang.php | 10 +- modules/backend/layouts/_custom_styles.php | 2 + modules/backend/layouts/_head.php | 2 +- modules/backend/layouts/_hint.php | 2 +- modules/backend/layouts/_sidenav.php | 2 +- modules/backend/layouts/auth.php | 2 +- modules/backend/models/AccessLog.php | 6 +- modules/backend/models/BrandSetting.php | 9 +- modules/backend/models/EditorSetting.php | 11 +- modules/backend/models/ExportModel.php | 10 +- modules/backend/models/ImportModel.php | 10 +- modules/backend/models/Preference.php | 10 +- modules/backend/models/User.php | 11 +- modules/backend/models/UserGroup.php | 4 +- modules/backend/models/UserPreference.php | 4 +- modules/backend/models/UserRole.php | 10 +- modules/backend/models/UserThrottle.php | 4 +- modules/backend/reportwidgets/Welcome.php | 7 +- .../welcome/partials/_widget.php | 4 +- modules/backend/skins/Standard.php | 7 +- .../tests/formwidgets/CheckboxTest.php | 4 +- .../tests/helpers/BackendHelperTest.php | 4 +- .../backend/tests/models/ExportModelTest.php | 5 +- .../backend/tests/models/ImportModelTest.php | 9 +- .../backend/tests/traits/WidgetMakerTest.php | 6 +- .../tests/widgets/FilterWidgetTest.php | 18 +- modules/backend/tests/widgets/FormTest.php | 22 +- modules/backend/tests/widgets/ListsTest.php | 18 +- modules/backend/traits/CollapsableWidget.php | 12 +- modules/backend/traits/ErrorMaker.php | 4 +- modules/backend/traits/FormModelSaver.php | 10 +- modules/backend/traits/FormModelWidget.php | 7 +- .../backend/traits/InspectableContainer.php | 9 +- modules/backend/traits/PreferenceMaker.php | 4 +- modules/backend/traits/SearchableWidget.php | 4 +- modules/backend/traits/SelectableWidget.php | 4 +- modules/backend/traits/SessionMaker.php | 4 +- modules/backend/traits/UploadableWidget.php | 12 +- modules/backend/traits/WidgetMaker.php | 7 +- modules/backend/widgets/Filter.php | 94 ++------- modules/backend/widgets/Form.php | 57 ++--- modules/backend/widgets/Lists.php | 152 +++++--------- modules/backend/widgets/MediaManager.php | 43 ++-- modules/backend/widgets/ReportContainer.php | 24 +-- modules/backend/widgets/Search.php | 4 +- modules/backend/widgets/Table.php | 4 +- modules/backend/widgets/Toolbar.php | 7 +- .../widgets/filter/partials/_scope_text.php | 2 +- .../form/partials/_field-container.php | 2 +- .../form/partials/_field_checkboxlist.php | 4 +- .../widgets/form/partials/_field_dropdown.php | 2 +- .../form/partials/_section-container.php | 2 +- .../widgets/form/partials/_section.php | 4 +- .../widgets/lists/partials/_list_body_row.php | 4 +- .../widgets/lists/partials/_list_head_row.php | 2 +- .../lists/partials/_list_pagination.php | 4 +- .../partials/_list_pagination_simple.php | 4 +- .../widgets/lists/partials/_setup_form.php | 4 +- .../mediamanager/partials/_generic-list.php | 2 +- .../partials/_image-crop-popup-body.php | 2 +- .../mediamanager/partials/_popup-body.php | 2 +- .../mediamanager/partials/_rename-form.php | 2 +- .../reportcontainer/partials/_widget.php | 2 +- .../widgets/table/ClientMemoryDataSource.php | 4 +- .../backend/widgets/table/DataSourceBase.php | 4 +- .../widgets/table/ServerEventDataSource.php | 4 +- modules/cms/ServiceProvider.php | 10 +- modules/cms/classes/Asset.php | 14 +- modules/cms/classes/AutoDatasource.php | 7 +- modules/cms/classes/CmsCompoundObject.php | 14 +- modules/cms/classes/CmsController.php | 4 +- modules/cms/classes/CmsException.php | 7 +- modules/cms/classes/CmsObject.php | 27 +-- modules/cms/classes/CmsObjectCollection.php | 4 +- modules/cms/classes/CodeBase.php | 4 +- modules/cms/classes/CodeParser.php | 35 ++-- modules/cms/classes/ComponentBase.php | 9 +- modules/cms/classes/ComponentHelpers.php | 7 +- modules/cms/classes/ComponentManager.php | 4 +- modules/cms/classes/ComponentPartial.php | 14 +- modules/cms/classes/Content.php | 4 +- modules/cms/classes/Controller.php | 137 +++++------- modules/cms/classes/Layout.php | 4 +- modules/cms/classes/LayoutCode.php | 4 +- modules/cms/classes/MediaLibrary.php | 4 +- modules/cms/classes/MediaLibraryItem.php | 4 +- modules/cms/classes/MediaViewHelper.php | 8 +- modules/cms/classes/Meta.php | 4 +- modules/cms/classes/ObjectMemoryCache.php | 4 +- modules/cms/classes/Page.php | 8 +- modules/cms/classes/PageCode.php | 4 +- modules/cms/classes/Partial.php | 4 +- modules/cms/classes/PartialCode.php | 4 +- modules/cms/classes/PartialStack.php | 4 +- modules/cms/classes/Router.php | 12 +- modules/cms/classes/Theme.php | 15 +- modules/cms/classes/ThemeManager.php | 4 +- modules/cms/components/Resources.php | 22 +- modules/cms/components/SoftComponent.php | 4 +- modules/cms/components/UnknownComponent.php | 4 +- modules/cms/components/ViewBag.php | 4 +- modules/cms/console/CreateComponent.php | 4 +- modules/cms/console/CreateTheme.php | 4 +- modules/cms/console/ThemeInstall.php | 8 +- modules/cms/console/ThemeList.php | 8 +- modules/cms/console/ThemeRemove.php | 4 +- modules/cms/console/ThemeSync.php | 11 +- modules/cms/console/ThemeUse.php | 4 +- modules/cms/contracts/CmsObject.php | 4 +- modules/cms/controllers/Index.php | 24 +-- modules/cms/controllers/Media.php | 4 +- modules/cms/controllers/ThemeLogs.php | 7 +- modules/cms/controllers/ThemeOptions.php | 9 +- modules/cms/controllers/Themes.php | 41 ++-- .../index/_concurrency_resolve_form.php | 2 +- modules/cms/controllers/media/index.php | 2 +- .../controllers/themelogs/_field_content.php | 2 +- .../cms/controllers/themeoptions/update.php | 2 +- .../controllers/themes/_theme_list_item.php | 4 +- modules/cms/controllers/themes/index.php | 2 +- modules/cms/facades/Cms.php | 4 +- modules/cms/formwidgets/Components.php | 7 +- modules/cms/formwidgets/MediaFinder.php | 4 +- .../components/partials/_component.php | 2 +- modules/cms/helpers/Cms.php | 4 +- modules/cms/helpers/File.php | 4 +- modules/cms/lang/bg/lang.php | 3 +- modules/cms/lang/cs/lang.php | 4 +- modules/cms/lang/da/lang.php | 4 +- modules/cms/lang/el/lang.php | 5 +- modules/cms/lang/es-ar/lang.php | 4 +- modules/cms/lang/fa/lang.php | 5 +- modules/cms/lang/fr/lang.php | 4 +- modules/cms/lang/id/lang.php | 4 +- modules/cms/lang/it/lang.php | 4 +- modules/cms/lang/ja/lang.php | 4 +- modules/cms/lang/kr/lang.php | 4 +- modules/cms/lang/pl/lang.php | 2 +- modules/cms/lang/pt-br/lang.php | 4 +- modules/cms/lang/pt-pt/lang.php | 4 +- modules/cms/lang/sk/lang.php | 1 + modules/cms/lang/sv/lang.php | 4 +- modules/cms/lang/tr/lang.php | 4 +- modules/cms/lang/zh-cn/lang.php | 4 +- modules/cms/lang/zh-tw/lang.php | 4 +- modules/cms/models/MaintenanceSetting.php | 7 +- modules/cms/models/ThemeData.php | 10 +- modules/cms/models/ThemeExport.php | 21 +- modules/cms/models/ThemeImport.php | 24 +-- modules/cms/models/ThemeLog.php | 10 +- modules/cms/reportwidgets/ActiveTheme.php | 9 +- .../activetheme/partials/_widget.php | 2 +- .../tests/classes/CmsCompoundObjectTest.php | 2 +- modules/cms/tests/classes/ContentTest.php | 1 - modules/cms/tests/classes/PageTest.php | 2 +- .../cms/tests/classes/PartialStackTest.php | 5 +- .../cms/tests/classes/TwigExtensionTest.php | 9 +- modules/cms/traits/UrlMaker.php | 8 +- modules/cms/twig/ComponentNode.php | 6 +- modules/cms/twig/ComponentTokenParser.php | 4 +- modules/cms/twig/ContentNode.php | 6 +- modules/cms/twig/ContentTokenParser.php | 4 +- modules/cms/twig/DebugExtension.php | 74 +++---- modules/cms/twig/DefaultNode.php | 4 +- modules/cms/twig/DefaultTokenParser.php | 4 +- modules/cms/twig/Extension.php | 28 +-- modules/cms/twig/FlashNode.php | 19 +- modules/cms/twig/FlashTokenParser.php | 7 +- modules/cms/twig/FrameworkNode.php | 9 +- modules/cms/twig/FrameworkTokenParser.php | 4 +- modules/cms/twig/Loader.php | 4 +- modules/cms/twig/PageNode.php | 4 +- modules/cms/twig/PageTokenParser.php | 4 +- modules/cms/twig/PartialNode.php | 6 +- modules/cms/twig/PartialTokenParser.php | 4 +- modules/cms/twig/PlaceholderNode.php | 22 +- modules/cms/twig/PlaceholderTokenParser.php | 7 +- modules/cms/twig/PutNode.php | 6 +- modules/cms/twig/PutTokenParser.php | 4 +- modules/cms/twig/ScriptsNode.php | 4 +- modules/cms/twig/ScriptsTokenParser.php | 4 +- modules/cms/twig/SnowboardNode.php | 6 +- modules/cms/twig/SnowboardTokenParser.php | 4 +- modules/cms/twig/StylesNode.php | 4 +- modules/cms/twig/StylesTokenParser.php | 4 +- modules/cms/widgets/AssetList.php | 51 +++-- modules/cms/widgets/ComponentList.php | 4 +- modules/cms/widgets/MediaManager.php | 4 +- modules/cms/widgets/TemplateList.php | 28 +-- .../cms/widgets/assetlist/partials/_body.php | 2 +- .../cms/widgets/assetlist/partials/_files.php | 2 +- .../cms/widgets/assetlist/partials/_items.php | 4 +- .../widgets/assetlist/partials/_move_form.php | 8 +- .../assetlist/partials/_new_dir_form.php | 8 +- .../widgets/assetlist/partials/_toolbar.php | 4 +- .../widgets/componentlist/partials/_body.php | 2 +- .../partials/_component_list.php | 2 +- .../componentlist/partials/_components.php | 2 +- .../widgets/componentlist/partials/_items.php | 2 +- .../widgets/templatelist/partials/_items.php | 4 +- .../templatelist/partials/_toolbar.php | 4 +- modules/system/ServiceProvider.php | 15 +- modules/system/assets/js/lang/lang.tr.js | 2 +- modules/system/behaviors/SettingsModel.php | 6 +- modules/system/classes/CombineAssets.php | 59 +++--- modules/system/classes/ComposerManager.php | 8 +- modules/system/classes/ErrorHandler.php | 6 +- modules/system/classes/FileManifest.php | 6 +- modules/system/classes/ImageResizer.php | 4 +- modules/system/classes/MailManager.php | 16 +- modules/system/classes/MarkupManager.php | 14 +- modules/system/classes/MediaLibrary.php | 34 ++- modules/system/classes/MediaLibraryItem.php | 4 +- modules/system/classes/ModelBehavior.php | 4 +- modules/system/classes/PluginBase.php | 17 +- modules/system/classes/PluginManager.php | 4 +- modules/system/classes/SettingsManager.php | 9 +- modules/system/classes/SourceManifest.php | 4 +- modules/system/classes/SystemController.php | 8 +- modules/system/classes/UpdateManager.php | 12 +- modules/system/classes/VersionManager.php | 19 +- .../system/classes/VersionYamlProcessor.php | 4 +- .../system/console/BaseScaffoldCommand.php | 4 +- modules/system/console/CreateCommand.php | 4 +- modules/system/console/CreateJob.php | 4 +- modules/system/console/CreateMigration.php | 11 +- modules/system/console/CreateModel.php | 4 +- modules/system/console/CreatePlugin.php | 4 +- modules/system/console/CreateSettings.php | 4 +- modules/system/console/PluginDisable.php | 4 +- modules/system/console/PluginEnable.php | 4 +- modules/system/console/PluginInstall.php | 4 +- modules/system/console/PluginList.php | 8 +- modules/system/console/PluginRefresh.php | 14 +- modules/system/console/PluginRemove.php | 14 +- modules/system/console/PluginRollback.php | 14 +- modules/system/console/WinterDown.php | 14 +- modules/system/console/WinterEnv.php | 4 +- modules/system/console/WinterFresh.php | 8 +- modules/system/console/WinterInstall.php | 34 ++- modules/system/console/WinterManifest.php | 6 +- modules/system/console/WinterMirror.php | 16 +- modules/system/console/WinterTest.php | 4 +- modules/system/console/WinterUp.php | 4 +- modules/system/console/WinterUpdate.php | 4 +- modules/system/console/WinterUtil.php | 37 ++-- modules/system/console/WinterVersion.php | 6 +- .../system/console/asset/mix/MixCreate.php | 4 +- .../system/console/asset/mix/MixInstall.php | 4 +- .../console/traits/HasPluginArgument.php | 4 +- modules/system/controllers/EventLogs.php | 7 +- .../system/controllers/MailBrandSettings.php | 8 +- modules/system/controllers/MailLayouts.php | 4 +- modules/system/controllers/MailPartials.php | 4 +- modules/system/controllers/MailTemplates.php | 7 +- modules/system/controllers/RequestLogs.php | 7 +- modules/system/controllers/Settings.php | 11 +- modules/system/controllers/Updates.php | 51 ++--- .../controllers/mailbrandsettings/index.php | 2 +- .../system/controllers/maillayouts/create.php | 2 +- .../system/controllers/maillayouts/update.php | 2 +- .../controllers/mailpartials/create.php | 2 +- .../controllers/mailpartials/update.php | 2 +- .../controllers/mailtemplates/create.php | 2 +- .../controllers/mailtemplates/update.php | 2 +- .../controllers/updates/_column_code.php | 3 +- .../controllers/updates/_update_list.php | 4 +- .../system/controllers/updates/details.php | 10 +- ...01_000014_Db_System_Mail_Layout_Rename.php | 3 +- .../system/database/seeds/DatabaseSeeder.php | 5 +- .../database/seeds/SeedSetupMailLayouts.php | 4 +- modules/system/helpers/Cache.php | 14 +- modules/system/helpers/DateTime.php | 24 +-- modules/system/helpers/View.php | 4 +- modules/system/lang/bg/client.php | 1 + modules/system/lang/bg/lang.php | 1 + modules/system/lang/bg/validation.php | 1 + modules/system/lang/el/client.php | 1 + modules/system/lang/el/lang.php | 1 + modules/system/lang/el/validation.php | 3 +- modules/system/lang/ru/lang.php | 198 +++++++++--------- modules/system/lang/sk/client.php | 1 + modules/system/lang/sk/lang.php | 1 + modules/system/lang/sk/validation.php | 1 + modules/system/lang/zh-cn/lang.php | 2 +- modules/system/models/EventLog.php | 9 +- modules/system/models/File.php | 7 +- modules/system/models/LogSetting.php | 4 +- modules/system/models/MailBrandSetting.php | 9 +- modules/system/models/MailLayout.php | 10 +- modules/system/models/MailPartial.php | 13 +- modules/system/models/MailSetting.php | 7 +- modules/system/models/MailTemplate.php | 6 +- modules/system/models/Parameter.php | 8 +- modules/system/models/PluginVersion.php | 13 +- modules/system/models/RequestLog.php | 7 +- modules/system/models/Revision.php | 4 +- .../models/mailsetting/_drivers_hint.php | 2 +- modules/system/partials/_settings_menu.php | 1 + modules/system/reportwidgets/Status.php | 11 +- .../tests/bootstrap/PluginManagerTestCase.php | 7 +- .../system/tests/bootstrap/PluginTestCase.php | 2 +- modules/system/tests/bootstrap/app.php | 2 +- .../tests/classes/CombineAssetsTest.php | 4 +- modules/system/tests/classes/CoreLangTest.php | 2 +- .../system/tests/classes/FileManifestTest.php | 1 - .../tests/classes/MarkupManagerTest.php | 3 +- .../tests/classes/VersionManagerTest.php | 3 +- .../tests/console/CreateMigrationTest.php | 42 ++-- .../system/tests/console/WinterEnvTest.php | 4 +- modules/system/tests/fixtures/config/app.php | 1 + .../system/tests/fixtures/config/cache.php | 1 + modules/system/tests/fixtures/config/cms.php | 1 + .../system/tests/fixtures/config/database.php | 1 + modules/system/tests/fixtures/config/mail.php | 1 + .../system/tests/fixtures/config/queue.php | 1 + .../system/tests/fixtures/config/session.php | 1 + .../plugins/database/tester/Plugin.php | 4 +- .../plugins/database/tester/models/Author.php | 5 +- .../database/tester/models/Category.php | 6 +- .../database/tester/models/Country.php | 5 +- .../database/tester/models/EventLog.php | 4 +- .../plugins/database/tester/models/Meta.php | 4 +- .../plugins/database/tester/models/Phone.php | 5 +- .../plugins/database/tester/models/Post.php | 4 +- .../plugins/database/tester/models/Role.php | 4 +- .../plugins/database/tester/models/Tag.php | 4 +- .../plugins/database/tester/models/User.php | 4 +- .../tester/updates/create_authors_table.php | 4 +- .../updates/create_categories_table.php | 5 +- .../tester/updates/create_countries_table.php | 4 +- .../tester/updates/create_event_log_table.php | 5 +- .../tester/updates/create_meta_table.php | 5 +- .../tester/updates/create_phones_table.php | 5 +- .../tester/updates/create_posts_table.php | 5 +- .../tester/updates/create_roles_table.php | 5 +- .../tester/updates/create_tags_table.php | 5 +- .../tester/updates/create_users_table.php | 5 +- .../plugins/dependencytest/acme/Plugin.php | 4 +- .../dependencytest/dependency/Plugin.php | 4 +- .../plugins/dependencytest/found/Plugin.php | 4 +- .../dependencytest/notfound/Plugin.php | 4 +- .../dependencytest/wrongcase/Plugin.php | 4 +- .../fixtures/plugins/mix/testa/Plugin.php | 4 +- .../fixtures/plugins/mix/testb/Plugin.php | 4 +- .../fixtures/plugins/mix/testc/Plugin.php | 4 +- .../plugins/testvendor/test/Plugin.php | 4 +- .../testvendor/test/formwidgets/Sample.php | 4 +- .../winter/invalidreplacement/Plugin.php | 4 +- .../plugins/winter/noupdates/Plugin.php | 4 +- .../plugins/winter/original/Plugin.php | 4 +- .../plugins/winter/replacement/Plugin.php | 4 +- .../fixtures/plugins/winter/sample/Plugin.php | 4 +- .../fixtures/plugins/winter/tester/Plugin.php | 4 +- .../plugins/winter/tester/classes/Users.php | 4 +- .../winter/tester/components/Archive.php | 4 +- .../winter/tester/components/Categories.php | 4 +- .../winter/tester/components/Comments.php | 4 +- .../winter/tester/components/ContentBlock.php | 6 +- .../winter/tester/components/MainMenu.php | 4 +- .../plugins/winter/tester/components/Post.php | 4 +- .../winter/tester/formwidgets/Preview.php | 4 +- .../winter/tester/models/TestModel.php | 4 +- .../winter/tester/rules/BeLikeBobRule.php | 4 +- .../plugins/database/AttachManyModelTest.php | 2 +- .../plugins/database/AttachOneModelTest.php | 2 +- .../database/BelongsToManyModelTest.php | 2 +- .../plugins/database/BelongsToModelTest.php | 2 +- .../plugins/database/DeferredBindingTest.php | 2 +- .../plugins/database/HasManyModelTest.php | 2 +- .../database/HasManyThroughModelTest.php | 2 +- .../plugins/database/HasOneModelTest.php | 2 +- .../database/HasOneThroughModelTest.php | 2 +- .../plugins/database/MorphManyModelTest.php | 2 +- .../plugins/database/MorphOneModelTest.php | 2 +- .../plugins/database/MorphToModelTest.php | 2 +- .../plugins/database/NestedTreeModelTest.php | 2 +- .../plugins/database/NullableModelTest.php | 2 +- .../plugins/database/PluginModelTest.php | 4 +- .../database/RevisionableModelTest.php | 6 +- .../plugins/database/SimpleTreeModelTest.php | 2 +- .../plugins/database/SluggableModelTest.php | 8 +- .../plugins/database/SoftDeleteModelTest.php | 2 +- .../plugins/database/ValidationModelTest.php | 2 +- .../system/CustomValidatorRulesTest.php | 2 +- .../system/tests/traits/AssetMakerTest.php | 16 +- modules/system/tests/traits/ViewMakerTest.php | 2 +- modules/system/traits/ConfigMaker.php | 31 ++- modules/system/traits/EventEmitter.php | 6 +- modules/system/traits/LazyOwnerAlias.php | 4 +- modules/system/traits/PropertyContainer.php | 4 +- modules/system/traits/ResponseMaker.php | 8 +- modules/system/traits/SecurityController.php | 4 +- modules/system/traits/ViewMaker.php | 10 +- modules/system/twig/Engine.php | 4 +- modules/system/twig/Extension.php | 8 +- modules/system/twig/FilterTokenParser.php | 4 +- modules/system/twig/Loader.php | 7 +- modules/system/twig/MailPartialNode.php | 6 +- .../system/twig/MailPartialTokenParser.php | 4 +- modules/system/twig/SecurityPolicy.php | 4 +- modules/system/twig/SpacelessNode.php | 4 +- modules/system/twig/SpacelessTokenParser.php | 4 +- phpcs.xml | 16 +- plugins/winter/demo/Plugin.php | 5 +- plugins/winter/demo/components/Todo.php | 5 +- 511 files changed, 2334 insertions(+), 2027 deletions(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index 10e92d3cd6..3cb4279a7f 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -12,7 +12,7 @@ */ $app = new Winter\Storm\Foundation\Application( - realpath(__DIR__.'/../') + realpath(__DIR__ . '/../') ); /* diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php index 0b57e5e2f2..9e56cab1b6 100644 --- a/bootstrap/autoload.php +++ b/bootstrap/autoload.php @@ -13,10 +13,10 @@ | */ -$helperPath = __DIR__.'/../vendor/winter/storm/src/Support/helpers.php'; +$helperPath = __DIR__ . '/../vendor/winter/storm/src/Support/helpers.php'; if (!file_exists($helperPath)) { - echo 'Missing vendor files, try running "composer install" or use the Wizard installer.'.PHP_EOL; + echo 'Missing vendor files, try running "composer install" or use the Wizard installer.' . PHP_EOL; exit(1); } @@ -34,4 +34,4 @@ | */ -require __DIR__.'/../vendor/autoload.php'; +require __DIR__ . '/../vendor/autoload.php'; diff --git a/config/app.php b/config/app.php index b740d465ed..c860102a24 100644 --- a/config/app.php +++ b/config/app.php @@ -63,7 +63,7 @@ */ 'asset_url' => env('ASSET_URL', null), - + /* |-------------------------------------------------------------------------- | Temporary Path diff --git a/modules/backend/ServiceProvider.php b/modules/backend/ServiceProvider.php index c81552de9d..3a70003324 100644 --- a/modules/backend/ServiceProvider.php +++ b/modules/backend/ServiceProvider.php @@ -1,4 +1,6 @@ -controller->formExtendModel($model) ?: $model; $this->initForm($model); - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->controller->handleError($ex); } } @@ -287,8 +288,7 @@ public function update($recordId = null, $context = null) $model = $this->controller->formFindModelObject($recordId); $this->initForm($model); - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->controller->handleError($ex); } } @@ -384,8 +384,7 @@ public function preview($recordId = null, $context = null) $model = $this->controller->formFindModelObject($recordId); $this->initForm($model); - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->controller->handleError($ex); } } @@ -451,7 +450,7 @@ public function formGetContext() protected function createModel() { $class = $this->config->modelClass; - return new $class; + return new $class(); } /** diff --git a/modules/backend/behaviors/ImportExportController.php b/modules/backend/behaviors/ImportExportController.php index 057a0758a3..91f61df522 100644 --- a/modules/backend/behaviors/ImportExportController.php +++ b/modules/backend/behaviors/ImportExportController.php @@ -1,4 +1,6 @@ -vars['importResults'] = $model->getResultStats(); $this->vars['returnUrl'] = $this->getRedirectUrlForType('import'); - } - catch (MassAssignmentException $ex) { + } catch (MassAssignmentException $ex) { $this->controller->handleError(new ApplicationException(Lang::get( 'backend::lang.model.mass_assignment_failed', ['attribute' => $ex->getMessage()] ))); - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->controller->handleError($ex); } @@ -228,8 +228,7 @@ public function onImportLoadForm() { try { $this->checkRequiredImportColumns(); - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->controller->handleError($ex); } @@ -329,7 +328,7 @@ protected function getImportFileColumns() if (!post('first_row_titles')) { array_walk($firstRow, function (&$value, $key) { - $value = 'Column #'.($key + 1); + $value = 'Column #' . ($key + 1); }); } @@ -447,19 +446,17 @@ public function onExport() $reference = $model->export($columns, $exportOptions); $fileUrl = $this->controller->actionUrl( 'download', - $reference.'/'.$this->exportFileName + $reference . '/' . $this->exportFileName ); $this->vars['fileUrl'] = $fileUrl; $this->vars['returnUrl'] = $this->getRedirectUrlForType('export'); - } - catch (MassAssignmentException $ex) { + } catch (MassAssignmentException $ex) { $this->controller->handleError(new ApplicationException(Lang::get( 'backend::lang.model.mass_assignment_failed', ['attribute' => $ex->getMessage()] ))); - } - catch (Exception $ex) { + } catch (Exception $ex) { $this->controller->handleError($ex); } @@ -583,8 +580,7 @@ protected function checkUseListExportMode() if (is_array($useList)) { $listDefinition = array_get($useList, 'definition'); - } - else { + } else { $listDefinition = $useList; } @@ -620,7 +616,7 @@ public function exportFromList($definition = null, $options = []) /* * Prepare CSV */ - $csv = CsvWriter::createFromFileObject(new SplTempFileObject); + $csv = CsvWriter::createFromFileObject(new SplTempFileObject()); $csv->setOutputBOM(CsvWriter::BOM_UTF8); $csv->setDelimiter($options['delimiter']); $csv->setEnclosure($options['enclosure']); @@ -687,7 +683,7 @@ public function exportFromList($definition = null, $options = []) */ public function importExportMakePartial($partial, $params = []) { - $contents = $this->controller->makePartial('import_export_'.$partial, $params + $this->vars, false); + $contents = $this->controller->makePartial('import_export_' . $partial, $params + $this->vars, false); if (!$contents) { $contents = $this->makePartial($partial, $params); @@ -704,7 +700,7 @@ public function importExportMakePartial($partial, $params = []) protected function checkPermissionsForType($type) { if ( - ($permissions = $this->getConfig($type.'[permissions]')) && + ($permissions = $this->getConfig($type . '[permissions]')) && (!BackendAuth::getUser()->hasAnyAccess((array) $permissions)) ) { return Response::make(View::make('backend::access_denied'), 403); @@ -717,11 +713,11 @@ protected function makeOptionsFormWidgetForType($type) return null; } - if ($fieldConfig = $this->getConfig($type.'[form]')) { + if ($fieldConfig = $this->getConfig($type . '[form]')) { $widgetConfig = $this->makeConfig($fieldConfig); $widgetConfig->model = $this->getModelForType($type); - $widgetConfig->alias = $type.'OptionsForm'; - $widgetConfig->arrayName = ucfirst($type).'Options'; + $widgetConfig->alias = $type . 'OptionsForm'; + $widgetConfig->arrayName = ucfirst($type) . 'Options'; return $this->makeWidget('Backend\Widgets\Form', $widgetConfig); } @@ -731,20 +727,20 @@ protected function makeOptionsFormWidgetForType($type) protected function getModelForType($type) { - $cacheProperty = $type.'Model'; + $cacheProperty = $type . 'Model'; if ($this->{$cacheProperty} !== null) { return $this->{$cacheProperty}; } - $modelClass = $this->getConfig($type.'[modelClass]'); + $modelClass = $this->getConfig($type . '[modelClass]'); if (!$modelClass) { throw new ApplicationException(Lang::get('backend::lang.import_export.missing_model_class_error', [ 'type' => $type ])); } - return $this->{$cacheProperty} = new $modelClass; + return $this->{$cacheProperty} = new $modelClass(); } protected function makeListColumns($config) @@ -759,8 +755,7 @@ protected function makeListColumns($config) foreach ($config->columns as $attribute => $column) { if (is_array($column)) { $result[$attribute] = array_get($column, 'label', $attribute); - } - else { + } else { $result[$attribute] = $column ?: $attribute; } } @@ -770,7 +765,7 @@ protected function makeListColumns($config) protected function getRedirectUrlForType($type) { - $redirect = $this->getConfig($type.'[redirect]'); + $redirect = $this->getConfig($type . '[redirect]'); if ($redirect !== null) { return $redirect ? Backend::url($redirect) : 'javascript:;'; diff --git a/modules/backend/behaviors/ListController.php b/modules/backend/behaviors/ListController.php index 379cf99cc1..cc3fab6137 100644 --- a/modules/backend/behaviors/ListController.php +++ b/modules/backend/behaviors/ListController.php @@ -1,4 +1,6 @@ -listDefinitions = $config; $this->primaryDefinition = key($this->listDefinitions); - } - else { + } else { $this->listDefinitions = ['list' => $config]; $this->primaryDefinition = 'list'; } @@ -124,7 +125,7 @@ public function makeList($definition = null) * Create the model */ $class = $listConfig->modelClass; - $model = new $class; + $model = new $class(); $model = $this->controller->listExtendModel($model, $definition); /* @@ -327,7 +328,7 @@ public function index_onDelete() * Create the model */ $class = $listConfig->modelClass; - $model = new $class; + $model = new $class(); $model = $this->controller->listExtendModel($model, $definition); /* @@ -354,8 +355,7 @@ public function index_onDelete() ? $listConfig->deleteMessage : 'backend::lang.list.delete_selected_success' )); - } - else { + } else { Flash::error(Lang::get( (!empty($listConfig->noRecordsDeletedMessage)) ? $listConfig->noRecordsDeletedMessage @@ -409,7 +409,7 @@ public function listRender($definition = null) */ public function listMakePartial($partial, $params = []) { - $contents = $this->controller->makePartial('list_'.$partial, $params + $this->vars, false); + $contents = $this->controller->makePartial('list_' . $partial, $params + $this->vars, false); if (!$contents) { $contents = $this->makePartial($partial, $params); } diff --git a/modules/backend/behaviors/RelationController.php b/modules/backend/behaviors/RelationController.php index 3f8346df4e..a94cf17b6a 100644 --- a/modules/backend/behaviors/RelationController.php +++ b/modules/backend/behaviors/RelationController.php @@ -1,4 +1,6 @@ -validateField($field); - $result = ['#'.$this->relationGetId('view') => $this->relationRenderView($field)]; + $result = ['#' . $this->relationGetId('view') => $this->relationRenderView($field)]; if ($toolbar = $this->relationRenderToolbar($field)) { - $result['#'.$this->relationGetId('toolbar')] = $toolbar; + $result['#' . $this->relationGetId('toolbar')] = $toolbar; } if ($eventResult = $this->controller->relationExtendRefreshResults($field)) { @@ -515,7 +517,7 @@ public function relationRenderView($field = null) */ public function relationMakePartial($partial, $params = []) { - $contents = $this->controller->makePartial('relation_'.$partial, $params + $this->vars, false); + $contents = $this->controller->makePartial('relation_' . $partial, $params + $this->vars, false); if (!$contents) { $contents = $this->makePartial($partial, $params); } @@ -658,10 +660,10 @@ protected function makeViewWidget() { $widget = null; - /* - * Multiple (has many, belongs to many) - */ if ($this->viewMode === 'multi') { + /* + * Multiple (has many, belongs to many) + */ $config = $this->makeConfigForMode('view', 'list'); $config->model = $this->relationModel; $config->alias = $this->alias . 'ViewList'; @@ -684,8 +686,7 @@ protected function makeViewWidget() if ($config->recordUrl) { $defaultOnClick = null; - } - elseif ( + } elseif ( !$this->makeConfigForMode('manage', 'form', false) && !$this->makeConfigForMode('pivot', 'form', false) ) { @@ -707,13 +708,11 @@ protected function makeViewWidget() $widget->bindEvent('list.extendQueryBefore', function ($query) use ($sqlConditions) { $query->whereRaw($sqlConditions); }); - } - elseif ($scopeMethod = $this->getConfig('view[scope]')) { + } elseif ($scopeMethod = $this->getConfig('view[scope]')) { $widget->bindEvent('list.extendQueryBefore', function ($query) use ($scopeMethod) { $query->$scopeMethod($this->model); }); - } - else { + } else { $widget->bindEvent('list.extendQueryBefore', function ($query) use ($widget) { $this->relationObject->addDefinedConstraintsToQuery($query); if ($widget->getSortColumn()) { @@ -732,15 +731,15 @@ protected function makeViewWidget() if ($sessionKey) { $this->relationObject->withDeferred($sessionKey); - } - elseif ($this->model->exists) { + } elseif ($this->model->exists) { $this->relationObject->addConstraints(); } /* * Allows pivot data to enter the fray */ - if ($this->relationType === 'belongsToMany' + if ( + $this->relationType === 'belongsToMany' || $this->relationType === 'morphToMany' || $this->relationType === 'morphedByMany' ) { @@ -752,7 +751,8 @@ protected function makeViewWidget() /* * Constrain the list by the search widget, if available */ - if ($this->toolbarWidget && $this->getConfig('view[showSearch]') + if ( + $this->toolbarWidget && $this->getConfig('view[showSearch]') && $searchWidget = $this->toolbarWidget->getSearchWidget() ) { $searchWidget->bindEvent('search.submit', function () use ($widget, $searchWidget) { @@ -765,8 +765,7 @@ protected function makeViewWidget() */ if (Request::ajax()) { $widget->setSearchTerm($searchWidget->getActiveTerm()); - } - else { + } else { $searchWidget->setActiveTerm(null); } } @@ -782,11 +781,10 @@ protected function makeViewWidget() // Apply predefined filter values $widget->addFilter([$this->viewFilterWidget, 'applyAllScopesToQuery']); } - } - /* - * Single (belongs to, has one) - */ - elseif ($this->viewMode === 'single') { + } elseif ($this->viewMode === 'single') { + /* + * Single (belongs to, has one) + */ $this->viewModel = $this->relationObject->getResults() ?: $this->relationModel; @@ -807,9 +805,6 @@ protected function makeManageWidget() { $widget = null; - /* - * List / Pivot - */ if ($this->manageMode === 'list' || $this->manageMode === 'pivot') { $isPivot = $this->manageMode === 'pivot'; @@ -832,11 +827,9 @@ protected function makeManageWidget() $this->relationGetId(), $this->relationGetSessionKey() ); - } - elseif ($config->showCheckboxes) { + } elseif ($config->showCheckboxes) { $config->recordOnClick = "$.wn.relationBehavior.toggleListCheckbox(this)"; - } - elseif ($isPivot) { + } elseif ($isPivot) { $config->recordOnClick = sprintf( "$.wn.relationBehavior.clickManagePivotListRecord(':%s', '%s', '%s')", $this->relationModel->getKeyName(), @@ -854,13 +847,11 @@ protected function makeManageWidget() $widget->bindEvent('list.extendQueryBefore', function ($query) use ($sqlConditions) { $query->whereRaw($sqlConditions); }); - } - elseif ($scopeMethod = $this->getConfig('manage[scope]')) { + } elseif ($scopeMethod = $this->getConfig('manage[scope]')) { $widget->bindEvent('list.extendQueryBefore', function ($query) use ($scopeMethod) { $query->$scopeMethod($this->model); }); - } - else { + } else { $widget->bindEvent('list.extendQueryBefore', function ($query) use ($widget) { $this->relationObject->addDefinedConstraintsToQuery($query); if ($widget->getSortColumn()) { @@ -897,11 +888,7 @@ protected function makeManageWidget() // Apply predefined filter values $widget->addFilter([$this->manageFilterWidget, 'applyAllScopesToQuery']); } - } - /* - * Form - */ - elseif ($this->manageMode === 'form') { + } elseif ($this->manageMode === 'form') { if (!$config = $this->makeConfigForMode('manage', 'form', false)) { return null; } @@ -975,11 +962,10 @@ protected function makePivotWidget() 'id' => $this->manageId, ])); } - } - /* - * New record - */ - else { + } else { + /* + * New record + */ if ($this->foreignId) { $foreignModel = $this->relationModel ->whereIn($foreignKeyName, (array) $this->foreignId) @@ -1195,8 +1181,7 @@ public function onRelationManageUpdate() foreach ($modelsToSave as $modelToSave) { $modelToSave->save(null, $this->manageWidget->getSessionKey()); } - } - elseif ($this->viewMode === 'single') { + } elseif ($this->viewMode === 'single') { // Ensure that the view widget model is the same instance as the manage widget model // since they will technically be different object instances in this context as // $viewWidet->model is populated by $this->relationObject->getResults() and @@ -1217,10 +1202,10 @@ public function onRelationManageDelete() { $this->beforeAjax(); - /* - * Multiple (has many, belongs to many) - */ if ($this->viewMode === 'multi') { + /* + * Multiple (has many, belongs to many) + */ if (($checkedIds = post('checked')) && is_array($checkedIds)) { foreach ($checkedIds as $relationId) { if (!$obj = $this->relationModel->find($relationId)) { @@ -1230,11 +1215,10 @@ public function onRelationManageDelete() $obj->delete(); } } - } - /* - * Single (belongs to, has one) - */ - elseif ($this->viewMode === 'single') { + } elseif ($this->viewMode === 'single') { + /* + * Single (belongs to, has one) + */ $relatedModel = $this->viewModel; if ($relatedModel->exists) { $relatedModel->delete(); @@ -1260,10 +1244,10 @@ public function onRelationManageAdd() $recordId = post('record_id'); $sessionKey = $this->deferredBinding ? $this->relationGetSessionKey() : null; - /* - * Add - */ if ($this->viewMode === 'multi') { + /* + * Add + */ $checkedIds = $recordId ? [$recordId] : post('checked'); if (is_array($checkedIds)) { @@ -1279,11 +1263,10 @@ public function onRelationManageAdd() $this->relationObject->add($model, $sessionKey); } } - } - /* - * Link - */ - elseif ($this->viewMode === 'single') { + } elseif ($this->viewMode === 'single') { + /* + * Link + */ if ($recordId && ($model = $this->relationModel->find($recordId))) { if ($this->relationType === 'hasOne') { // Unassign previous relation if one is already assigned @@ -1324,10 +1307,10 @@ public function onRelationManageRemove() $sessionKey = $this->deferredBinding ? $this->relationGetSessionKey() : null; $relatedModel = $this->relationModel; - /* - * Remove - */ if ($this->viewMode === 'multi') { + /* + * Remove + */ $checkedIds = $recordId ? [$recordId] : post('checked'); if (is_array($checkedIds)) { @@ -1338,11 +1321,10 @@ public function onRelationManageRemove() $this->relationObject->remove($model, $sessionKey); } } - } - /* - * Unlink - */ - elseif ($this->viewMode === 'single') { + } elseif ($this->viewMode === 'single') { + /* + * Unlink + */ if ($this->relationType === 'belongsTo') { $this->relationObject->dissociate(); $this->relationObject->getParent()->save(); @@ -1352,12 +1334,10 @@ public function onRelationManageRemove() $this->model->refresh(); $this->initRelation($this->model); } - } - elseif ($this->relationType === 'hasOne' || $this->relationType === 'morphOne') { + } elseif ($this->relationType === 'hasOne' || $this->relationType === 'morphOne') { if ($obj = $relatedModel->find($recordId)) { $this->relationObject->remove($obj, $sessionKey); - } - elseif ($this->viewModel->exists) { + } elseif ($this->viewModel->exists) { $this->relationObject->remove($this->viewModel, $sessionKey); } } @@ -1419,7 +1399,7 @@ public function onRelationManagePivotCreate() } }); - return ['#'.$this->relationGetId('view') => $this->relationRenderView()]; + return ['#' . $this->relationGetId('view') => $this->relationRenderView()]; } public function onRelationManagePivotUpdate() @@ -1435,7 +1415,7 @@ public function onRelationManagePivotUpdate() $modelToSave->save(null, $this->pivotWidget->getSessionKey()); } - return ['#'.$this->relationGetId('view') => $this->relationRenderView()]; + return ['#' . $this->relationGetId('view') => $this->relationRenderView()]; } // @@ -1722,11 +1702,9 @@ protected function evalManageMode() case 'belongsToMany': if (isset($this->config->pivot)) { return 'pivot'; - } - elseif ($this->eventTarget === 'list') { + } elseif ($this->eventTarget === 'list') { return 'form'; - } - else { + } else { return 'list'; } @@ -1799,19 +1777,12 @@ protected function makeConfigForMode($mode = 'view', $type = 'list', $throwExcep { $config = null; - /* - * Look for $this->config->view['list'] - */ if ( isset($this->config->{$mode}) && array_key_exists($type, $this->config->{$mode}) ) { $config = $this->config->{$mode}[$type]; - } - /* - * Look for $this->config->list - */ - elseif (isset($this->config->{$type})) { + } elseif (isset($this->config->{$type})) { $config = $this->config->{$type}; } @@ -1826,7 +1797,7 @@ protected function makeConfigForMode($mode = 'view', $type = 'list', $throwExcep } if ($throwException) { - throw new ApplicationException('Missing configuration for '.$mode.'.'.$type.' in RelationController definition '.$this->field); + throw new ApplicationException('Missing configuration for ' . $mode . '.' . $type . ' in RelationController definition ' . $this->field); } return false; diff --git a/modules/backend/behaviors/ReorderController.php b/modules/backend/behaviors/ReorderController.php index 20cd3460ff..47adc7cf20 100644 --- a/modules/backend/behaviors/ReorderController.php +++ b/modules/backend/behaviors/ReorderController.php @@ -1,4 +1,6 @@ -validateModel(); - /* - * Simple - */ if ($this->sortMode == 'simple') { if ( (!$ids = post('record_ids')) || @@ -128,11 +127,7 @@ public function onReorder() } $model->setSortableOrder($ids, $orders); - } - /* - * Nested set - */ - elseif ($this->sortMode == 'nested') { + } elseif ($this->sortMode == 'nested') { $sourceNode = $model->find(post('sourceNode')); $targetNode = post('targetNode') ? $model->find(post('targetNode')) : null; @@ -193,7 +188,7 @@ public function reorderGetModel() throw new ApplicationException('Please specify the modelClass property for reordering'); } - return $this->model = new $modelClass; + return $this->model = new $modelClass(); } /** @@ -221,15 +216,13 @@ protected function validateModel() $model->isClassExtendedWith(\October\Rain\Database\Behaviors\Sortable::class) ) { $this->sortMode = 'simple'; - } - elseif ( + } elseif ( isset($modelTraits[\Winter\Storm\Database\Traits\NestedTree::class]) || isset($modelTraits[\October\Rain\Database\Traits\NestedTree::class]) ) { $this->sortMode = 'nested'; $this->showTree = true; - } - else { + } else { throw new ApplicationException('The model must implement the Sortable trait/behavior or the NestedTree trait.'); } @@ -253,8 +246,7 @@ protected function getRecords() ->orderBy($model->getSortOrderColumn()) ->get() ; - } - elseif ($this->sortMode == 'nested') { + } elseif ($this->sortMode == 'nested') { $records = $query->getNested(); } @@ -280,8 +272,7 @@ protected function makeToolbarWidget() if ($toolbarConfig = $this->getConfig('toolbar')) { $toolbarConfig = $this->makeConfig($toolbarConfig); $toolbarWidget = $this->makeWidget('Backend\Widgets\Toolbar', $toolbarConfig); - } - else { + } else { $toolbarWidget = null; } diff --git a/modules/backend/behaviors/UserPreferencesModel.php b/modules/backend/behaviors/UserPreferencesModel.php index 52e2cd7575..c3984eb56c 100644 --- a/modules/backend/behaviors/UserPreferencesModel.php +++ b/modules/backend/behaviors/UserPreferencesModel.php @@ -1,4 +1,6 @@ -userContext ? $item->userContext->id : 0; - return $this->recordCode.'-userpreference-'.$userId; + return $this->recordCode . '-userpreference-' . $userId; } } diff --git a/modules/backend/behaviors/importexportcontroller/TranscodeFilter.php b/modules/backend/behaviors/importexportcontroller/TranscodeFilter.php index bc683d600f..f32248befe 100644 --- a/modules/backend/behaviors/importexportcontroller/TranscodeFilter.php +++ b/modules/backend/behaviors/importexportcontroller/TranscodeFilter.php @@ -1,4 +1,6 @@ -" /> diff --git a/modules/backend/behaviors/relationcontroller/partials/_manage_pivot.php b/modules/backend/behaviors/relationcontroller/partials/_manage_pivot.php index 6ac2419bfc..c08647d911 100644 --- a/modules/backend/behaviors/relationcontroller/partials/_manage_pivot.php +++ b/modules/backend/behaviors/relationcontroller/partials/_manage_pivot.php @@ -2,7 +2,7 @@