summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-05-25 20:12:45 (GMT)
committer Alex Pott2013-05-25 20:12:45 (GMT)
commitf2d710c60793dc8833061b8b8648f202705b7c90 (patch)
treedcecbae78b9d0ccb3480370390fd972bdb9dc836
parent8cc75202e7e417f51199c1a903c42523a62a178e (diff)
Issue #1620010 by dawehner, ParisLiakos, plach, jibran: Move LANGUAGE constants to the Language class.
-rw-r--r--core/includes/bootstrap.inc117
-rw-r--r--core/includes/common.inc9
-rw-r--r--core/includes/entity.inc5
-rw-r--r--core/includes/form.inc3
-rw-r--r--core/includes/language.inc12
-rw-r--r--core/includes/menu.inc7
-rw-r--r--core/includes/standard.inc10
-rw-r--r--core/includes/theme.inc9
-rw-r--r--core/lib/Drupal/Core/Condition/ConditionManager.php3
-rw-r--r--core/lib/Drupal/Core/Datetime/DrupalDateTime.php3
-rw-r--r--core/lib/Drupal/Core/Entity/DatabaseStorageController.php3
-rw-r--r--core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php9
-rw-r--r--core/lib/Drupal/Core/Entity/Entity.php8
-rw-r--r--core/lib/Drupal/Core/Entity/EntityAccessController.php3
-rw-r--r--core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php5
-rw-r--r--core/lib/Drupal/Core/Entity/EntityBCDecorator.php38
-rw-r--r--core/lib/Drupal/Core/Entity/EntityFormController.php4
-rw-r--r--core/lib/Drupal/Core/Entity/EntityFormControllerNG.php2
-rw-r--r--core/lib/Drupal/Core/Entity/EntityManager.php3
-rw-r--r--core/lib/Drupal/Core/Entity/EntityNG.php57
-rw-r--r--core/lib/Drupal/Core/Entity/EntityRenderController.php4
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php5
-rw-r--r--core/lib/Drupal/Core/Language/Language.php86
-rw-r--r--core/lib/Drupal/Core/Language/LanguageManager.php6
-rw-r--r--core/lib/Drupal/Core/Path/AliasManager.php23
-rw-r--r--core/lib/Drupal/Core/Path/Path.php3
-rw-r--r--core/lib/Drupal/Core/TypedData/TranslatableInterface.php4
-rw-r--r--core/lib/Drupal/Core/Validation/ConstraintManager.php3
-rw-r--r--core/lib/Drupal/Core/Validation/DrupalTranslator.php3
-rw-r--r--core/modules/aggregator/aggregator.install5
-rw-r--r--core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php3
-rw-r--r--core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php3
-rw-r--r--core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php3
-rw-r--r--core/modules/block/block.install5
-rw-r--r--core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php3
-rw-r--r--core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php3
-rw-r--r--core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php4
-rw-r--r--core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php4
-rw-r--r--core/modules/block/lib/Drupal/block/BlockFormController.php3
-rw-r--r--core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php3
-rw-r--r--core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php1
-rw-r--r--core/modules/book/book.admin.inc3
-rw-r--r--core/modules/book/book.module5
-rw-r--r--core/modules/book/lib/Drupal/book/Tests/BookTest.php7
-rw-r--r--core/modules/ckeditor/ckeditor.admin.inc3
-rw-r--r--core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php3
-rw-r--r--core/modules/comment/lib/Drupal/comment/CommentFormController.php3
-rw-r--r--core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php7
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php4
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php6
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php4
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php3
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php6
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php6
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php6
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php3
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php4
-rw-r--r--core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php4
-rw-r--r--core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php1
-rw-r--r--core/modules/contact/contact.install3
-rw-r--r--core/modules/contact/lib/Drupal/contact/MessageFormController.php3
-rw-r--r--core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php11
-rw-r--r--core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php7
-rw-r--r--core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php7
-rw-r--r--core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php5
-rw-r--r--core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php3
-rw-r--r--core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php3
-rw-r--r--core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php7
-rw-r--r--core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php7
-rw-r--r--core/modules/field/field.default.inc8
-rw-r--r--core/modules/field/field.info.inc3
-rw-r--r--core/modules/field/field.module3
-rw-r--r--core/modules/field/field.multilingual.inc24
-rw-r--r--core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php13
-rw-r--r--core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php4
-rw-r--r--core/modules/field/lib/Drupal/field/Tests/CrudTest.php9
-rw-r--r--core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php18
-rw-r--r--core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php13
-rw-r--r--core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php18
-rw-r--r--core/modules/field/lib/Drupal/field/Tests/FormTest.php44
-rw-r--r--core/modules/field/lib/Drupal/field/Tests/TranslationTest.php6
-rw-r--r--core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php2
-rw-r--r--core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php13
-rw-r--r--core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php13
-rw-r--r--core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php19
-rw-r--r--core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php3
-rw-r--r--core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php6
-rw-r--r--core/modules/file/lib/Drupal/file/FileStorageController.php3
-rw-r--r--core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php3
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php10
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php8
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php4
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php16
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php5
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php16
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php24
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php6
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php6
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/SaveTest.php4
-rw-r--r--core/modules/filter/filter.module3
-rw-r--r--core/modules/filter/lib/Drupal/filter/FilterPluginManager.php3
-rw-r--r--core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php3
-rw-r--r--core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php5
-rw-r--r--core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php3
-rw-r--r--core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php5
-rw-r--r--core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php5
-rw-r--r--core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php3
-rw-r--r--core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php3
-rw-r--r--core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php13
-rw-r--r--core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php3
-rw-r--r--core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php4
-rw-r--r--core/modules/image/image.module3
-rw-r--r--core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php10
-rw-r--r--core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php22
-rw-r--r--core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php3
-rw-r--r--core/modules/language/language.admin.inc2
-rw-r--r--core/modules/language/language.module30
-rw-r--r--core/modules/language/language.negotiation.inc8
-rw-r--r--core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php3
-rw-r--r--core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php5
-rw-r--r--core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php2
-rw-r--r--core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php3
-rw-r--r--core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php4
-rw-r--r--core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php4
-rw-r--r--core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php4
-rw-r--r--core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php5
-rw-r--r--core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php3
-rw-r--r--core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php8
-rw-r--r--core/modules/language/tests/language_test/language_test.module10
-rw-r--r--core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php9
-rw-r--r--core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php2
-rw-r--r--core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php7
-rw-r--r--core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php2
-rw-r--r--core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php16
-rw-r--r--core/modules/locale/locale.bulk.inc14
-rw-r--r--core/modules/locale/locale.install8
-rw-r--r--core/modules/locale/locale.module17
-rw-r--r--core/modules/locale/locale.pages.inc3
-rw-r--r--core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php3
-rw-r--r--core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php3
-rw-r--r--core/modules/node/lib/Drupal/node/NodeAccessController.php3
-rw-r--r--core/modules/node/lib/Drupal/node/NodeFormController.php3
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php3
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php4
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php6
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php1
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php7
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php4
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php4
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php2
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php6
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php6
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php8
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php4
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php4
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/PageEditTest.php6
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php10
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php9
-rw-r--r--core/modules/node/node.admin.inc7
-rw-r--r--core/modules/node/node.install6
-rw-r--r--core/modules/node/node.module9
-rw-r--r--core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php3
-rw-r--r--core/modules/openid/openid.inc4
-rw-r--r--core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php5
-rw-r--r--core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php3
-rw-r--r--core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php11
-rw-r--r--core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php4
-rw-r--r--core/modules/path/path.admin.inc12
-rw-r--r--core/modules/path/path.module15
-rw-r--r--core/modules/php/lib/Drupal/php/Tests/PhpFilterTest.php4
-rw-r--r--core/modules/picture/lib/Drupal/picture/Tests/PictureFieldDisplayTest.php3
-rw-r--r--core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php5
-rw-r--r--core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php3
-rw-r--r--core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php1
-rw-r--r--core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php4
-rw-r--r--core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php10
-rw-r--r--core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php4
-rw-r--r--core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php8
-rw-r--r--core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php4
-rw-r--r--core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php4
-rw-r--r--core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php4
-rw-r--r--core/modules/search/search.pages.inc6
-rw-r--r--core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php5
-rw-r--r--core/modules/simpletest/lib/Drupal/simpletest/TestBase.php3
-rw-r--r--core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php5
-rw-r--r--core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php4
-rw-r--r--core/modules/system/language.api.php6
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php7
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php5
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php13
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php13
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php3
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php6
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php8
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php16
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php10
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php5
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php4
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php2
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php3
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php3
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php9
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php3
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php10
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php6
-rw-r--r--core/modules/system/system.api.php2
-rw-r--r--core/modules/system/system.install5
-rw-r--r--core/modules/system/system.module3
-rw-r--r--core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php3
-rw-r--r--core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php3
-rw-r--r--core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php3
-rw-r--r--core/modules/system/tests/modules/form_test/form_test.module13
-rw-r--r--core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php3
-rw-r--r--core/modules/system/tests/upgrade/drupal-7.language.database.php4
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php5
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php3
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php4
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php4
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php7
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php5
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php4
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php5
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php4
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php8
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php5
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php6
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php3
-rw-r--r--core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php3
-rw-r--r--core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php3
-rw-r--r--core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php7
-rw-r--r--core/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php5
-rw-r--r--core/modules/toolbar/toolbar.module3
-rw-r--r--core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php9
-rw-r--r--core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php3
-rw-r--r--core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php21
-rw-r--r--core/modules/translation/translation.module11
-rw-r--r--core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php5
-rw-r--r--core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php3
-rw-r--r--core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php3
-rw-r--r--core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationWorkflowsTest.php3
-rw-r--r--core/modules/translation_entity/translation_entity.admin.inc31
-rw-r--r--core/modules/translation_entity/translation_entity.install4
-rw-r--r--core/modules/translation_entity/translation_entity.module16
-rw-r--r--core/modules/translation_entity/translation_entity.pages.inc10
-rw-r--r--core/modules/user/lib/Drupal/user/AccountFormController.php9
-rw-r--r--core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php7
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php3
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php5
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php9
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php3
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php2
-rw-r--r--core/modules/user/user.install9
-rw-r--r--core/modules/user/user.pages.inc3
-rw-r--r--core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php5
-rw-r--r--core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php5
-rw-r--r--core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php7
-rw-r--r--core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php4
-rw-r--r--core/modules/views/lib/Drupal/views/ViewsData.php3
-rw-r--r--core/modules/views/views.api.php2
-rw-r--r--core/modules/views/views.module10
-rw-r--r--core/modules/views/views.theme.inc3
-rw-r--r--core/modules/views/views.views_execution.inc3
-rw-r--r--core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php9
-rw-r--r--core/tests/Drupal/Tests/Core/Entity/EntityAccessCheckTest.php8
-rw-r--r--core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php6
265 files changed, 1117 insertions, 829 deletions
diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index ce64e46..6541350 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -188,90 +188,6 @@ const DRUPAL_AUTHENTICATED_RID = 'authenticated';
const DRUPAL_KILOBYTE = 1024;
/**
- * Special system language code (only applicable to UI language).
- *
- * Refers to the language used in Drupal and module/theme source code. Drupal
- * uses the built-in text for English by default, but if configured to allow
- * translation/customization of English, we need to differentiate between the
- * built-in language and the English translation.
- */
-const LANGUAGE_SYSTEM = 'system';
-
-/**
- * The language code used when no language is explicitly assigned (yet).
- *
- * Should be used when language information is not available or cannot be
- * determined. This special language code is useful when we know the data
- * might have linguistic information, but we don't know the language.
- *
- * See http://www.w3.org/International/questions/qa-no-language#undetermined.
- */
-const LANGUAGE_NOT_SPECIFIED = 'und';
-
-/**
- * The language code used when the marked object has no linguistic content.
- *
- * Should be used when we explicitly know that the data referred has no
- * linguistic content.
- *
- * See http://www.w3.org/International/questions/qa-no-language#nonlinguistic.
- */
-const LANGUAGE_NOT_APPLICABLE = 'zxx';
-
-/**
- * Language code referring to the default language of data, e.g. of an entity.
- *
- * @todo: Change value to differ from LANGUAGE_NOT_SPECIFIED once field API
- * leverages the property API.
- */
-const LANGUAGE_DEFAULT = 'und';
-
-/**
- * The language state when referring to configurable languages.
- */
-const LANGUAGE_CONFIGURABLE = 1;
-
-/**
- * The language state when referring to locked languages.
- */
-const LANGUAGE_LOCKED = 2;
-
-/**
- * The language state used when referring to all languages.
- */
-const LANGUAGE_ALL = 3;
-
-/**
- * The language state used when referring to the site's default language.
- */
-const LANGUAGE_SITE_DEFAULT = 4;
-
-/**
- * The type of language used to define the content language.
- */
-const LANGUAGE_TYPE_CONTENT = 'language_content';
-
-/**
- * The type of language used to select the user interface.
- */
-const LANGUAGE_TYPE_INTERFACE = 'language_interface';
-
-/**
- * The type of language used for URLs.
- */
-const LANGUAGE_TYPE_URL = 'language_url';
-
-/**
- * Language written left to right. Possible value of $language->direction.
- */
-const LANGUAGE_LTR = 0;
-
-/**
- * Language written right to left. Possible value of $language->direction.
- */
-const LANGUAGE_RTL = 1;
-
-/**
* Time of the current request in seconds elapsed since the Unix Epoch.
*
* This differs from $_SERVER['REQUEST_TIME'], which is stored as a float
@@ -1465,7 +1381,7 @@ function t($string, array $args = array(), array $options = array()) {
// Merge in default.
if (empty($options['langcode'])) {
- $options['langcode'] = language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ $options['langcode'] = language(Language::TYPE_INTERFACE)->langcode;
}
if (empty($options['context'])) {
$options['context'] = '';
@@ -1483,7 +1399,7 @@ function t($string, array $args = array(), array $options = array()) {
$string = $custom_strings[$options['langcode']][$options['context']][$string];
}
// Translate with locale module if enabled.
- elseif ($options['langcode'] != LANGUAGE_SYSTEM && ($options['langcode'] != 'en' || variable_get('locale_translate_english', FALSE)) && function_exists('locale')) {
+ elseif ($options['langcode'] != Language::LANGCODE_SYSTEM && ($options['langcode'] != 'en' || variable_get('locale_translate_english', FALSE)) && function_exists('locale')) {
$string = locale($string, $options['context'], $options['langcode']);
}
if (empty($args)) {
@@ -2571,7 +2487,7 @@ function drupal_language_initialize() {
* @see Drupal\Core\Language\LanguageManager
*
* @param string $type
- * The type of language object needed, e.g. LANGUAGE_TYPE_INTERFACE.
+ * The type of language object needed, e.g. Language::TYPE_INTERFACE.
*/
function language($type) {
$container = drupal_container();
@@ -2606,9 +2522,9 @@ function language_types_get_all() {
*/
function language_types_get_default() {
return array(
- LANGUAGE_TYPE_INTERFACE => TRUE,
- LANGUAGE_TYPE_CONTENT => FALSE,
- LANGUAGE_TYPE_URL => FALSE,
+ Language::TYPE_INTERFACE => TRUE,
+ Language::TYPE_CONTENT => FALSE,
+ Language::TYPE_URL => FALSE,
);
}
@@ -2630,13 +2546,14 @@ function language_multilingual() {
*
* @param $flags
* (optional) Specifies the state of the languages that have to be returned.
- * It can be: LANGUAGE_CONFIGURABLE, LANGUAGE_LOCKED, LANGUAGE_ALL.
+ * It can be: Language::STATE_CONFIGURABLE, Language::STATE_LOCKED,
+ * Language::STATE_ALL.
*
* @return array
* An associative array of languages, keyed by the language code, ordered by
* weight ascending and name ascending.
*/
-function language_list($flags = LANGUAGE_CONFIGURABLE) {
+function language_list($flags = Language::STATE_CONFIGURABLE) {
$languages = &drupal_static(__FUNCTION__);
@@ -2672,7 +2589,7 @@ function language_list($flags = LANGUAGE_CONFIGURABLE) {
$filtered_languages = array();
// Add the site's default language if flagged as allowed value.
- if ($flags & LANGUAGE_SITE_DEFAULT) {
+ if ($flags & Language::STATE_SITE_DEFAULT) {
$default = isset($default) ? $default : language_default();
// Rename the default language.
$default->name = t("Site's default language (@lang_name)", array('@lang_name' => $default->name));
@@ -2680,7 +2597,7 @@ function language_list($flags = LANGUAGE_CONFIGURABLE) {
}
foreach ($languages as $langcode => $language) {
- if (($language->locked && !($flags & LANGUAGE_LOCKED)) || (!$language->locked && !($flags & LANGUAGE_CONFIGURABLE))) {
+ if (($language->locked && !($flags & Language::STATE_LOCKED)) || (!$language->locked && !($flags & Language::STATE_CONFIGURABLE))) {
continue;
}
$filtered_languages[$langcode] = $language;
@@ -2707,13 +2624,13 @@ function language_default_locked_languages($weight = 0) {
);
$languages = array();
- $languages[LANGUAGE_NOT_SPECIFIED] = new Language(array(
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ $languages[Language::LANGCODE_NOT_SPECIFIED] = new Language(array(
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'name' => t('Not specified'),
'weight' => ++$weight,
) + $locked_language);
- $languages[LANGUAGE_NOT_APPLICABLE] = new Language(array(
- 'langcode' => LANGUAGE_NOT_APPLICABLE,
+ $languages[Language::LANGCODE_NOT_APPLICABLE] = new Language(array(
+ 'langcode' => Language::LANGCODE_NOT_APPLICABLE,
'name' => t('Not applicable'),
'weight' => ++$weight,
) + $locked_language);
@@ -2730,7 +2647,7 @@ function language_default_locked_languages($weight = 0) {
* A fully-populated language object or FALSE.
*/
function language_load($langcode) {
- $languages = language_list(LANGUAGE_ALL);
+ $languages = language_list(Language::STATE_ALL);
return isset($languages[$langcode]) ? $languages[$langcode] : FALSE;
}
@@ -2744,7 +2661,7 @@ function language_load($langcode) {
* The printed name of the language.
*/
function language_name($langcode) {
- if ($langcode == LANGUAGE_NOT_SPECIFIED) {
+ if ($langcode == Language::LANGCODE_NOT_SPECIFIED) {
return t('None');
}
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 8b9d9e3..4f72021 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -2,6 +2,7 @@
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Cache\Cache;
+use Drupal\Core\Language\Language;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\Yaml\Parser;
use Drupal\Component\PhpStorage\PhpStorageFactory;
@@ -1261,7 +1262,7 @@ function filter_xss_bad_protocol($string, $decode = TRUE) {
* Arbitrary elements may be added using the $args associative array.
*/
function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) {
- $langcode = $langcode ? $langcode : language(LANGUAGE_TYPE_CONTENT)->langcode;
+ $langcode = $langcode ? $langcode : language(Language::TYPE_CONTENT)->langcode;
$output = "<channel>\n";
$output .= ' <title>' . check_plain($title) . "</title>\n";
@@ -1563,7 +1564,7 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
}
if (empty($langcode)) {
- $langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ $langcode = language(Language::TYPE_INTERFACE)->langcode;
}
// Create a DrupalDateTime object from the timestamp and timezone.
@@ -1711,7 +1712,7 @@ function datetime_default_format_type() {
* - 'language': An optional language object. If the path being linked to is
* internal to the site, $options['language'] is used to look up the alias
* for the URL. If $options['language'] is omitted, the language will be
- * obtained from language(LANGUAGE_TYPE_URL).
+ * obtained from language(Language::TYPE_URL).
* - 'https': Whether this URL should point to a secure location. If not
* defined, the current scheme is used, so the user stays on HTTP or HTTPS
* respectively. TRUE enforces HTTPS and FALSE enforces HTTP, but HTTPS can
@@ -1946,7 +1947,7 @@ function l($text, $path, array $options = array()) {
$active = array(
'path' => current_path(),
'front_page' => drupal_is_front_page(),
- 'language' => language(LANGUAGE_TYPE_URL)->langcode,
+ 'language' => language(Language::TYPE_URL)->langcode,
'query' => Drupal::service('request')->query->all(),
);
}
diff --git a/core/includes/entity.inc b/core/includes/entity.inc
index 444634b..702a56e 100644
--- a/core/includes/entity.inc
+++ b/core/includes/entity.inc
@@ -8,6 +8,7 @@
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Language\Language;
/**
* Gets the entity definition for an entity type.
@@ -58,7 +59,7 @@ function entity_info_cache_clear() {
function entity_get_bundles($entity_type = NULL) {
$bundles = &drupal_static(__FUNCTION__);
if (!$bundles) {
- $langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ $langcode = language(Language::TYPE_INTERFACE)->langcode;
if ($cache = cache()->get("entity_bundle_info:$langcode")) {
$bundles = $cache->data;
}
@@ -116,7 +117,7 @@ function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = N
function entity_get_view_modes($entity_type = NULL) {
$view_modes = &drupal_static(__FUNCTION__);
if (!$view_modes) {
- $langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ $langcode = language(Language::TYPE_INTERFACE)->langcode;
if ($cache = cache()->get("entity_view_mode_info:$langcode")) {
$view_modes = $cache->data;
}
diff --git a/core/includes/form.inc b/core/includes/form.inc
index e5433f5..f3d1d86 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -10,6 +10,7 @@ use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\BaseFormIdInterface;
use Drupal\Core\Database\Database;
+use Drupal\Core\Language\Language;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Utility\Color;
@@ -3761,7 +3762,7 @@ function form_validate_table($element, &$form_state) {
*/
function form_process_machine_name($element, &$form_state) {
// We need to pass the langcode to the client.
- $language = language(LANGUAGE_TYPE_INTERFACE);
+ $language = language(Language::TYPE_INTERFACE);
// Apply default form element properties.
$element += array(
diff --git a/core/includes/language.inc b/core/includes/language.inc
index 74d5752..896cf69 100644
--- a/core/includes/language.inc
+++ b/core/includes/language.inc
@@ -7,6 +7,8 @@
* @see http://drupal.org/node/1497272
*/
+use Drupal\Core\Language\Language;
+
/**
* No language negotiation. The default language is used.
*/
@@ -46,7 +48,7 @@ const LANGUAGE_NEGOTIATION_SELECTED = 'language-selected';
* configurable:
* @code
* function mymodule_language_types_info_alter(&$language_types) {
- * unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']);
+ * unset($language_types[Language::TYPE_CONTENT]['fixed']);
* }
* @endcode
*
@@ -528,18 +530,18 @@ function language_url_split_prefix($path, $languages) {
* Returns the possible fallback languages ordered by language weight.
*
* @param
- * (optional) The language type. Defaults to LANGUAGE_TYPE_CONTENT.
+ * (optional) The language type. Defaults to Language::TYPE_CONTENT.
*
* @return
* An array of language codes.
*/
-function language_fallback_get_candidates($type = LANGUAGE_TYPE_CONTENT) {
+function language_fallback_get_candidates($type = Language::TYPE_CONTENT) {
$fallback_candidates = &drupal_static(__FUNCTION__);
if (!isset($fallback_candidates)) {
- // Get languages ordered by weight, add LANGUAGE_NOT_SPECIFIED at the end.
+ // Get languages ordered by weight, add Language::LANGCODE_NOT_SPECIFIED at the end.
$fallback_candidates = array_keys(language_list());
- $fallback_candidates[] = LANGUAGE_NOT_SPECIFIED;
+ $fallback_candidates[] = Language::LANGCODE_NOT_SPECIFIED;
// Let other modules hook in and add/change candidates.
drupal_alter('language_fallback_candidates', $fallback_candidates);
diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index 08181b1..f7ee143 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -7,6 +7,7 @@
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Language\Language;
use Drupal\Core\Template\Attribute;
use Drupal\menu_link\Plugin\Core\Entity\MenuLink;
use Drupal\menu_link\MenuLinkStorageController;
@@ -1109,7 +1110,7 @@ function menu_tree_output($tree) {
*/
function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
$tree = &drupal_static(__FUNCTION__, array());
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Use $mlid as a flag for whether the data being loaded is for the whole tree.
$mlid = isset($link['mlid']) ? $link['mlid'] : 0;
@@ -1220,7 +1221,7 @@ function menu_tree_get_path($menu_name) {
function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = FALSE) {
$tree = &drupal_static(__FUNCTION__, array());
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Check if the active trail has been overridden for this menu tree.
$active_path = menu_tree_get_path($menu_name);
@@ -1371,7 +1372,7 @@ function menu_build_tree($menu_name, array $parameters = array()) {
function _menu_build_tree($menu_name, array $parameters = array()) {
// Static cache of already built menu trees.
$trees = &drupal_static(__FUNCTION__, array());
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Build the cache id; sort parents to prevent duplicate storage and remove
// default parameter values.
diff --git a/core/includes/standard.inc b/core/includes/standard.inc
index 1289475..9271162 100644
--- a/core/includes/standard.inc
+++ b/core/includes/standard.inc
@@ -5,6 +5,8 @@
* Provides a list of countries and languages based on web standards.
*/
+use Drupal\Core\Language\Language;
+
/**
* Get an array of all country code => country name pairs.
*
@@ -306,7 +308,7 @@ function standard_language_list() {
return array(
'af' => array('Afrikaans', 'Afrikaans'),
'am' => array('Amharic', 'አማርኛ'),
- 'ar' => array('Arabic', /* Left-to-right marker "‭" */ 'العربية', LANGUAGE_RTL),
+ 'ar' => array('Arabic', /* Left-to-right marker "‭" */ 'العربية', Language::DIRECTION_RTL),
'ast' => array('Asturian', 'Asturianu'),
'az' => array('Azerbaijani', 'Azərbaycanca'),
'be' => array('Belarusian', 'Беларуская'),
@@ -326,7 +328,7 @@ function standard_language_list() {
'es' => array('Spanish', 'Español'),
'et' => array('Estonian', 'Eesti'),
'eu' => array('Basque', 'Euskera'),
- 'fa' => array('Persian, Farsi', /* Left-to-right marker "‭" */ 'فارسی', LANGUAGE_RTL),
+ 'fa' => array('Persian, Farsi', /* Left-to-right marker "‭" */ 'فارسی', Language::DIRECTION_RTL),
'fi' => array('Finnish', 'Suomi'),
'fil' => array('Filipino', 'Filipino'),
'fo' => array('Faeroese', 'Føroyskt'),
@@ -335,7 +337,7 @@ function standard_language_list() {
'gl' => array('Galician', 'Galego'),
'gsw-berne' => array('Swiss German', 'Schwyzerdütsch'),
'gu' => array('Gujarati', 'ગુજરાતી'),
- 'he' => array('Hebrew', /* Left-to-right marker "‭" */ 'עברית', LANGUAGE_RTL),
+ 'he' => array('Hebrew', /* Left-to-right marker "‭" */ 'עברית', Language::DIRECTION_RTL),
'hi' => array('Hindi', 'हिन्दी'),
'hr' => array('Croatian', 'Hrvatski'),
'ht' => array('Haitian Creole', 'Kreyòl ayisyen'),
@@ -387,7 +389,7 @@ function standard_language_list() {
'tyv' => array('Tuvan', 'Тыва дыл'),
'ug' => array('Uyghur', 'Уйғур'),
'uk' => array('Ukrainian', 'Українська'),
- 'ur' => array('Urdu', /* Left-to-right marker "‭" */ 'اردو', LANGUAGE_RTL),
+ 'ur' => array('Urdu', /* Left-to-right marker "‭" */ 'اردو', Language::DIRECTION_RTL),
'vi' => array('Vietnamese', 'Tiếng Việt'),
'xx-lolspeak' => array('Lolspeak', 'Lolspeak'),
'zh-hans' => array('Chinese, Simplified', '简体中文'),
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 782b562..3683d37 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -10,6 +10,7 @@
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\Config;
+use Drupal\Core\Language\Language;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Utility\ThemeRegistry;
use Drupal\Core\Theme\ThemeSettings;
@@ -1790,7 +1791,7 @@ function theme_link($variables) {
* http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.
*/
function theme_links($variables) {
- $language_url = language(LANGUAGE_TYPE_URL);
+ $language_url = language(Language::TYPE_URL);
$links = $variables['links'];
$attributes = $variables['attributes'];
@@ -2736,7 +2737,7 @@ function _template_preprocess_default_variables() {
* @see system_elements()
*/
function template_preprocess_html(&$variables) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Compile a list of classes that are going to be applied to the body element.
// This allows advanced theming based on context (home page, node of certain type, etc.).
@@ -2870,7 +2871,7 @@ function template_preprocess_html(&$variables) {
* @see template_process_page()
*/
function template_preprocess_page(&$variables) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$site_config = config('system.site');
// Move some variables to the top level for themer convenience and template cleanliness.
@@ -3085,7 +3086,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') {
*/
function template_preprocess_maintenance_page(&$variables) {
global $theme;
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Retrieve the theme data to list all available regions.
$theme_data = list_themes();
$regions = $theme_data[$theme]->info['regions'];
diff --git a/core/lib/Drupal/Core/Condition/ConditionManager.php b/core/lib/Drupal/Core/Condition/ConditionManager.php
index 4131330..e973132 100644
--- a/core/lib/Drupal/Core/Condition/ConditionManager.php
+++ b/core/lib/Drupal/Core/Condition/ConditionManager.php
@@ -12,6 +12,7 @@ use Drupal\Core\Executable\ExecutableManagerInterface;
use Drupal\Core\Executable\ExecutableInterface;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
+use Drupal\Core\Language\Language;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
@@ -32,7 +33,7 @@ class ConditionManager extends PluginManagerBase implements ExecutableManagerInt
$this->discovery = new AnnotatedClassDiscovery('Condition', $namespaces);
$this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
$this->discovery = new AlterDecorator($this->discovery, 'condition_info');
- $this->discovery = new CacheDecorator($this->discovery, 'condition:' . language(LANGUAGE_TYPE_INTERFACE)->langcode);
+ $this->discovery = new CacheDecorator($this->discovery, 'condition:' . language(Language::TYPE_INTERFACE)->langcode);
$this->factory = new DefaultFactory($this);
}
diff --git a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
index 468c583..0179bcc 100644
--- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
+++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php
@@ -7,6 +7,7 @@
namespace Drupal\Core\Datetime;
use Drupal\Component\Datetime\DateTimePlus;
+use Drupal\Core\Language\Language;
/**
* Extends DateTimePlus().
@@ -59,7 +60,7 @@ class DrupalDateTime extends DateTimePlus {
public function __construct($time = 'now', $timezone = NULL, $format = NULL, $settings = array()) {
// We can set the langcode and country using Drupal values.
- $settings['langcode'] = !empty($settings['langcode']) ? $settings['langcode'] : language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ $settings['langcode'] = !empty($settings['langcode']) ? $settings['langcode'] : language(Language::TYPE_INTERFACE)->langcode;
$settings['country'] = !empty($settings['country']) ? $settings['country'] : config('system.date')->get('country.default');
// Instantiate the parent class.
diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
index 6bb91e1..9c223f2 100644
--- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
+++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php
@@ -7,6 +7,7 @@
namespace Drupal\Core\Entity;
+use Drupal\Core\Language\Language;
use PDO;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Entity\Query\QueryInterface;
@@ -680,7 +681,7 @@ class DatabaseStorageController implements EntityStorageControllerInterface {
public function getFieldDefinitions(array $constraints) {
if (!isset($this->entityFieldInfo)) {
// First, try to load from cache.
- $cid = 'entity_field_definitions:' . $this->entityType . ':' . language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ $cid = 'entity_field_definitions:' . $this->entityType . ':' . language(Language::TYPE_INTERFACE)->langcode;
if ($cache = cache()->get($cid)) {
$this->entityFieldInfo = $cache->data;
}
diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
index 9b7020a..12f7c80 100644
--- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
+++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php
@@ -7,6 +7,7 @@
namespace Drupal\Core\Entity;
+use Drupal\Core\Language\Language;
use PDO;
use Drupal\Core\Entity\Query\QueryInterface;
@@ -202,7 +203,7 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
// Skip the item delta and item value levels but let the field assign
// the value as suiting. This avoids unnecessary array hierarchies and
// saves memory here.
- $values[$name][LANGUAGE_DEFAULT] = $value;
+ $values[$name][Language::LANGCODE_DEFAULT] = $value;
}
$bundle = $this->bundleKey ? $record->{$this->bundleKey} : FALSE;
// Turn the record into an entity class.
@@ -242,9 +243,9 @@ class DatabaseStorageControllerNG extends DatabaseStorageController {
foreach ($data as $values) {
$id = $values[$this->idKey];
- // Field values in default language are stored with LANGUAGE_DEFAULT as
- // key.
- $langcode = empty($values['default_langcode']) ? $values['langcode'] : LANGUAGE_DEFAULT;
+ // Field values in default language are stored with
+ // Language::LANGCODE_DEFAULT as key.
+ $langcode = empty($values['default_langcode']) ? $values['langcode'] : Language::LANGCODE_DEFAULT;
$translation = $entities[$id]->getTranslation($langcode);
foreach ($field_definition as $name => $definition) {
diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php
index d48d0b7..7ea8b62 100644
--- a/core/lib/Drupal/Core/Entity/Entity.php
+++ b/core/lib/Drupal/Core/Entity/Entity.php
@@ -27,7 +27,7 @@ class Entity implements IteratorAggregate, EntityInterface {
*
* @var string
*/
- public $langcode = LANGUAGE_NOT_SPECIFIED;
+ public $langcode = Language::LANGCODE_NOT_SPECIFIED;
/**
* The entity type.
@@ -260,7 +260,7 @@ class Entity implements IteratorAggregate, EntityInterface {
public function access($operation = 'view', \Drupal\user\Plugin\Core\Entity\User $account = NULL) {
return \Drupal::entityManager()
->getAccessController($this->entityType)
- ->access($this, $operation, LANGUAGE_DEFAULT, $account);
+ ->access($this, $operation, Language::LANGCODE_DEFAULT, $account);
}
/**
@@ -272,7 +272,7 @@ class Entity implements IteratorAggregate, EntityInterface {
$language = language_load($this->langcode);
if (!$language) {
// Make sure we return a proper language object.
- $language = new Language(array('langcode' => LANGUAGE_NOT_SPECIFIED));
+ $language = new Language(array('langcode' => Language::LANGCODE_NOT_SPECIFIED));
}
return $language;
}
@@ -317,7 +317,7 @@ class Entity implements IteratorAggregate, EntityInterface {
}
}
}
- $languages = array_intersect_key(language_list(LANGUAGE_ALL), $languages);
+ $languages = array_intersect_key(language_list(Language::STATE_ALL), $languages);
}
if (empty($include_default)) {
diff --git a/core/lib/Drupal/Core/Entity/EntityAccessController.php b/core/lib/Drupal/Core/Entity/EntityAccessController.php
index 9b75d53..da0c003 100644
--- a/core/lib/Drupal/Core/Entity/EntityAccessController.php
+++ b/core/lib/Drupal/Core/Entity/EntityAccessController.php
@@ -7,6 +7,7 @@
namespace Drupal\Core\Entity;
+use Drupal\Core\Language\Language;
use Drupal\user\Plugin\Core\Entity\User;
/**
@@ -24,7 +25,7 @@ class EntityAccessController implements EntityAccessControllerInterface {
/**
* {@inheritdoc}
*/
- public function access(EntityInterface $entity, $operation, $langcode = LANGUAGE_DEFAULT, User $account = NULL) {
+ public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, User $account = NULL) {
// @todo Remove this once we can rely on $account.
if (!$account) {
diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php
index ddf3dfd..ea93c9d 100644
--- a/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php
+++ b/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php
@@ -7,6 +7,7 @@
namespace Drupal\Core\Entity;
+use Drupal\Core\Language\Language;
// @todo Don't depend on module level code.
use Drupal\user\Plugin\Core\Entity\User;
@@ -25,7 +26,7 @@ interface EntityAccessControllerInterface {
* Usually one of "view", "create", "update" or "delete".
* @param string $langcode
* (optional) The language code for which to check access. Defaults to
- * LANGUAGE_DEFAULT.
+ * Language::LANGCODE_DEFAULT.
* @param \Drupal\user\Plugin\Core\Entity\User $account
* (optional) The user for which to check access, or NULL to check access
* for the current user. Defaults to NULL.
@@ -33,7 +34,7 @@ interface EntityAccessControllerInterface {
* @return bool
* TRUE if access was granted, FALSE otherwise.
*/
- public function access(EntityInterface $entity, $operation, $langcode = LANGUAGE_DEFAULT, User $account = NULL);
+ public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, User $account = NULL);
/**
* Clears all cached access checks.
diff --git a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php
index 9697648..ffb0e0c 100644
--- a/core/lib/Drupal/Core/Entity/EntityBCDecorator.php
+++ b/core/lib/Drupal/Core/Entity/EntityBCDecorator.php
@@ -7,6 +7,7 @@
namespace Drupal\Core\Entity;
+use Drupal\Core\Language\Language;
use IteratorAggregate;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\TypedData\TypedDataInterface;
@@ -118,28 +119,29 @@ class EntityBCDecorator implements IteratorAggregate, EntityInterface {
// an entity field, provide direct access to the plain value. This makes it
// possible to use the BC-decorator with properties; e.g., $node->title.
if (isset($this->definitions[$name]) && empty($this->definitions[$name]['configurable'])) {
- if (!isset($this->decorated->values[$name][LANGUAGE_DEFAULT])) {
- $this->decorated->values[$name][LANGUAGE_DEFAULT][0]['value'] = NULL;
+ if (!isset($this->decorated->values[$name][Language::LANGCODE_DEFAULT])) {
+ $this->decorated->values[$name][Language::LANGCODE_DEFAULT][0]['value'] = NULL;
}
- if (is_array($this->decorated->values[$name][LANGUAGE_DEFAULT])) {
+ if (is_array($this->decorated->values[$name][Language::LANGCODE_DEFAULT])) {
// This will work with all defined properties that have a single value.
// We need to ensure the key doesn't matter. Mostly it's 'value' but
// e.g. EntityReferenceItem uses target_id.
- if (isset($this->decorated->values[$name][LANGUAGE_DEFAULT][0]) && count($this->decorated->values[$name][LANGUAGE_DEFAULT][0]) == 1) {
- return $this->decorated->values[$name][LANGUAGE_DEFAULT][0][key($this->decorated->values[$name][LANGUAGE_DEFAULT][0])];
+ if (isset($this->decorated->values[$name][Language::LANGCODE_DEFAULT][0]) && count($this->decorated->values[$name][Language::LANGCODE_DEFAULT][0]) == 1) {
+ return $this->decorated->values[$name][Language::LANGCODE_DEFAULT][0][key($this->decorated->values[$name][Language::LANGCODE_DEFAULT][0])];
}
}
- return $this->decorated->values[$name][LANGUAGE_DEFAULT];
+ return $this->decorated->values[$name][Language::LANGCODE_DEFAULT];
}
else {
// Allow accessing field values in an entity default language other than
- // LANGUAGE_DEFAULT by mapping the values to LANGUAGE_DEFAULT. This is
- // necessary as EntityNG always keys default language values with
- // LANGUAGE_DEFAULT while field API expects them to be keyed by langcode.
+ // Language::LANGCODE_DEFAULT by mapping the values to
+ // Language::LANGCODE_DEFAULT. This is necessary as EntityNG always keys
+ // default language values with Language::LANGCODE_DEFAULT while field API
+ // expects them to be keyed by langcode.
$langcode = $this->decorated->language()->langcode;
- if ($langcode != LANGUAGE_DEFAULT && isset($this->decorated->values[$name]) && is_array($this->decorated->values[$name])) {
- if (isset($this->decorated->values[$name][LANGUAGE_DEFAULT]) && !isset($this->decorated->values[$name][$langcode])) {
- $this->decorated->values[$name][$langcode] = &$this->decorated->values[$name][LANGUAGE_DEFAULT];
+ if ($langcode != Language::LANGCODE_DEFAULT && isset($this->decorated->values[$name]) && is_array($this->decorated->values[$name])) {
+ if (isset($this->decorated->values[$name][Language::LANGCODE_DEFAULT]) && !isset($this->decorated->values[$name][$langcode])) {
+ $this->decorated->values[$name][$langcode] = &$this->decorated->values[$name][Language::LANGCODE_DEFAULT];
}
}
if (!isset($this->decorated->values[$name])) {
@@ -160,18 +162,18 @@ class EntityBCDecorator implements IteratorAggregate, EntityInterface {
// an entity field, directly write to the plain value. This makes it
// possible to use the BC-decorator with properties; e.g., $node->title.
if ($defined && empty($this->definitions[$name]['configurable'])) {
- $this->decorated->values[$name][LANGUAGE_DEFAULT] = $value;
+ $this->decorated->values[$name][Language::LANGCODE_DEFAULT] = $value;
}
else {
if ($defined && is_array($value)) {
// If field API sets a value with a langcode in entity language, move it
- // to LANGUAGE_DEFAULT.
+ // to Language::LANGCODE_DEFAULT.
// This is necessary as EntityNG always keys default language values
- // with LANGUAGE_DEFAULT while field API expects them to be keyed by
- // langcode.
+ // with Language::LANGCODE_DEFAULT while field API expects them to be
+ // keyed by langcode.
foreach ($value as $langcode => $data) {
- if ($langcode != LANGUAGE_DEFAULT && $langcode == $this->decorated->language()->langcode) {
- $value[LANGUAGE_DEFAULT] = $data;
+ if ($langcode != Language::LANGCODE_DEFAULT && $langcode == $this->decorated->language()->langcode) {
+ $value[Language::LANGCODE_DEFAULT] = $data;
unset($value[$langcode]);
}
}
diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php
index 53f1de3..7c5f7ed 100644
--- a/core/lib/Drupal/Core/Entity/EntityFormController.php
+++ b/core/lib/Drupal/Core/Entity/EntityFormController.php
@@ -9,6 +9,8 @@ namespace Drupal\Core\Entity;
use Drupal\entity\EntityFormDisplayInterface;
+use Drupal\Core\Language\Language;
+
/**
* Base class for entity form controllers.
*/
@@ -316,7 +318,7 @@ class EntityFormController implements EntityFormControllerInterface {
// If no form langcode was provided we default to the current content
// language and inspect existing translations to find a valid fallback,
// if any.
- $langcode = language(LANGUAGE_TYPE_CONTENT)->langcode;
+ $langcode = language(Language::TYPE_CONTENT)->langcode;
$fallback = language_multilingual() ? language_fallback_get_candidates() : array();
while (!empty($langcode) && !isset($translations[$langcode])) {
$langcode = array_shift($fallback);
diff --git a/core/lib/Drupal/Core/Entity/EntityFormControllerNG.php b/core/lib/Drupal/Core/Entity/EntityFormControllerNG.php
index 40ef056..0c9dabd 100644
--- a/core/lib/Drupal/Core/Entity/EntityFormControllerNG.php
+++ b/core/lib/Drupal/Core/Entity/EntityFormControllerNG.php
@@ -65,7 +65,7 @@ class EntityFormControllerNG extends EntityFormController {
*/
protected function submitEntityLanguage(array $form, array &$form_state) {
// Nothing to do here, as original field values are always stored with
- // LANGUAGE_DEFAULT language.
+ // Language::LANGCODE_DEFAULT language.
// @todo Delete this method when merging EntityFormControllerNG with
// EntityFormController.
}
diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php
index 9e1d12f..f712cfb 100644
--- a/core/lib/Drupal/Core/Entity/EntityManager.php
+++ b/core/lib/Drupal/Core/Entity/EntityManager.php
@@ -9,6 +9,7 @@ namespace Drupal\Core\Entity;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
+use Drupal\Core\Language\Language;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
@@ -53,7 +54,7 @@ class EntityManager extends PluginManagerBase {
$this->discovery = new AnnotatedClassDiscovery('Core/Entity', $namespaces, $annotation_namespaces, 'Drupal\Core\Entity\Annotation\EntityType');
$this->discovery = new InfoHookDecorator($this->discovery, 'entity_info');
$this->discovery = new AlterDecorator($this->discovery, 'entity_info');
- $this->discovery = new CacheDecorator($this->discovery, 'entity_info:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'cache', CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE));
+ $this->discovery = new CacheDecorator($this->discovery, 'entity_info:' . language(Language::TYPE_INTERFACE)->langcode, 'cache', CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE));
$this->factory = new DefaultFactory($this->discovery);
}
diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php
index d9d17c2..6a93a59 100644
--- a/core/lib/Drupal/Core/Entity/EntityNG.php
+++ b/core/lib/Drupal/Core/Entity/EntityNG.php
@@ -37,8 +37,8 @@ class EntityNG extends Entity {
* The plain data values of the contained fields.
*
* This always holds the original, unchanged values of the entity. The values
- * are keyed by language code, whereas LANGUAGE_DEFAULT is used for values in
- * default language.
+ * are keyed by language code, whereas Language::LANGCODE_DEFAULT is used for
+ * values in default language.
*
* @todo: Add methods for getting original fields and for determining
* changes.
@@ -47,7 +47,7 @@ class EntityNG extends Entity {
* @var array
*/
protected $values = array(
- 'langcode' => array(LANGUAGE_DEFAULT => array(0 => array('value' => LANGUAGE_NOT_SPECIFIED))),
+ 'langcode' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => Language::LANGCODE_NOT_SPECIFIED))),
);
/**
@@ -82,8 +82,8 @@ class EntityNG extends Entity {
foreach ($values as $key => $value) {
// If the key matches an existing property set the value to the property
// to ensure non converted properties have the correct value.
- if (property_exists($this, $key) && isset($value[LANGUAGE_DEFAULT])) {
- $this->$key = $value[LANGUAGE_DEFAULT];
+ if (property_exists($this, $key) && isset($value[Language::LANGCODE_DEFAULT])) {
+ $this->$key = $value[Language::LANGCODE_DEFAULT];
}
$this->values[$key] = $value;
}
@@ -139,12 +139,12 @@ class EntityNG extends Entity {
* Implements \Drupal\Core\TypedData\ComplexDataInterface::get().
*/
public function get($property_name) {
- // Values in default language are always stored using the LANGUAGE_DEFAULT
- // constant.
- if (!isset($this->fields[$property_name][LANGUAGE_DEFAULT])) {
- return $this->getTranslatedField($property_name, LANGUAGE_DEFAULT);
+ // Values in default language are always stored using the
+ // Language::LANGCODE_DEFAULT constant.
+ if (!isset($this->fields[$property_name][Language::LANGCODE_DEFAULT])) {
+ return $this->getTranslatedField($property_name, Language::LANGCODE_DEFAULT);
}
- return $this->fields[$property_name][LANGUAGE_DEFAULT];
+ return $this->fields[$property_name][Language::LANGCODE_DEFAULT];
}
/**
@@ -160,9 +160,10 @@ class EntityNG extends Entity {
if (!$definition) {
throw new InvalidArgumentException('Field ' . check_plain($property_name) . ' is unknown.');
}
- // Non-translatable fields are always stored with LANGUAGE_DEFAULT as key.
- if ($langcode != LANGUAGE_DEFAULT && empty($definition['translatable'])) {
- $this->fields[$property_name][$langcode] = $this->getTranslatedField($property_name, LANGUAGE_DEFAULT);
+ // Non-translatable fields are always stored with
+ // Language::LANGCODE_DEFAULT as key.
+ if ($langcode != Language::LANGCODE_DEFAULT && empty($definition['translatable'])) {
+ $this->fields[$property_name][$langcode] = $this->getTranslatedField($property_name, Language::LANGCODE_DEFAULT);
}
else {
$value = NULL;
@@ -276,7 +277,7 @@ class EntityNG extends Entity {
}
if (empty($language)) {
// Make sure we return a proper language object.
- $language = new Language(array('langcode' => LANGUAGE_NOT_SPECIFIED));
+ $language = new Language(array('langcode' => Language::LANGCODE_NOT_SPECIFIED));
}
return $language;
}
@@ -287,15 +288,15 @@ class EntityNG extends Entity {
* @return \Drupal\Core\Entity\Field\Type\EntityTranslation
*/
public function getTranslation($langcode, $strict = TRUE) {
- // If the default language is LANGUAGE_NOT_SPECIFIED, the entity is not
- // translatable, so we use LANGUAGE_DEFAULT.
- if ($langcode == LANGUAGE_DEFAULT || in_array($this->language()->langcode, array(LANGUAGE_NOT_SPECIFIED, $langcode))) {
+ // If the default language is Language::LANGCODE_NOT_SPECIFIED, the entity is not
+ // translatable, so we use Language::LANGCODE_DEFAULT.
+ if ($langcode == Language::LANGCODE_DEFAULT || in_array($this->language()->langcode, array(Language::LANGCODE_NOT_SPECIFIED, $langcode))) {
// No translation needed, return the entity.
return $this;
}
// Check whether the language code is valid, thus is of an available
// language.
- $languages = language_list(LANGUAGE_ALL);
+ $languages = language_list(Language::STATE_ALL);
if (!isset($languages[$langcode])) {
throw new InvalidArgumentException("Unable to get translation for the invalid language '$langcode'.");
}
@@ -345,15 +346,15 @@ class EntityNG extends Entity {
}
}
}
- // We include the default language code instead of the LANGUAGE_DEFAULT
- // constant.
- unset($translations[LANGUAGE_DEFAULT]);
+ // We include the default language code instead of the
+ // Language::LANGCODE_DEFAULT constant.
+ unset($translations[Language::LANGCODE_DEFAULT]);
if ($include_default) {
$translations[$this->language()->langcode] = TRUE;
}
// Now load language objects based upon translation langcodes.
- return array_intersect_key(language_list(LANGUAGE_ALL), $translations);
+ return array_intersect_key(language_list(Language::STATE_ALL), $translations);
}
/**
@@ -403,15 +404,15 @@ class EntityNG extends Entity {
public function &__get($name) {
// If this is an entity field, handle it accordingly. We first check whether
// a field object has been already created. If not, we create one.
- if (isset($this->fields[$name][LANGUAGE_DEFAULT])) {
- return $this->fields[$name][LANGUAGE_DEFAULT];
+ if (isset($this->fields[$name][Language::LANGCODE_DEFAULT])) {
+ return $this->fields[$name][Language::LANGCODE_DEFAULT];
}
// Inline getPropertyDefinition() to speed up things.
if (!isset($this->fieldDefinitions)) {
$this->getPropertyDefinitions();
}
if (isset($this->fieldDefinitions[$name])) {
- $return = $this->getTranslatedField($name, LANGUAGE_DEFAULT);
+ $return = $this->getTranslatedField($name, Language::LANGCODE_DEFAULT);
return $return;
}
// Allow the EntityBCDecorator to directly access the values and fields.
@@ -439,11 +440,11 @@ class EntityNG extends Entity {
}
// If this is an entity field, handle it accordingly. We first check whether
// a field object has been already created. If not, we create one.
- if (isset($this->fields[$name][LANGUAGE_DEFAULT])) {
- $this->fields[$name][LANGUAGE_DEFAULT]->setValue($value);
+ if (isset($this->fields[$name][Language::LANGCODE_DEFAULT])) {
+ $this->fields[$name][Language::LANGCODE_DEFAULT]->setValue($value);
}
elseif ($this->getPropertyDefinition($name)) {
- $this->getTranslatedField($name, LANGUAGE_DEFAULT)->setValue($value);
+ $this->getTranslatedField($name, Language::LANGCODE_DEFAULT)->setValue($value);
}
// Else directly read/write plain values. That way, fields not yet converted
// to the entity field API can always be directly accessed.
diff --git a/core/lib/Drupal/Core/Entity/EntityRenderController.php b/core/lib/Drupal/Core/Entity/EntityRenderController.php
index 53457aa..d202636 100644
--- a/core/lib/Drupal/Core/Entity/EntityRenderController.php
+++ b/core/lib/Drupal/Core/Entity/EntityRenderController.php
@@ -8,6 +8,8 @@
namespace Drupal\Core\Entity;
use Drupal\entity\Plugin\Core\Entity\EntityDisplay;
+use Drupal\Core\Language\Language;
+
/**
* Base class for entity view controllers.
*/
@@ -94,7 +96,7 @@ class EntityRenderController implements EntityRenderControllerInterface {
*/
public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
- $langcode = language(LANGUAGE_TYPE_CONTENT)->langcode;
+ $langcode = language(Language::TYPE_CONTENT)->langcode;
}
// Build the view modes and display objects.
diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
index c5c491c..163d5c8 100644
--- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
@@ -7,6 +7,7 @@
namespace Drupal\Core\EventSubscriber;
+use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageManager;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
@@ -50,10 +51,10 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
// Set the X-UA-Compatible HTTP header to force IE to use the most recent
// rendering engine or use Chrome's frame rendering engine if available.
- $response->headers->set('X-UA-Compatible', 'IE=edge,chrome=1', false);
+ $response->headers->set('X-UA-Compatible', 'IE=edge,chrome=1', FALSE);
// Set the Content-language header.
- $response->headers->set('Content-language', $this->languageManager->getLanguage(LANGUAGE_TYPE_INTERFACE)->langcode);
+ $response->headers->set('Content-language', $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->langcode);
// Because pages are highly dynamic, set the last-modified time to now
// since the page is in fact being regenerated right now.
diff --git a/core/lib/Drupal/Core/Language/Language.php b/core/lib/Drupal/Core/Language/Language.php
index 4db85da..f51a225 100644
--- a/core/lib/Drupal/Core/Language/Language.php
+++ b/core/lib/Drupal/Core/Language/Language.php
@@ -20,13 +20,97 @@ class Language {
// Properties within the Language are set up as the default language.
public $name = '';
public $langcode = '';
- public $direction = LANGUAGE_LTR;
+ public $direction = Language::DIRECTION_LTR;
public $weight = 0;
public $default = FALSE;
public $method_id = NULL;
public $locked = FALSE;
/**
+ * Special system language code (only applicable to UI language).
+ *
+ * Refers to the language used in Drupal and module/theme source code. Drupal
+ * uses the built-in text for English by default, but if configured to allow
+ * translation/customization of English, we need to differentiate between the
+ * built-in language and the English translation.
+ */
+ const LANGCODE_SYSTEM = 'system';
+
+ /**
+ * The language code used when no language is explicitly assigned (yet).
+ *
+ * Should be used when language information is not available or cannot be
+ * determined. This special language code is useful when we know the data
+ * might have linguistic information, but we don't know the language.
+ *
+ * See http://www.w3.org/International/questions/qa-no-language#undetermined.
+ */
+ const LANGCODE_NOT_SPECIFIED = 'und';
+
+ /**
+ * The language code used when the marked object has no linguistic content.
+ *
+ * Should be used when we explicitly know that the data referred has no
+ * linguistic content.
+ *
+ * See http://www.w3.org/International/questions/qa-no-language#nonlinguistic.
+ */
+ const LANGCODE_NOT_APPLICABLE = 'zxx';
+
+ /**
+ * Language code referring to the default language of data, e.g. of an entity.
+ *
+ * @todo: Change value to differ from Language::LANGCODE_NOT_SPECIFIED once
+ * field API leverages the property API.
+ */
+ const LANGCODE_DEFAULT = 'und';
+
+ /**
+ * The language state when referring to configurable languages.
+ */
+ const STATE_CONFIGURABLE = 1;
+
+ /**
+ * The language state when referring to locked languages.
+ */
+ const STATE_LOCKED = 2;
+
+ /**
+ * The language state used when referring to all languages.
+ */
+ const STATE_ALL = 3;
+
+ /**
+ * The language state used when referring to the site's default language.
+ */
+ const STATE_SITE_DEFAULT = 4;
+
+ /**
+ * The type of language used to define the content language.
+ */
+ const TYPE_CONTENT = 'language_content';
+
+ /**
+ * The type of language used to select the user interface.
+ */
+ const TYPE_INTERFACE = 'language_interface';
+
+ /**
+ * The type of language used for URLs.
+ */
+ const TYPE_URL = 'language_url';
+
+ /**
+ * Language written left to right. Possible value of $language->direction.
+ */
+ const DIRECTION_LTR = 0;
+
+ /**
+ * Language written right to left. Possible value of $language->direction.
+ */
+ const DIRECTION_RTL = 1;
+
+ /**
* Language constructor builds the default language object.
*
* @param array $options
diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php
index fa94205..673e8e3 100644
--- a/core/lib/Drupal/Core/Language/LanguageManager.php
+++ b/core/lib/Drupal/Core/Language/LanguageManager.php
@@ -76,7 +76,7 @@ class LanguageManager {
* Returns a language object for the given type.
*
* @param string $type
- * The language type, e.g. LANGUAGE_TYPE_INTERFACE.
+ * The language type, e.g. Language::TYPE_INTERFACE.
*
* @return \Drupal\Core\Language\Language
* A language object for the given type.
@@ -115,8 +115,8 @@ class LanguageManager {
*
* @param string|null $type
* (optional) The language type to reset as a string, e.g.,
- * LANGUAGE_TYPE_INTERFACE, or NULL to reset all language types. Defaults to
- * NULL.
+ * Language::TYPE_INTERFACE, or NULL to reset all language types. Defaults
+ * to NULL.
*/
public function reset($type = NULL) {
if (!isset($type)) {
diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php
index 7a99a1c..1dde427 100644
--- a/core/lib/Drupal/Core/Path/AliasManager.php
+++ b/core/lib/Drupal/Core/Path/AliasManager.php
@@ -8,6 +8,7 @@
namespace Drupal\Core\Path;
use Drupal\Core\Database\Connection;
+use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageManager;
class AliasManager implements AliasManagerInterface {
@@ -102,7 +103,7 @@ class AliasManager implements AliasManagerInterface {
// language. If we used a language different from the one conveyed by the
// requested URL, we might end up being unable to check if there is a path
// alias matching the URL path.
- $path_language = $path_language ?: $this->languageManager->getLanguage(LANGUAGE_TYPE_URL)->langcode;
+ $path_language = $path_language ?: $this->languageManager->getLanguage(Language::TYPE_URL)->langcode;
$original_path = $path;
// Lookup the path alias first.
if (!empty($path) && $source = $this->lookupPathSource($path, $path_language)) {
@@ -120,7 +121,7 @@ class AliasManager implements AliasManagerInterface {
// language. If we used a language different from the one conveyed by the
// requested URL, we might end up being unable to check if there is a path
// alias matching the URL path.
- $path_language = $path_language ?: $this->languageManager->getLanguage(LANGUAGE_TYPE_URL)->langcode;
+ $path_language = $path_language ?: $this->languageManager->getLanguage(Language::TYPE_URL)->langcode;
$result = $path;
if (!empty($path) && $alias = $this->lookupPathAlias($path, $path_language)) {
$result = $alias;
@@ -184,7 +185,7 @@ class AliasManager implements AliasManagerInterface {
$args = array(
':system' => $this->preloadedPathLookups,
':langcode' => $langcode,
- ':langcode_undetermined' => LANGUAGE_NOT_SPECIFIED,
+ ':langcode_undetermined' => Language::LANGCODE_NOT_SPECIFIED,
);
// Always get the language-specific alias before the language-neutral
// one. For example 'de' is less than 'und' so the order needs to be
@@ -193,12 +194,12 @@ class AliasManager implements AliasManagerInterface {
// the most recently created alias for each source. Subsequent queries
// using fetchField() must use pid DESC to have the same effect.
// For performance reasons, the query builder is not used here.
- if ($langcode == LANGUAGE_NOT_SPECIFIED) {
+ if ($langcode == Language::LANGCODE_NOT_SPECIFIED) {
// Prevent PDO from complaining about a token the query doesn't use.
unset($args[':langcode']);
$result = $this->connection->query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode = :langcode_undetermined ORDER BY pid ASC', $args);
}
- elseif ($langcode < LANGUAGE_NOT_SPECIFIED) {
+ elseif ($langcode < Language::LANGCODE_NOT_SPECIFIED) {
$result = $this->connection->query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode ASC, pid ASC', $args);
}
else {
@@ -224,14 +225,14 @@ class AliasManager implements AliasManagerInterface {
$args = array(
':source' => $path,
':langcode' => $langcode,
- ':langcode_undetermined' => LANGUAGE_NOT_SPECIFIED,
+ ':langcode_undetermined' => Language::LANGCODE_NOT_SPECIFIED,
);
// See the queries above.
- if ($langcode == LANGUAGE_NOT_SPECIFIED) {
+ if ($langcode == Language::LANGCODE_NOT_SPECIFIED) {
unset($args[':langcode']);
$alias = $this->connection->query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode = :langcode_undetermined ORDER BY pid DESC", $args)->fetchField();
}
- elseif ($langcode > LANGUAGE_NOT_SPECIFIED) {
+ elseif ($langcode > Language::LANGCODE_NOT_SPECIFIED) {
$alias = $this->connection->query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode DESC, pid DESC", $args)->fetchField();
}
else {
@@ -265,14 +266,14 @@ class AliasManager implements AliasManagerInterface {
$args = array(
':alias' => $path,
':langcode' => $langcode,
- ':langcode_undetermined' => LANGUAGE_NOT_SPECIFIED,
+ ':langcode_undetermined' => Language::LANGCODE_NOT_SPECIFIED,
);
// See the queries above.
- if ($langcode == LANGUAGE_NOT_SPECIFIED) {
+ if ($langcode == Language::LANGCODE_NOT_SPECIFIED) {
unset($args[':langcode']);
$result = $this->connection->query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode = :langcode_undetermined ORDER BY pid DESC", $args);
}
- elseif ($langcode > LANGUAGE_NOT_SPECIFIED) {
+ elseif ($langcode > Language::LANGCODE_NOT_SPECIFIED) {
$result = $this->connection->query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode DESC, pid DESC", $args);
}
else {
diff --git a/core/lib/Drupal/Core/Path/Path.php b/core/lib/Drupal/Core/Path/Path.php
index a7fd55a..4a3410f 100644
--- a/core/lib/Drupal/Core/Path/Path.php
+++ b/core/lib/Drupal/Core/Path/Path.php
@@ -9,6 +9,7 @@ namespace Drupal\Core\Path;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Connection;
+use Drupal\Core\Language\Language;
/**
* Defines a class for CRUD operations on path aliases.
@@ -63,7 +64,7 @@ class Path {
* - pid: Unique path alias identifier.
* - langcode: The language code of the alias.
*/
- public function save($source, $alias, $langcode = LANGUAGE_NOT_SPECIFIED, $pid = NULL) {
+ public function save($source, $alias, $langcode = Language::LANGCODE_NOT_SPECIFIED, $pid = NULL) {
$fields = array(
'source' => $source,
diff --git a/core/lib/Drupal/Core/TypedData/TranslatableInterface.php b/core/lib/Drupal/Core/TypedData/TranslatableInterface.php
index f066b72..f86068a 100644
--- a/core/lib/Drupal/Core/TypedData/TranslatableInterface.php
+++ b/core/lib/Drupal/Core/TypedData/TranslatableInterface.php
@@ -40,8 +40,8 @@ interface TranslatableInterface {
* AccessibleInterface, the translation object has to implement both as well.
*
* @param $langcode
- * The language code of the translation to get or LANGUAGE_DEFAULT to get
- * the data in default language.
+ * The language code of the translation to get or Language::LANGCODE_DEFAULT
+ * to get the data in default language.
* @param $strict
* (optional) If the data is complex, whether the translation should include
* only translatable properties. If set to FALSE, untranslatable properties
diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php
index 8afd195..da84d55 100644
--- a/core/lib/Drupal/Core/Validation/ConstraintManager.php
+++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php
@@ -12,6 +12,7 @@ use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Discovery\StaticDiscoveryDecorator;
use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
use Drupal\Component\Plugin\Discovery\ProcessDecorator;
+use Drupal\Core\Language\Language;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
@@ -49,7 +50,7 @@ class ConstraintManager extends PluginManagerBase {
$this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
$this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition'));
$this->discovery = new AlterDecorator($this->discovery, 'validation_constraint');
- $this->discovery = new CacheDecorator($this->discovery, 'validation_constraints:' . language(LANGUAGE_TYPE_INTERFACE)->langcode);
+ $this->discovery = new CacheDecorator($this->discovery, 'validation_constraints:' . language(Language::TYPE_INTERFACE)->langcode);
$this->factory = new DefaultFactory($this);
}
diff --git a/core/lib/Drupal/Core/Validation/DrupalTranslator.php b/core/lib/Drupal/Core/Validation/DrupalTranslator.php
index 8700526..ecc6781 100644
--- a/core/lib/Drupal/Core/Validation/DrupalTranslator.php
+++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php
@@ -7,6 +7,7 @@
namespace Drupal\Core\Validation;
+use Drupal\Core\Language\Language;
use Symfony\Component\Translation\TranslatorInterface;
/**
@@ -55,7 +56,7 @@ class DrupalTranslator implements TranslatorInterface {
* Implements \Symfony\Component\Translation\TranslatorInterface::getLocale().
*/
public function getLocale() {
- return $this->locale ? $this->locale : language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ return $this->locale ? $this->locale : language(Language::TYPE_INTERFACE)->langcode;
}
/**
diff --git a/core/modules/aggregator/aggregator.install b/core/modules/aggregator/aggregator.install
index 11447ee..7979eba 100644
--- a/core/modules/aggregator/aggregator.install
+++ b/core/modules/aggregator/aggregator.install
@@ -4,6 +4,7 @@
* @file
* Install, update and uninstall functions for the aggregator module.
*/
+use Drupal\Core\Language\Language;
/**
* Implements hook_requirements().
@@ -319,7 +320,7 @@ function aggregator_update_8001() {
'length' => 12,
'not null' => TRUE,
'default' => '',
- 'initial' => LANGUAGE_DEFAULT,
+ 'initial' => Language::LANGCODE_DEFAULT,
));
db_add_field('aggregator_item', 'langcode', array(
'description' => 'The {language}.langcode of this feed item.',
@@ -327,6 +328,6 @@ function aggregator_update_8001() {
'length' => 12,
'not null' => TRUE,
'default' => '',
- 'initial' => LANGUAGE_DEFAULT,
+ 'initial' => Language::LANGCODE_DEFAULT,
));
}
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php
index 459a99b..1e77d7c 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php
@@ -8,6 +8,7 @@
namespace Drupal\aggregator;
use Drupal\Core\Entity\EntityFormControllerNG;
+use Drupal\Core\Language\Language;
/**
* Form controller for the aggregator feed edit forms.
@@ -35,7 +36,7 @@ class FeedFormController extends EntityFormControllerNG {
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $feed->language()->langcode,
- '#languages' => LANGUAGE_ALL,
+ '#languages' => Language::STATE_ALL,
);
$form['url'] = array(
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php
index 6988f94..12e41cd 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php
@@ -9,6 +9,7 @@ namespace Drupal\aggregator\Plugin;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
+use Drupal\Core\Language\Language;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
@@ -38,7 +39,7 @@ class AggregatorPluginManager extends PluginManagerBase {
);
$this->discovery = new AnnotatedClassDiscovery("aggregator/$type", $namespaces, $annotation_namespaces, $type_annotations[$type]);
- $this->discovery = new CacheDecorator($this->discovery, "aggregator_$type:" . language(LANGUAGE_TYPE_INTERFACE)->langcode);
+ $this->discovery = new CacheDecorator($this->discovery, "aggregator_$type:" . language(Language::TYPE_INTERFACE)->langcode);
$this->factory = new DefaultFactory($this->discovery);
}
}
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php
index ca56e20..8f8dc04 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\aggregator\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
use Drupal\aggregator\Plugin\Core\Entity\Feed;
@@ -355,7 +356,7 @@ EOF;
* (optional) The number of nodes to generate. Defaults to five.
*/
function createSampleNodes($count = 5) {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Post $count article nodes.
for ($i = 0; $i < $count; $i++) {
$edit = array();
diff --git a/core/modules/block/block.install b/core/modules/block/block.install
index bb9806e..8e0d224 100644
--- a/core/modules/block/block.install
+++ b/core/modules/block/block.install
@@ -5,6 +5,7 @@
* Install, update and uninstall functions for the block module.
*/
use Drupal\Component\Uuid\Uuid;
+use Drupal\Core\Language\Language;
/**
* Implements hook_install().
@@ -215,7 +216,7 @@ function block_update_8007() {
'uuid' => $uuid->generate(),
'info' => $block->info,
'revision_id' => $block->bid,
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'type' => 'basic'
);
$revision = array(
@@ -301,7 +302,7 @@ function block_update_8008() {
$found = TRUE;
$data = array(
- LANGUAGE_NOT_SPECIFIED => array(
+ Language::LANGCODE_NOT_SPECIFIED => array(
array(
'format' => $block->format,
'value' => $block->body
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
index 1a09dbf..405fabd 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
@@ -9,6 +9,7 @@ namespace Drupal\custom_block;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\EntityFormControllerNG;
+use Drupal\Core\Language\Language;
/**
* Form controller for the custom block edit forms.
@@ -77,7 +78,7 @@ class CustomBlockFormController extends EntityFormControllerNG {
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $block->langcode->value,
- '#languages' => LANGUAGE_ALL,
+ '#languages' => Language::STATE_ALL,
'#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'],
);
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
index ba86c1b..c989682 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
@@ -8,6 +8,7 @@
namespace Drupal\custom_block\Tests;
use Drupal\Core\Database\Database;
+use Drupal\Core\Language\Language;
/**
* Tests creating and saving a block.
@@ -48,7 +49,7 @@ class CustomBlockCreationTest extends CustomBlockTestBase {
public function testCustomBlockCreation() {
// Create a block.
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit['info'] = $this->randomName(8);
$edit["block_body[$langcode][0][value]"] = $this->randomName(16);
$this->drupalPost('block/add/basic', $edit, t('Save'));
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php
index 1874ff3..b74de5c 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php
@@ -7,6 +7,8 @@
namespace Drupal\custom_block\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests block save related functionality.
*/
@@ -49,7 +51,7 @@ class CustomBlockSaveTest extends CustomBlockTestBase {
$info = $this->randomName(8);
$block = array(
'info' => $info,
- 'block_body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32)))),
+ 'block_body' => array(Language::LANGCODE_NOT_SPECIFIED => array(array('value' => $this->randomName(32)))),
'type' => 'basic',
'id' => $test_id
);
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php
index 8b8a827..e541c40 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php
@@ -7,6 +7,8 @@
namespace Drupal\custom_block\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests the block edit functionality.
*/
@@ -29,7 +31,7 @@ class PageEditTest extends CustomBlockTestBase {
public function testPageEdit() {
$this->drupalLogin($this->adminUser);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$title_key = 'info';
$body_key = "block_body[$langcode][0][value]";
// Create block to edit.
diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php
index ef499c0..335a9cd 100644
--- a/core/modules/block/lib/Drupal/block/BlockFormController.php
+++ b/core/modules/block/lib/Drupal/block/BlockFormController.php
@@ -8,6 +8,7 @@
namespace Drupal\block;
use Drupal\Core\Entity\EntityFormController;
+use Drupal\Core\Language\Language;
/**
* Provides form controller for block instance forms.
@@ -111,7 +112,7 @@ class BlockFormController extends EntityFormController {
$configurable_language_types = language_types_get_configurable();
// Fetch languages.
- $languages = language_list(LANGUAGE_ALL);
+ $languages = language_list(Language::STATE_ALL);
foreach ($languages as $language) {
// @todo $language->name is not wrapped with t(), it should be replaced
// by CMI translation implementation.
diff --git a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php
index 19cdf60..012bf10 100644
--- a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php
+++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php
@@ -9,6 +9,7 @@ namespace Drupal\block\Plugin\Type;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Language\Language;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
@@ -34,7 +35,7 @@ class BlockManager extends PluginManagerBase {
$this->discovery = new AnnotatedClassDiscovery('Block', $namespaces);
$this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
$this->discovery = new AlterDecorator($this->discovery, 'block');
- $this->discovery = new CacheDecorator($this->discovery, 'block_plugins:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'block', CacheBackendInterface::CACHE_PERMANENT, array('block'));
+ $this->discovery = new CacheDecorator($this->discovery, 'block_plugins:' . language(Language::TYPE_INTERFACE)->langcode, 'block', CacheBackendInterface::CACHE_PERMANENT, array('block'));
$this->factory = new DefaultFactory($this->discovery);
}
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php
index c3fbca3..90df426 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php
@@ -7,6 +7,7 @@
namespace Drupal\block\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\DrupalUnitTestBase;
use Drupal\block_test\Plugin\Block\TestHtmlIdBlock;
use Drupal\Component\Plugin\Exception\PluginException;
diff --git a/core/modules/book/book.admin.inc b/core/modules/book/book.admin.inc
index 30333be..8f30ada 100644
--- a/core/modules/book/book.admin.inc
+++ b/core/modules/book/book.admin.inc
@@ -7,6 +7,7 @@
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Language\Language;
/**
* Form constructor for administering a single book's hierarchy.
@@ -78,7 +79,7 @@ function book_admin_edit_submit($form, &$form_state) {
// Update the title if changed.
if ($row['title']['#default_value'] != $values['title']) {
$node = node_load($values['nid']);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$node->title = $values['title'];
$node->book['link_title'] = $values['title'];
$node->setNewRevision();
diff --git a/core/modules/book/book.module b/core/modules/book/book.module
index 59f1e45..95247ad 100644
--- a/core/modules/book/book.module
+++ b/core/modules/book/book.module
@@ -6,6 +6,7 @@
*/
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Language\Language;
use Drupal\entity\Plugin\Core\Entity\EntityDisplay;
use Drupal\Core\Template\Attribute;
use Drupal\menu_link\Plugin\Core\Entity\MenuLink;
@@ -1115,12 +1116,12 @@ function book_toc($bid, $depth_limit, $exclude = array()) {
*/
function template_preprocess_book_export_html(&$variables) {
global $base_url;
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$variables['title'] = check_plain($variables['title']);
$variables['base_url'] = $base_url;
$variables['language'] = $language_interface;
- $variables['language_rtl'] = ($language_interface->direction == LANGUAGE_RTL);
+ $variables['language_rtl'] = ($language_interface->direction == Language::DIRECTION_RTL);
$variables['head'] = drupal_get_html_head();
// HTML element attributes.
diff --git a/core/modules/book/lib/Drupal/book/Tests/BookTest.php b/core/modules/book/lib/Drupal/book/Tests/BookTest.php
index eba9ff9..f15c9a8 100644
--- a/core/modules/book/lib/Drupal/book/Tests/BookTest.php
+++ b/core/modules/book/lib/Drupal/book/Tests/BookTest.php
@@ -7,6 +7,7 @@
namespace Drupal\book\Tests;
+use Drupal\Core\Language\Language;
use Drupal\Core\Entity\EntityInterface;
use Drupal\simpletest\WebTestBase;
@@ -205,7 +206,7 @@ class BookTest extends WebTestBase {
// Check printer friendly version.
$this->drupalGet('book/export/html/' . $node->nid);
$this->assertText($node->label(), 'Printer friendly title found.');
- $this->assertRaw(check_markup($node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], $node->body[LANGUAGE_NOT_SPECIFIED][0]['format']), 'Printer friendly body found.');
+ $this->assertRaw(check_markup($node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'], $node->body[Language::LANGCODE_NOT_SPECIFIED][0]['format']), 'Printer friendly body found.');
$number++;
}
@@ -242,7 +243,7 @@ class BookTest extends WebTestBase {
static $number = 0; // Used to ensure that when sorted nodes stay in same order.
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $number . ' - SimpleTest test node ' . $this->randomName(10);
$edit["body[$langcode][0][value]"] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32);
$edit['book[bid]'] = $book_nid;
@@ -280,7 +281,7 @@ class BookTest extends WebTestBase {
// Make sure each part of the book is there.
foreach ($nodes as $node) {
$this->assertText($node->label(), 'Node title found in printer friendly version.');
- $this->assertRaw(check_markup($node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], $node->body[LANGUAGE_NOT_SPECIFIED][0]['format']), 'Node body found in printer friendly version.');
+ $this->assertRaw(check_markup($node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'], $node->body[Language::LANGCODE_NOT_SPECIFIED][0]['format']), 'Node body found in printer friendly version.');
}
// Make sure we can't export an unsupported format.
diff --git a/core/modules/ckeditor/ckeditor.admin.inc b/core/modules/ckeditor/ckeditor.admin.inc
index 0dff9f5..8443833 100644
--- a/core/modules/ckeditor/ckeditor.admin.inc
+++ b/core/modules/ckeditor/ckeditor.admin.inc
@@ -5,6 +5,7 @@
* Callbacks and theming for the CKEditor toolbar configuration UI.
*/
+use Drupal\Core\Language\Language;
use Drupal\Core\Template\Attribute;
/**
@@ -12,7 +13,7 @@ use Drupal\Core\Template\Attribute;
*/
function template_preprocess_ckeditor_settings_toolbar(&$variables) {
// Simplify the language direction information for toolbar buttons.
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$variables['language_direction'] = $language_interface->direction ? 'rtl' : 'ltr';
// Create lists of active and disabled buttons.
diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php
index 06aac80..0b8e758 100644
--- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php
+++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php
@@ -7,6 +7,7 @@
namespace Drupal\ckeditor\Plugin\Editor;
+use Drupal\Core\Language\Language;
use Drupal\editor\Plugin\EditorBase;
use Drupal\editor\Annotation\Editor;
use Drupal\Core\Annotation\Translation;
@@ -107,7 +108,7 @@ class CKEditor extends EditorBase {
* Implements \Drupal\editor\Plugin\EditPluginInterface::getJSSettings().
*/
public function getJSSettings(EditorEntity $editor) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$settings = array();
$manager = drupal_container()->get('plugin.manager.ckeditor.plugin');
diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php
index 179410c..dd4e13d 100644
--- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php
+++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php
@@ -9,6 +9,7 @@ namespace Drupal\comment;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\EntityFormControllerNG;
+use Drupal\Core\Language\Language;
/**
* Base for controller for comment forms.
@@ -152,7 +153,7 @@ class CommentFormController extends EntityFormControllerNG {
// Make the comment inherit the current content language unless specifically
// set.
if ($comment->isNew()) {
- $language_content = language(LANGUAGE_TYPE_CONTENT);
+ $language_content = language(Language::TYPE_CONTENT);
$comment->langcode->value = $language_content->langcode;
}
diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php
index 059f516..55a1bd3 100644
--- a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php
+++ b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php
@@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityNG;
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\Annotation\Translation;
use Drupal\comment\CommentInterface;
+use Drupal\Core\Language\Language;
/**
* Defines the comment entity class.
@@ -183,9 +184,9 @@ class Comment extends EntityNG implements CommentInterface {
* @var array
*/
protected $values = array(
- 'langcode' => array(LANGUAGE_DEFAULT => array(0 => array('value' => LANGUAGE_NOT_SPECIFIED))),
- 'name' => array(LANGUAGE_DEFAULT => array(0 => array('value' => ''))),
- 'uid' => array(LANGUAGE_DEFAULT => array(0 => array('target_id' => 0))),
+ 'langcode' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => Language::LANGCODE_NOT_SPECIFIED))),
+ 'name' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => ''))),
+ 'uid' => array(Language::LANGCODE_DEFAULT => array(0 => array('target_id' => 0))),
);
/**
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php
index 86f778a..f4ef8cf 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php
@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests anonymous commenting.
*/
@@ -66,7 +68,7 @@ class CommentAnonymousTest extends CommentTestBase {
$this->assertTrue($this->commentExists($anonymous_comment2), 'Anonymous comment with contact info (optional) found.');
// Ensure anonymous users cannot post in the name of registered users.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array(
'name' => $this->admin_user->name,
'mail' => $this->randomName() . '@example.com',
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php
index 1294de4..9213e16 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php
@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests comment CSS classes.
*/
@@ -54,8 +56,8 @@ class CommentCSSTest extends CommentTestBase {
'uid' => $case['comment_uid'],
'status' => $case['comment_status'],
'subject' => $this->randomName(),
- 'language' => LANGUAGE_NOT_SPECIFIED,
- 'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())),
+ 'language' => Language::LANGCODE_NOT_SPECIFIED,
+ 'comment_body' => array(Language::LANGCODE_NOT_SPECIFIED => array($this->randomName())),
));
comment_save($comment);
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php
index bda6368..8d7a472 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php
@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests the comment module administrative and end-user-facing interfaces.
*/
@@ -24,7 +26,7 @@ class CommentInterfaceTest extends CommentTestBase {
* Tests the comment interface.
*/
function testCommentInterface() {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Set comments to have subject and preview disabled.
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_DISABLED);
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
index 35a935e..6dec469 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
@@ -7,6 +7,7 @@
namespace Drupal\comment\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -89,7 +90,7 @@ class CommentLanguageTest extends WebTestBase {
// language and interface language do not influence comment language, as
// only content language has to.
foreach (language_list() as $node_langcode => $node_language) {
- $langcode_not_specified = LANGUAGE_NOT_SPECIFIED;
+ $langcode_not_specified = Language::LANGCODE_NOT_SPECIFIED;
// Create "Article" content.
$title = $this->randomName();
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php
index 5585650..5523674 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php
@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests comment links based on environment configurations.
*/
@@ -146,8 +148,8 @@ class CommentLinksTest extends CommentTestBase {
'status' => COMMENT_PUBLISHED,
'subject' => $this->randomName(),
'hostname' => '127.0.0.1',
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
- 'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())),
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
+ 'comment_body' => array(Language::LANGCODE_NOT_SPECIFIED => array($this->randomName())),
));
comment_save($comment);
$this->comment = $comment;
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php
index 818227e..295c6c2 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php
@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests the 'new' marker on comments.
*/
@@ -53,8 +55,8 @@ class CommentNewIndicatorTest extends CommentTestBase {
'status' => COMMENT_PUBLISHED,
'subject' => $this->randomName(),
'hostname' => '127.0.0.1',
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
- 'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())),
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
+ 'comment_body' => array(Language::LANGCODE_NOT_SPECIFIED => array($this->randomName())),
));
comment_save($comment);
$this->drupalLogout();
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php
index f898ab2..bf1cf6b 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php
@@ -9,6 +9,8 @@ namespace Drupal\comment\Tests;
use Drupal\Core\Datetime\DrupalDateTime;
+use Drupal\Core\Language\Language;
+
/**
* Tests previewing comments.
*/
@@ -33,7 +35,7 @@ class CommentPreviewTest extends CommentTestBase {
* Tests comment preview.
*/
function testCommentPreview() {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// As admin user, configure comment settings.
$this->drupalLogin($this->admin_user);
@@ -78,7 +80,7 @@ class CommentPreviewTest extends CommentTestBase {
* Tests comment edit, preview, and save.
*/
function testCommentEditPreviewSave() {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval'));
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_OPTIONAL);
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php
index fe4a11c..22132c1 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\comment\Tests;
+use Drupal\Core\Language\Language;
use Drupal\comment\Plugin\Core\Entity\Comment;
use Drupal\simpletest\WebTestBase;
@@ -91,7 +92,7 @@ abstract class CommentTestBase extends WebTestBase {
* array of values to set contact info.
*/
function postComment($node, $comment, $subject = '', $contact = NULL) {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array();
$edit['comment_body[' . $langcode . '][0][value]'] = $comment;
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php
index 6f2837a..3636f91 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php
@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests comment threading.
*/
@@ -23,7 +25,7 @@ class CommentThreadingTest extends CommentTestBase {
* Tests the comment threading.
*/
function testCommentThreading() {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Set comments to have a subject with preview disabled.
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_DISABLED);
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php
index 92be58f..608a8a4 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php
@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests comment token replacement in strings.
*/
@@ -24,7 +26,7 @@ class CommentTokenReplaceTest extends CommentTestBase {
*/
function testCommentTokenReplacement() {
$token_service = \Drupal::token();
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$url_options = array(
'absolute' => TRUE,
'language' => $language_interface,
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php
index 84fbc97..e2e910f 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php
@@ -8,6 +8,7 @@
namespace Drupal\config\Tests;
use Drupal\Core\Entity\EntityMalformedException;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
diff --git a/core/modules/contact/contact.install b/core/modules/contact/contact.install
index d35abe9..e4f2302 100644
--- a/core/modules/contact/contact.install
+++ b/core/modules/contact/contact.install
@@ -6,6 +6,7 @@
*/
use Drupal\Component\Uuid\Uuid;
+use Drupal\Core\Language\Language;
/**
* Implements hook_install().
@@ -75,7 +76,7 @@ function contact_update_8001() {
->set('recipients', explode(',', $category->recipients))
->set('reply', $category->reply)
->set('weight', $category->weight)
- ->set('langcode', LANGUAGE_NOT_SPECIFIED)
+ ->set('langcode', Language::LANGCODE_NOT_SPECIFIED)
->save();
}
diff --git a/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
index 6f73d96..1f56dd1 100644
--- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php
+++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
@@ -8,6 +8,7 @@
namespace Drupal\contact;
use Drupal\Core\Entity\EntityFormController;
+use Drupal\Core\Language\Language;
use Drupal\user\Plugin\Core\Entity\User;
/**
@@ -139,7 +140,7 @@ class MessageFormController extends EntityFormController {
public function save(array $form, array &$form_state) {
global $user;
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$message = $this->entity;
$sender = clone user_load($user->uid);
diff --git a/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php b/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php
index ac3f4a3..dd7712e 100644
--- a/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php
+++ b/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php
@@ -7,6 +7,7 @@
namespace Drupal\datetime\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Datetime\DrupalDateTime;
@@ -85,7 +86,7 @@ class DatetimeFieldTest extends WebTestBase {
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value][date]", '', 'Date element found.');
$this->assertNoFieldByName("{$this->field['field_name']}[$langcode][0][value][time]", '', 'Time element not found.');
@@ -154,7 +155,7 @@ class DatetimeFieldTest extends WebTestBase {
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value][date]", '', 'Date element found.');
$this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value][time]", '', 'Time element found.');
@@ -235,7 +236,7 @@ class DatetimeFieldTest extends WebTestBase {
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
$field_name = $this->field['field_name'];
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-$langcode-0-value-year\"]", NULL, 'Year element found.');
$this->assertOptionSelected("edit-$field_name-$langcode-0-value-year", '', 'No year selected.');
@@ -293,7 +294,7 @@ class DatetimeFieldTest extends WebTestBase {
$date = new DrupalDateTime();
$date_format = 'Y-m-d';
$this->drupalGet('test-entity/add/test_bundle');
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// See if current date is set. We cannot test for the precise time because
// it may be a few seconds between the time the comparison date is created
@@ -327,7 +328,7 @@ class DatetimeFieldTest extends WebTestBase {
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value][date]", '', 'Date element found.');
$this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value][time]", '', 'Time element found.');
diff --git a/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php b/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php
index 9043d8b..e619fff 100644
--- a/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php
+++ b/core/modules/dblog/lib/Drupal/dblog/Tests/DbLogTest.php
@@ -7,6 +7,7 @@
namespace Drupal\dblog\Tests;
+use Drupal\Core\Language\Language;
use Drupal\dblog\Controller\DbLogController;
use Drupal\simpletest\WebTestBase;
use SimpleXMLElement;
@@ -310,7 +311,7 @@ class DbLogTest extends WebTestBase {
// Create a node using the form in order to generate an add content event
// (which is not triggered by drupalCreateNode).
$edit = $this->getContent($type);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$title = $edit["title"];
$this->drupalPost('node/add/' . $type, $edit, t('Save'));
$this->assertResponse(200);
@@ -368,7 +369,7 @@ class DbLogTest extends WebTestBase {
* Random content needed by various node types.
*/
private function getContent($type) {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
switch ($type) {
case 'forum':
$content = array(
@@ -398,7 +399,7 @@ class DbLogTest extends WebTestBase {
* Random content needed by various node types.
*/
private function getContentUpdate($type) {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$content = array(
"body[$langcode][0][value]" => $this->randomName(32),
);
diff --git a/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php b/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php
index 1394285..b988b2c 100644
--- a/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php
+++ b/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php
@@ -7,6 +7,7 @@
namespace Drupal\edit\Tests;
+use Drupal\Core\Language\Language;
use Drupal\edit\EditorSelector;
use Drupal\edit\MetadataGenerator;
use Drupal\edit\Plugin\EditorManager;
@@ -103,7 +104,7 @@ class MetadataGeneratorTest extends EditTestBase {
// Verify metadata for field 1.
$instance_1 = field_info_instance($entity->entityType(), $field_1_name, $entity->bundle());
- $metadata_1 = $this->metadataGenerator->generate($entity, $instance_1, LANGUAGE_NOT_SPECIFIED, 'default');
+ $metadata_1 = $this->metadataGenerator->generate($entity, $instance_1, Language::LANGCODE_NOT_SPECIFIED, 'default');
$expected_1 = array(
'access' => TRUE,
'label' => 'Simple text field',
@@ -114,7 +115,7 @@ class MetadataGeneratorTest extends EditTestBase {
// Verify metadata for field 2.
$instance_2 = field_info_instance($entity->entityType(), $field_2_name, $entity->bundle());
- $metadata_2 = $this->metadataGenerator->generate($entity, $instance_2, LANGUAGE_NOT_SPECIFIED, 'default');
+ $metadata_2 = $this->metadataGenerator->generate($entity, $instance_2, Language::LANGCODE_NOT_SPECIFIED, 'default');
$expected_2 = array(
'access' => TRUE,
'label' => 'Simple number field',
@@ -166,7 +167,7 @@ class MetadataGeneratorTest extends EditTestBase {
// Verify metadata.
$instance = field_info_instance($entity->entityType(), $field_name, $entity->bundle());
- $metadata = $this->metadataGenerator->generate($entity, $instance, LANGUAGE_NOT_SPECIFIED, 'default');
+ $metadata = $this->metadataGenerator->generate($entity, $instance, Language::LANGCODE_NOT_SPECIFIED, 'default');
$expected = array(
'access' => TRUE,
'label' => 'Rich text field',
diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
index 6e8e36f..8cefab6 100644
--- a/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
+++ b/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
@@ -7,6 +7,7 @@
namespace Drupal\editor\Tests;
+use Drupal\Core\Language\Language;
use Drupal\edit\EditorSelector;
use Drupal\edit\MetadataGenerator;
use Drupal\edit\Plugin\EditorManager;
@@ -160,7 +161,7 @@ class EditIntegrationTest extends EditTestBase {
// Verify metadata.
$instance = field_info_instance($entity->entityType(), $this->field_name, $entity->bundle());
- $metadata = $this->metadataGenerator->generate($entity, $instance, LANGUAGE_NOT_SPECIFIED, 'default');
+ $metadata = $this->metadataGenerator->generate($entity, $instance, Language::LANGCODE_NOT_SPECIFIED, 'default');
$expected = array(
'access' => TRUE,
'label' => 'Long text field',
@@ -188,7 +189,7 @@ class EditIntegrationTest extends EditTestBase {
// Verify AJAX response.
$controller = new EditorController();
$request = new Request();
- $response = $controller->getUntransformedText($entity, $this->field_name, LANGUAGE_NOT_SPECIFIED, 'default');
+ $response = $controller->getUntransformedText($entity, $this->field_name, Language::LANGCODE_NOT_SPECIFIED, 'default');
$expected = array(
array(
'command' => 'editorGetUntransformedText',
diff --git a/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php b/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php
index dbb2bed..50badce 100644
--- a/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php
+++ b/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php
@@ -7,6 +7,7 @@
namespace Drupal\email\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -75,7 +76,7 @@ class EmailFieldTest extends WebTestBase {
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', 'Widget found.');
$this->assertRaw('placeholder="example@example.com"');
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php
index ace6f5d..b6bb5aa 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php
@@ -7,6 +7,7 @@
namespace Drupal\entity_reference\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -112,6 +113,6 @@ class EntityReferenceAutoCreateTest extends WebTestBase {
$referencing_nid = key($result);
$referencing_node = node_load($referencing_nid);
- $this->assertEqual($referenced_nid, $referencing_node->test_field[LANGUAGE_NOT_SPECIFIED][0]['target_id'], 'Newly created node is referenced from the referencing node.');
+ $this->assertEqual($referenced_nid, $referencing_node->test_field[Language::LANGCODE_NOT_SPECIFIED][0]['target_id'], 'Newly created node is referenced from the referencing node.');
}
}
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php
index 139250b..8c17fd6 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceItemTest.php
@@ -9,6 +9,7 @@ namespace Drupal\entity_reference\Tests;
use Drupal\Core\Entity\Field\FieldInterface;
use Drupal\Core\Entity\Field\FieldItemInterface;
+use Drupal\Core\Language\Language;
use Drupal\field\Tests\FieldUnitTestBase;
/**
@@ -43,14 +44,14 @@ class EntityReferenceItemTest extends FieldUnitTestBase {
$vocabulary = entity_create('taxonomy_vocabulary', array(
'name' => $this->randomName(),
'vid' => drupal_strtolower($this->randomName()),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$vocabulary->save();
$this->term = entity_create('taxonomy_term', array(
'name' => $this->randomName(),
'vid' => $vocabulary->id(),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$this->term->save();
@@ -90,7 +91,7 @@ class EntityReferenceItemTest extends FieldUnitTestBase {
$term2 = entity_create('taxonomy_term', array(
'name' => $this->randomName(),
'vid' => $this->term->bundle(),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$term2->save();
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php
index cf1c619..9ab172b 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php
@@ -7,6 +7,7 @@
namespace Drupal\entity_reference\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -385,7 +386,7 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
'pid' => 0,
'status' => COMMENT_PUBLISHED,
'subject' => 'Comment Published <&>',
- 'language' => LANGUAGE_NOT_SPECIFIED,
+ 'language' => Language::LANGCODE_NOT_SPECIFIED,
),
'published_unpublished' => array(
'nid' => $nodes['published']->nid,
@@ -394,7 +395,7 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
'pid' => 0,
'status' => COMMENT_NOT_PUBLISHED,
'subject' => 'Comment Unpublished <&>',
- 'language' => LANGUAGE_NOT_SPECIFIED,
+ 'language' => Language::LANGCODE_NOT_SPECIFIED,
),
'unpublished_published' => array(
'nid' => $nodes['unpublished']->nid,
@@ -403,7 +404,7 @@ class EntityReferenceSelectionAccessTest extends WebTestBase {
'pid' => 0,
'status' => COMMENT_NOT_PUBLISHED,
'subject' => 'Comment Published on Unpublished node <&>',
- 'language' => LANGUAGE_NOT_SPECIFIED,
+ 'language' => Language::LANGCODE_NOT_SPECIFIED,
),
);
diff --git a/core/modules/field/field.default.inc b/core/modules/field/field.default.inc
index 27ba32c..ab6b10e 100644
--- a/core/modules/field/field.default.inc
+++ b/core/modules/field/field.default.inc
@@ -12,6 +12,8 @@ use Drupal\Core\Entity\EntityInterface;
* the corresponding field_attach_[operation]() function.
*/
+use Drupal\Core\Language\Language;
+
/**
* Generic field validation handler.
*
@@ -73,9 +75,9 @@ function field_default_validate(EntityInterface $entity, $field, $instance, $lan
*/
function field_default_prepare_translation(EntityInterface $entity, $field, $instance, $langcode, &$items, EntityInterface $source_entity, $source_langcode) {
$field_name = $field['field_name'];
- // If the field is untranslatable keep using LANGUAGE_NOT_SPECIFIED.
- if ($langcode == LANGUAGE_NOT_SPECIFIED) {
- $source_langcode = LANGUAGE_NOT_SPECIFIED;
+ // If the field is untranslatable keep using Language::LANGCODE_NOT_SPECIFIED.
+ if ($langcode == Language::LANGCODE_NOT_SPECIFIED) {
+ $source_langcode = Language::LANGCODE_NOT_SPECIFIED;
}
if (isset($source_entity->{$field_name}[$source_langcode])) {
$items = $source_entity->{$field_name}[$source_langcode];
diff --git a/core/modules/field/field.info.inc b/core/modules/field/field.info.inc
index d4b439e..f69649d 100644
--- a/core/modules/field/field.info.inc
+++ b/core/modules/field/field.info.inc
@@ -6,6 +6,7 @@
*/
use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Language\Language;
use Drupal\field\Plugin\Core\Entity\FieldInstance;
use Drupal\field\Field;
@@ -58,7 +59,7 @@ function field_info_cache_clear() {
* @see _field_info_collate_types_reset()
*/
function _field_info_collate_types() {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
diff --git a/core/modules/field/field.module b/core/modules/field/field.module
index a429eea..a720c4d 100644
--- a/core/modules/field/field.module
+++ b/core/modules/field/field.module
@@ -5,6 +5,7 @@
*/
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Language\Language;
use Drupal\Core\Template\Attribute;
/*
@@ -272,7 +273,7 @@ function field_populate_default_values(EntityInterface $entity, $langcode = NULL
$langcode = $langcode ?: $entity->language()->langcode;
foreach (field_info_instances($entity_type, $entity->bundle()) as $field_name => $instance) {
$field = field_info_field($field_name);
- $field_langcode = field_is_translatable($entity_type, $field) ? $langcode : LANGUAGE_NOT_SPECIFIED;
+ $field_langcode = field_is_translatable($entity_type, $field) ? $langcode : Language::LANGCODE_NOT_SPECIFIED;
// We need to preserve existing values.
if (empty($entity->{$field_name}) || !array_key_exists($field_langcode, $entity->{$field_name})) {
$items = field_get_default_value($entity, $field, $instance, $field_langcode);
diff --git a/core/modules/field/field.multilingual.inc b/core/modules/field/field.multilingual.inc
index 55b364e..6f6e2d6 100644
--- a/core/modules/field/field.multilingual.inc
+++ b/core/modules/field/field.multilingual.inc
@@ -7,6 +7,8 @@ use Drupal\Core\Entity\EntityInterface;
* Functions implementing Field API multilingual support.
*/
+use Drupal\Core\Language\Language;
+
/**
* @defgroup field_language Field Language API
* @{
@@ -19,10 +21,10 @@ use Drupal\Core\Entity\EntityInterface;
* @endcode
* Every field can hold a single or multiple value for each language code
* belonging to the available language codes set:
- * - For untranslatable fields this set only contains LANGUAGE_NOT_SPECIFIED.
+ * - For untranslatable fields this set only contains Language::LANGCODE_NOT_SPECIFIED.
* - For translatable fields this set can contain any language code. By default
* it is the list returned by field_content_languages(), which contains all
- * installed languages with the addition of LANGUAGE_NOT_SPECIFIED. This
+ * installed languages with the addition of Language::LANGCODE_NOT_SPECIFIED. This
* default can be altered by modules implementing
* hook_field_available_languages_alter().
*
@@ -67,7 +69,7 @@ use Drupal\Core\Entity\EntityInterface;
* Collects the available language codes for the given entity type and field.
*
* If the given field has language support enabled, an array of available
- * language codes will be returned, otherwise only LANGUAGE_NOT_SPECIFIED will
+ * language codes will be returned, otherwise only Language::LANGCODE_NOT_SPECIFIED will
* be returned. Since the default value for a 'translatable' entity property is
* FALSE, we ensure that only entities that are able to handle translations
* actually get translatable fields.
@@ -90,7 +92,7 @@ function field_available_languages($entity_type, $field) {
if (!isset($field_langcodes[$entity_type][$field_name])) {
// If the field has language support enabled we retrieve an (alterable) list
- // of enabled languages, otherwise we return just LANGUAGE_NOT_SPECIFIED.
+ // of enabled languages, otherwise we return just Language::LANGCODE_NOT_SPECIFIED.
if (field_is_translatable($entity_type, $field)) {
$langcodes = field_content_languages();
// Let other modules alter the available languages.
@@ -99,7 +101,7 @@ function field_available_languages($entity_type, $field) {
$field_langcodes[$entity_type][$field_name] = $langcodes;
}
else {
- $field_langcodes[$entity_type][$field_name] = array(LANGUAGE_NOT_SPECIFIED);
+ $field_langcodes[$entity_type][$field_name] = array(Language::LANGCODE_NOT_SPECIFIED);
}
}
@@ -147,7 +149,7 @@ function _field_language_suggestion($available_langcodes, $langcode_suggestion,
* An array of language codes.
*/
function field_content_languages() {
- return array_keys(language_list(LANGUAGE_ALL));
+ return array_keys(language_list(Language::STATE_ALL));
}
/**
@@ -219,7 +221,7 @@ function field_valid_language($langcode, $default = TRUE) {
if (in_array($langcode, $languages)) {
return $langcode;
}
- return $default ? language_default()->langcode : language(LANGUAGE_TYPE_CONTENT)->langcode;
+ return $default ? language_default()->langcode : language(Language::TYPE_CONTENT)->langcode;
}
/**
@@ -230,7 +232,7 @@ function field_valid_language($langcode, $default = TRUE) {
* requested language code and the actual data available in the fields
* themselves.
* If there is no registered translation handler for the given entity type, the
- * display language code to be used is just LANGUAGE_NOT_SPECIFIED, as no other
+ * display language code to be used is just Language::LANGCODE_NOT_SPECIFIED, as no other
* language code is allowed by field_available_languages().
*
* If translation handlers are found, we let modules provide alternative display
@@ -271,9 +273,9 @@ function field_language(EntityInterface $entity, $field_name = NULL, $langcode =
else {
// If the field has a value for one of the locked languages, then use
// that language for display. If not, the default one will be
- // LANGUAGE_NOT_SPECIFIED.
- $display_langcode[$instance['field_name']] = LANGUAGE_NOT_SPECIFIED;
- foreach (language_list(LANGUAGE_LOCKED) as $language_locked) {
+ // Language::LANGCODE_NOT_SPECIFIED.
+ $display_langcode[$instance['field_name']] = Language::LANGCODE_NOT_SPECIFIED;
+ foreach (language_list(Language::STATE_LOCKED) as $language_locked) {
if (isset($entity->{$instance['field_name']}[$language_locked->langcode])) {
$display_langcode[$instance['field_name']] = $language_locked->langcode;
break;
diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
index 19fe3e1..c393b2e 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Plugin\views\field;
+use Drupal\Core\Language\Language;
use Drupal\Core\Entity\EntityInterface;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
@@ -185,11 +186,11 @@ class Field extends FieldPluginBase {
$field = $this->field_info;
if (field_is_translatable($entity_type, $field) && !empty($this->view->display_handler->options['field_langcode_add_to_query'])) {
$column = $this->tableAlias . '.langcode';
- // By the same reason as field_language the field might be LANGUAGE_NOT_SPECIFIED in reality so allow it as well.
+ // By the same reason as field_language the field might be Language::LANGCODE_NOT_SPECIFIED in reality so allow it as well.
// @see this::field_langcode()
$default_langcode = language_default()->langcode;
$langcode = str_replace(array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'),
- array(drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode, $default_langcode),
+ array(drupal_container()->get(Language::TYPE_CONTENT)->langcode, $default_langcode),
$this->view->display_handler->options['field_langcode']);
$placeholder = $this->placeholder();
$langcode_fallback_candidates = array($langcode);
@@ -198,7 +199,7 @@ class Field extends FieldPluginBase {
$langcode_fallback_candidates = array_merge($langcode_fallback_candidates, language_fallback_get_candidates());
}
else {
- $langcode_fallback_candidates[] = LANGUAGE_NOT_SPECIFIED;
+ $langcode_fallback_candidates[] = Language::LANGCODE_NOT_SPECIFIED;
}
$this->query->add_where_expression(0, "$column IN($placeholder) OR $column IS NULL", array($placeholder => $langcode_fallback_candidates));
}
@@ -830,11 +831,11 @@ class Field extends FieldPluginBase {
if (field_is_translatable($entity->entityType(), $this->field_info)) {
$default_langcode = language_default()->langcode;
$langcode = str_replace(array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'),
- array(drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode, $default_langcode),
+ array(drupal_container()->get(Language::TYPE_CONTENT)->langcode, $default_langcode),
$this->view->display_handler->options['field_language']);
// Give the Field Language API a chance to fallback to a different language
- // (or LANGUAGE_NOT_SPECIFIED), in case the field has no data for the selected language.
+ // (or Language::LANGCODE_NOT_SPECIFIED), in case the field has no data for the selected language.
// field_view_field() does this as well, but since the returned language code
// is used before calling it, the fallback needs to happen explicitly.
$langcode = field_language($entity, $this->field_info['field_name'], $langcode);
@@ -842,7 +843,7 @@ class Field extends FieldPluginBase {
return $langcode;
}
else {
- return LANGUAGE_NOT_SPECIFIED;
+ return Language::LANGCODE_NOT_SPECIFIED;
}
}
diff --git a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
index 7ff4ff9..d27bd7d 100644
--- a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
@@ -9,6 +9,8 @@ namespace Drupal\field\Tests;
use Drupal\field\Plugin\Core\Entity\FieldInstance;
+use Drupal\Core\Language\Language;
+
/**
* Unit test class for field bulk delete and batch purge functionality.
*/
@@ -124,7 +126,7 @@ class BulkDeleteTest extends FieldUnitTestBase {
for ($i = 0; $i < 10; $i++) {
$entity = field_test_create_entity($id, $id, $bundle);
foreach ($this->fields as $field) {
- $entity->{$field['field_name']}[LANGUAGE_NOT_SPECIFIED] = $this->_generateTestFieldValues($field['cardinality']);
+ $entity->{$field['field_name']}[Language::LANGCODE_NOT_SPECIFIED] = $this->_generateTestFieldValues($field['cardinality']);
}
$entity->save();
$id++;
diff --git a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
index 8f9bdf9..7960f82 100644
--- a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Tests;
+use Drupal\Core\Language\Language;
use Drupal\field\FieldException;
class CrudTest extends FieldUnitTestBase {
@@ -329,7 +330,7 @@ class CrudTest extends FieldUnitTestBase {
// Save an entity with data for the field
$entity = field_test_create_entity(0, 0, $instance['bundle']);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$values[0]['value'] = mt_rand(1, 127);
$entity->{$field['field_name']}[$langcode] = $values;
$entity_type = 'test_entity';
@@ -383,17 +384,17 @@ class CrudTest extends FieldUnitTestBase {
$entity = field_test_create_entity($id, $id, $instance['bundle']);
// Fill in the entity with more values than $cardinality.
for ($i = 0; $i < 20; $i++) {
- $entity->field_update[LANGUAGE_NOT_SPECIFIED][$i]['value'] = $i;
+ $entity->field_update[Language::LANGCODE_NOT_SPECIFIED][$i]['value'] = $i;
}
// Save the entity.
field_attach_insert($entity);
// Load back and assert there are $cardinality number of values.
$entity = field_test_create_entity($id, $id, $instance['bundle']);
field_attach_load('test_entity', array($id => $entity));
- $this->assertEqual(count($entity->field_update[LANGUAGE_NOT_SPECIFIED]), $field['cardinality'], 'Cardinality is kept');
+ $this->assertEqual(count($entity->field_update[Language::LANGCODE_NOT_SPECIFIED]), $field['cardinality'], 'Cardinality is kept');
// Now check the values themselves.
for ($delta = 0; $delta < $cardinality; $delta++) {
- $this->assertEqual($entity->field_update[LANGUAGE_NOT_SPECIFIED][$delta]['value'], $delta, 'Value is kept');
+ $this->assertEqual($entity->field_update[Language::LANGCODE_NOT_SPECIFIED][$delta]['value'], $delta, 'Value is kept');
}
// Increase $cardinality and set the field cardinality to the new value.
$field['cardinality'] = ++$cardinality;
diff --git a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
index 39d9594..9ca988e 100644
--- a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
@@ -7,6 +7,8 @@
namespace Drupal\field\Tests;
+use Drupal\Core\Language\Language;
+
class DisplayApiTest extends FieldUnitTestBase {
public static function getInfo() {
@@ -67,7 +69,7 @@ class DisplayApiTest extends FieldUnitTestBase {
$this->values = $this->_generateTestFieldValues($this->cardinality);
$this->entity = field_test_create_entity();
$this->is_new = TRUE;
- $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED] = $this->values;
+ $this->entity->{$this->field_name}[Language::LANGCODE_NOT_SPECIFIED] = $this->values;
field_test_entity_save($this->entity);
}
@@ -99,7 +101,7 @@ class DisplayApiTest extends FieldUnitTestBase {
$setting = $display['settings']['test_formatter_setting_multiple'];
$this->assertNoText($this->label, 'Label was not displayed.');
$this->assertText('field_test_field_attach_view_alter', 'Alter fired, display passed.');
- $this->assertText('field language is ' . LANGUAGE_NOT_SPECIFIED, 'Language is placed onto the context.');
+ $this->assertText('field language is ' . Language::LANGCODE_NOT_SPECIFIED, 'Language is placed onto the context.');
$array = array();
foreach ($this->values as $delta => $value) {
$array[] = $delta . ':' . $value['value'];
@@ -153,7 +155,7 @@ class DisplayApiTest extends FieldUnitTestBase {
$settings = field_info_formatter_settings('field_test_default');
$setting = $settings['test_formatter_setting'];
foreach ($this->values as $delta => $value) {
- $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta];
+ $item = $this->entity->{$this->field_name}[Language::LANGCODE_NOT_SPECIFIED][$delta];
$output = field_view_value($this->entity, $this->field_name, $item);
$this->content = drupal_render($output);
$this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
@@ -169,7 +171,7 @@ class DisplayApiTest extends FieldUnitTestBase {
$setting = $display['settings']['test_formatter_setting_multiple'];
$array = array();
foreach ($this->values as $delta => $value) {
- $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta];
+ $item = $this->entity->{$this->field_name}[Language::LANGCODE_NOT_SPECIFIED][$delta];
$output = field_view_value($this->entity, $this->field_name, $item, $display);
$this->content = drupal_render($output);
$this->assertText($setting . '|0:' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
@@ -185,7 +187,7 @@ class DisplayApiTest extends FieldUnitTestBase {
$setting = $display['settings']['test_formatter_setting_additional'];
$array = array();
foreach ($this->values as $delta => $value) {
- $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta];
+ $item = $this->entity->{$this->field_name}[Language::LANGCODE_NOT_SPECIFIED][$delta];
$output = field_view_value($this->entity, $this->field_name, $item, $display);
$this->content = drupal_render($output);
$this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
@@ -195,7 +197,7 @@ class DisplayApiTest extends FieldUnitTestBase {
// used.
$setting = $this->display_options['teaser']['settings']['test_formatter_setting'];
foreach ($this->values as $delta => $value) {
- $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta];
+ $item = $this->entity->{$this->field_name}[Language::LANGCODE_NOT_SPECIFIED][$delta];
$output = field_view_value($this->entity, $this->field_name, $item, 'teaser');
$this->content = drupal_render($output);
$this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
@@ -205,7 +207,7 @@ class DisplayApiTest extends FieldUnitTestBase {
// are used.
$setting = $this->display_options['default']['settings']['test_formatter_setting'];
foreach ($this->values as $delta => $value) {
- $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta];
+ $item = $this->entity->{$this->field_name}[Language::LANGCODE_NOT_SPECIFIED][$delta];
$output = field_view_value($this->entity, $this->field_name, $item, 'unknown_view_mode');
$this->content = drupal_render($output);
$this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
@@ -234,7 +236,7 @@ class DisplayApiTest extends FieldUnitTestBase {
$this->assertNoText($display['settings']['test_empty_string']);
// Now remove the values from the test field and retest.
- $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED] = array();
+ $this->entity->{$this->field_name}[Language::LANGCODE_NOT_SPECIFIED] = array();
field_test_entity_save($this->entity);
$output = field_view_field($this->entity, $this->field_name, $display);
$view = drupal_render($output);
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
index 4bc03be..d16b25a 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Tests;
+use Drupal\Core\Language\Language;
use Drupal\field\FieldValidationException;
/**
@@ -34,7 +35,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
$entity_type = 'test_entity';
$entity_init = field_test_create_entity();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$options = array('field_name' => $this->field_name_2);
// Populate values to be displayed.
@@ -181,7 +182,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
*/
function testFieldAttachPrepareViewMultiple() {
$entity_type = 'test_entity';
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Set the instance to be hidden.
$display = entity_get_display('test_entity', 'test_bundle', 'full')
@@ -237,7 +238,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
function testFieldAttachCache() {
// Initialize random values and a test entity.
$entity_init = field_test_create_entity(1, 1, $this->instance['bundle']);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$values = $this->_generateTestFieldValues($this->field['cardinality']);
// Non-cacheable entity type.
@@ -340,7 +341,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
$entity_type = 'test_entity';
$entity = field_test_create_entity(0, 0, $this->instance['bundle']);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Set up all but one values of the first field to generate errors.
$values = array();
@@ -432,7 +433,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
$entity_type = 'test_entity';
$entity = field_test_create_entity(0, 0, $this->instance['bundle']);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// When generating form for all fields.
$form = array();
@@ -474,7 +475,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
$entity_type = 'test_entity';
$entity_init = field_test_create_entity(0, 0, $this->instance['bundle']);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Build the form for all fields.
$form = array();
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
index b9e87c7..7192067 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
@@ -7,6 +7,8 @@
namespace Drupal\field\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Unit test class for storage-related field_attach_* functions.
*
@@ -38,7 +40,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
// field_test_field_load() in field_test.module).
$this->instance['settings']['test_hook_field_load'] = TRUE;
field_update_instance($this->instance);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$entity_type = 'test_entity';
$values = array();
@@ -95,7 +97,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
*/
function testFieldAttachLoadMultiple() {
$entity_type = 'test_entity';
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Define 2 bundles.
$bundles = array(
@@ -171,7 +173,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
*/
function testFieldAttachSaveLoadDifferentStorage() {
$entity_type = 'test_entity';
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Create two fields using different storage backends, and their instances.
$fields = array(
@@ -265,7 +267,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
function testFieldAttachSaveMissingData() {
$entity_type = 'test_entity';
$entity_init = field_test_create_entity();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Insert: Field is missing.
$entity = clone($entity_init);
@@ -348,7 +350,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
// Verify that fields are populated with default values.
$entity_type = 'test_entity';
$entity_init = field_test_create_entity();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$default = field_test_default_value($entity_init, $this->field, $this->instance);
$this->assertEqual($entity_init->{$this->field_name}[$langcode], $default, 'Default field value correctly populated.');
@@ -383,7 +385,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
*/
function testFieldAttachDelete() {
$entity_type = 'test_entity';
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$rev[0] = field_test_create_entity(0, 0, $this->instance['bundle']);
// Create revision 0
@@ -447,7 +449,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
// Save an entity with data in the field.
$entity = field_test_create_entity(0, 0, $this->instance['bundle']);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$values = $this->_generateTestFieldValues($this->field['cardinality']);
$entity->{$this->field_name}[$langcode] = $values;
$entity_type = 'test_entity';
@@ -500,7 +502,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
// Save an entity with data for both fields
$entity = field_test_create_entity(0, 0, $this->instance['bundle']);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$values = $this->_generateTestFieldValues($this->field['cardinality']);
$entity->{$this->field_name}[$langcode] = $values;
$entity->{$field_name}[$langcode] = $this->_generateTestFieldValues(1);
diff --git a/core/modules/field/lib/Drupal/field/Tests/FormTest.php b/core/modules/field/lib/Drupal/field/Tests/FormTest.php
index 3d2aac3..e2fbac6 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FormTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FormTest.php
@@ -7,6 +7,8 @@
namespace Drupal\field\Tests;
+use Drupal\Core\Language\Language;
+
class FormTest extends FieldTestBase {
/**
@@ -55,7 +57,7 @@ class FormTest extends FieldTestBase {
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name)
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
@@ -124,7 +126,7 @@ class FormTest extends FieldTestBase {
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name)
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
@@ -151,7 +153,7 @@ class FormTest extends FieldTestBase {
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name)
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Submit with missing required value.
$edit = array();
@@ -192,7 +194,7 @@ class FormTest extends FieldTestBase {
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name)
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Display creation form -> 1 widget.
$this->drupalGet('test-entity/add/test_bundle');
@@ -275,7 +277,7 @@ class FormTest extends FieldTestBase {
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name)
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Add a required radio field.
field_create_field(array(
@@ -322,7 +324,7 @@ class FormTest extends FieldTestBase {
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name)
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Display creation form -> 1 widget.
$this->drupalGet('test-entity/add/test_bundle');
@@ -386,7 +388,7 @@ class FormTest extends FieldTestBase {
'type' => 'test_field_widget_multiple',
))
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
@@ -447,7 +449,7 @@ class FormTest extends FieldTestBase {
->setComponent($field_name_no_access)
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Test that the form structure includes full information for each delta
// apart from #access.
@@ -516,14 +518,14 @@ class FormTest extends FieldTestBase {
// Create two entities.
$entity_1 = field_test_create_entity(1, 1);
$entity_1->is_new = TRUE;
- $entity_1->field_single[LANGUAGE_NOT_SPECIFIED][] = array('value' => 0);
- $entity_1->field_unlimited[LANGUAGE_NOT_SPECIFIED][] = array('value' => 1);
+ $entity_1->field_single[Language::LANGCODE_NOT_SPECIFIED][] = array('value' => 0);
+ $entity_1->field_unlimited[Language::LANGCODE_NOT_SPECIFIED][] = array('value' => 1);
field_test_entity_save($entity_1);
$entity_2 = field_test_create_entity(2, 2);
$entity_2->is_new = TRUE;
- $entity_2->field_single[LANGUAGE_NOT_SPECIFIED][] = array('value' => 10);
- $entity_2->field_unlimited[LANGUAGE_NOT_SPECIFIED][] = array('value' => 11);
+ $entity_2->field_single[Language::LANGCODE_NOT_SPECIFIED][] = array('value' => 10);
+ $entity_2->field_unlimited[Language::LANGCODE_NOT_SPECIFIED][] = array('value' => 11);
field_test_entity_save($entity_2);
// Display the 'combined form'.
@@ -546,10 +548,10 @@ class FormTest extends FieldTestBase {
field_cache_clear();
$entity_1 = field_test_create_entity(1);
$entity_2 = field_test_create_entity(2);
- $this->assertFieldValues($entity_1, 'field_single', LANGUAGE_NOT_SPECIFIED, array(1));
- $this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NOT_SPECIFIED, array(2, 3));
- $this->assertFieldValues($entity_2, 'field_single', LANGUAGE_NOT_SPECIFIED, array(11));
- $this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NOT_SPECIFIED, array(12, 13));
+ $this->assertFieldValues($entity_1, 'field_single', Language::LANGCODE_NOT_SPECIFIED, array(1));
+ $this->assertFieldValues($entity_1, 'field_unlimited', Language::LANGCODE_NOT_SPECIFIED, array(2, 3));
+ $this->assertFieldValues($entity_2, 'field_single', Language::LANGCODE_NOT_SPECIFIED, array(11));
+ $this->assertFieldValues($entity_2, 'field_unlimited', Language::LANGCODE_NOT_SPECIFIED, array(12, 13));
// Submit invalid values and check that errors are reported on the
// correct widgets.
@@ -577,8 +579,8 @@ class FormTest extends FieldTestBase {
);
$this->drupalPost('test-entity/nested/1/2', $edit, t('Save'));
field_cache_clear();
- $this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NOT_SPECIFIED, array(3, 2));
- $this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NOT_SPECIFIED, array(13, 12));
+ $this->assertFieldValues($entity_1, 'field_unlimited', Language::LANGCODE_NOT_SPECIFIED, array(3, 2));
+ $this->assertFieldValues($entity_2, 'field_unlimited', Language::LANGCODE_NOT_SPECIFIED, array(13, 12));
// Test the 'add more' buttons. Only Ajax submission is tested, because
// the two 'add more' buttons present in the form have the same #value,
@@ -604,8 +606,8 @@ class FormTest extends FieldTestBase {
// Save the form and check values are saved correclty.
$this->drupalPost(NULL, array(), t('Save'));
field_cache_clear();
- $this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NOT_SPECIFIED, array(3, 2));
- $this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NOT_SPECIFIED, array(13, 14, 15));
+ $this->assertFieldValues($entity_1, 'field_unlimited', Language::LANGCODE_NOT_SPECIFIED, array(3, 2));
+ $this->assertFieldValues($entity_2, 'field_unlimited', Language::LANGCODE_NOT_SPECIFIED, array(13, 14, 15));
}
/**
@@ -623,7 +625,7 @@ class FormTest extends FieldTestBase {
'type' => 'hidden',
))
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Display the entity creation form.
$this->drupalGet('test-entity/add/test_bundle');
diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
index 24b7063..4aa9613 100644
--- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
@@ -97,7 +97,7 @@ class TranslationTest extends FieldUnitTestBase {
$this->field['translatable'] = FALSE;
field_update_field($this->field);
$available_langcodes = field_available_languages($this->entity_type, $this->field);
- $this->assertTrue(count($available_langcodes) == 1 && $available_langcodes[0] === LANGUAGE_NOT_SPECIFIED, 'For untranslatable fields only LANGUAGE_NOT_SPECIFIED is available.');
+ $this->assertTrue(count($available_langcodes) == 1 && $available_langcodes[0] === Language::LANGCODE_NOT_SPECIFIED, 'For untranslatable fields only Language::LANGCODE_NOT_SPECIFIED is available.');
}
/**
@@ -343,12 +343,12 @@ class TranslationTest extends FieldUnitTestBase {
$entity->{$field_name}[$langcode] = $this->_generateTestFieldValues($field['cardinality']);
// If the langcode is one of the locked languages, then that one
// will also be used for display. Otherwise, the default one should be
- // used, which is LANGUAGE_NOT_SPECIFIED.
+ // used, which is Language::LANGCODE_NOT_SPECIFIED.
if (language_is_locked($langcode)) {
$locked_languages[$field_name] = $langcode;
}
else {
- $locked_languages[$field_name] = LANGUAGE_NOT_SPECIFIED;
+ $locked_languages[$field_name] = Language::LANGCODE_NOT_SPECIFIED;
}
}
diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php
index a32cc81..786f1b4 100644
--- a/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php
@@ -78,7 +78,7 @@ class TranslationWebTest extends FieldTestBase {
$eid = 1;
$entity = field_test_create_entity($eid, $eid, $this->instance['bundle']);
$available_langcodes = array_flip(field_available_languages($this->entity_type, $this->field));
- unset($available_langcodes[LANGUAGE_NOT_SPECIFIED]);
+ unset($available_langcodes[Language::LANGCODE_NOT_SPECIFIED]);
$field_name = $this->field['field_name'];
// Store the field translations.
diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php
index 6d1975e..b494a5a 100644
--- a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php
@@ -7,6 +7,7 @@
namespace Drupal\field\Tests\Views;
+use Drupal\Core\Language\Language;
use Drupal\views\ViewExecutable;
/**
@@ -104,7 +105,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
for ($key = 0; $key < 2; $key++) {
$field = $this->fields[$key];
$rendered_field = $view->style_plugin->get_field($i, $field['field_name']);
- $expected_field = $this->nodes[$i]->{$field['field_name']}[LANGUAGE_NOT_SPECIFIED][0]['value'];
+ $expected_field = $this->nodes[$i]->{$field['field_name']}[Language::LANGCODE_NOT_SPECIFIED][0]['value'];
$this->assertEqual($rendered_field, $expected_field);
}
}
@@ -143,7 +144,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin->get_field($i, $field_name);
$items = array();
- $pure_items = $this->nodes[$i]->{$field_name}[LANGUAGE_NOT_SPECIFIED];
+ $pure_items = $this->nodes[$i]->{$field_name}[Language::LANGCODE_NOT_SPECIFIED];
$pure_items = array_splice($pure_items, 0, 3);
foreach ($pure_items as $j => $item) {
$items[] = $pure_items[$j]['value'];
@@ -166,7 +167,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin->get_field($i, $field_name);
$items = array();
- $pure_items = $this->nodes[$i]->{$field_name}[LANGUAGE_NOT_SPECIFIED];
+ $pure_items = $this->nodes[$i]->{$field_name}[Language::LANGCODE_NOT_SPECIFIED];
$pure_items = array_splice($pure_items, 1, 3);
foreach ($pure_items as $j => $item) {
$items[] = $pure_items[$j]['value'];
@@ -186,7 +187,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin->get_field($i, $field_name);
$items = array();
- $pure_items = $this->nodes[$i]->{$field_name}[LANGUAGE_NOT_SPECIFIED];
+ $pure_items = $this->nodes[$i]->{$field_name}[Language::LANGCODE_NOT_SPECIFIED];
array_splice($pure_items, 0, -3);
$pure_items = array_reverse($pure_items);
foreach ($pure_items as $j => $item) {
@@ -207,7 +208,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin->get_field($i, $field_name);
$items = array();
- $pure_items = $this->nodes[$i]->{$field_name}[LANGUAGE_NOT_SPECIFIED];
+ $pure_items = $this->nodes[$i]->{$field_name}[Language::LANGCODE_NOT_SPECIFIED];
$items[] = $pure_items[0]['value'];
$items[] = $pure_items[4]['value'];
$this->assertEqual($rendered_field, implode(', ', $items), 'Take sure that the amount of items are limited.');
@@ -225,7 +226,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin->get_field($i, $field_name);
$items = array();
- $pure_items = $this->nodes[$i]->{$field_name}[LANGUAGE_NOT_SPECIFIED];
+ $pure_items = $this->nodes[$i]->{$field_name}[Language::LANGCODE_NOT_SPECIFIED];
$pure_items = array_splice($pure_items, 0, 3);
foreach ($pure_items as $j => $item) {
$items[] = $pure_items[$j]['value'];
diff --git a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
index b7cf45e..3598446 100644
--- a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
+++ b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
@@ -8,6 +8,7 @@
namespace Drupal\field_sql_storage\Tests;
use Drupal\Core\Database\Database;
+use Drupal\Core\Language\Language;
use Drupal\field\FieldException;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
use PDO;
@@ -60,7 +61,7 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
function testFieldAttachLoad() {
$entity_type = 'test_entity';
$eid = 0;
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$columns = array('entity_type', 'entity_id', 'revision_id', 'delta', 'langcode', $this->field_name . '_value');
@@ -129,7 +130,7 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
function testFieldAttachInsertAndUpdate() {
$entity_type = 'test_entity';
$entity = field_test_create_entity(0, 0, $this->instance['bundle']);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Test insert.
$values = array();
@@ -210,7 +211,7 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
function testFieldAttachSaveMissingData() {
$entity_type = 'test_entity';
$entity = field_test_create_entity(0, 0, $this->instance['bundle']);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Insert: Field is missing
field_attach_insert($entity);
@@ -309,7 +310,7 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
$instance = array('field_name' => 'decimal52', 'entity_type' => 'test_entity', 'bundle' => 'test_bundle');
$instance = field_create_instance($instance);
$entity = field_test_create_entity(0, 0, $instance['bundle']);
- $entity->decimal52[LANGUAGE_NOT_SPECIFIED][0]['value'] = '1.235';
+ $entity->decimal52[Language::LANGCODE_NOT_SPECIFIED][0]['value'] = '1.235';
$entity->save();
// Attempt to update the field in a way that would work without data.
@@ -369,7 +370,7 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
// Add data so the table cannot be dropped.
$entity = field_test_create_entity(1, 1, $instance['bundle']);
- $entity->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['value'] = 'field data';
+ $entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['value'] = 'field data';
$entity->save();
// Add an index
@@ -390,7 +391,7 @@ class FieldSqlStorageTest extends EntityUnitTestBase {
// Verify that the tables were not dropped.
$entity = field_test_create_entity(1, 1, $instance['bundle']);
field_attach_load('test_entity', array(1 => $entity));
- $this->assertEqual($entity->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['value'], 'field data', t("Index changes performed without dropping the tables"));
+ $this->assertEqual($entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['value'], 'field data', t("Index changes performed without dropping the tables"));
}
/**
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php
index d8788a7..b37ddc3 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php
@@ -9,6 +9,7 @@ namespace Drupal\field_ui\Form;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\ControllerInterface;
+use Drupal\Core\Language\Language;
use Drupal\field\Plugin\Core\Entity\FieldInstance;
use Drupal\field\Plugin\Type\Widget\WidgetPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -178,27 +179,27 @@ class FieldInstanceEditForm implements FormInterface, ControllerInterface {
// Extract the 'default value'.
$items = array();
- $entity_form_display->getWidget($this->instance->getField()->id)->extractFormValues($entity, LANGUAGE_NOT_SPECIFIED, $items, $element, $form_state);
+ $entity_form_display->getWidget($this->instance->getField()->id)->extractFormValues($entity, Language::LANGCODE_NOT_SPECIFIED, $items, $element, $form_state);
// Grab the field definition from $form_state.
- $field_state = field_form_get_state($element['#parents'], $field_name, LANGUAGE_NOT_SPECIFIED, $form_state);
+ $field_state = field_form_get_state($element['#parents'], $field_name, Language::LANGCODE_NOT_SPECIFIED, $form_state);
$field = $field_state['field'];
// Validate the value.
$errors = array();
$function = $field['module'] . '_field_validate';
if (function_exists($function)) {
- $function(NULL, $field, $this->instance, LANGUAGE_NOT_SPECIFIED, $items, $errors);
+ $function(NULL, $field, $this->instance, Language::LANGCODE_NOT_SPECIFIED, $items, $errors);
}
// Report errors.
- if (isset($errors[$field_name][LANGUAGE_NOT_SPECIFIED])) {
+ if (isset($errors[$field_name][Language::LANGCODE_NOT_SPECIFIED])) {
// Store reported errors in $form_state.
- $field_state['errors'] = $errors[$field_name][LANGUAGE_NOT_SPECIFIED];
- field_form_set_state($element['#parents'], $field_name, LANGUAGE_NOT_SPECIFIED, $form_state, $field_state);
+ $field_state['errors'] = $errors[$field_name][Language::LANGCODE_NOT_SPECIFIED];
+ field_form_set_state($element['#parents'], $field_name, Language::LANGCODE_NOT_SPECIFIED, $form_state, $field_state);
// Assign reported errors to the correct form element.
- $entity_form_display->getWidget($this->instance->getField()->id)->flagErrors($entity, LANGUAGE_NOT_SPECIFIED, $items, $element, $form_state);
+ $entity_form_display->getWidget($this->instance->getField()->id)->flagErrors($entity, Language::LANGCODE_NOT_SPECIFIED, $items, $element, $form_state);
}
}
}
@@ -217,7 +218,7 @@ class FieldInstanceEditForm implements FormInterface, ControllerInterface {
// Extract field values.
$items = array();
- $entity_form_display->getWidget($this->instance->getField()->id)->extractFormValues($entity, LANGUAGE_NOT_SPECIFIED, $items, $element, $form_state);
+ $entity_form_display->getWidget($this->instance->getField()->id)->extractFormValues($entity, Language::LANGCODE_NOT_SPECIFIED, $items, $element, $form_state);
$this->instance['default_value'] = $items ? $items : NULL;
}
@@ -297,7 +298,7 @@ class FieldInstanceEditForm implements FormInterface, ControllerInterface {
if (!empty($this->instance['default_value'])) {
$items = (array) $this->instance['default_value'];
}
- $element += $entity_form_display->getWidget($this->instance->getField()->id)->form($entity, LANGUAGE_NOT_SPECIFIED, $items, $element, $form_state);
+ $element += $entity_form_display->getWidget($this->instance->getField()->id)->form($entity, Language::LANGCODE_NOT_SPECIFIED, $items, $element, $form_state);
return $element;
}
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php
index 2d3fb98..c4614ac 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\field_ui\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -38,7 +39,7 @@ abstract class FieldUiTestBase extends WebTestBase {
'name' => $this->randomName(),
'description' => $this->randomName(),
'vid' => drupal_strtolower($this->randomName()),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'help' => '',
'nodes' => array('article' => 'article'),
'weight' => mt_rand(0, 10),
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
index 5b84d0e..3b49b57 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
@@ -7,6 +7,8 @@
namespace Drupal\field_ui\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests the functionality of the 'Manage fields' screen.
*/
@@ -35,7 +37,7 @@ class ManageFieldsTest extends FieldUiTestBase {
$vocabulary = entity_create('taxonomy_vocabulary', array(
'name' => 'Tags',
'vid' => 'tags',
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$vocabulary->save();
@@ -264,7 +266,7 @@ class ManageFieldsTest extends FieldUiTestBase {
->setComponent($field_name)
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$admin_path = 'admin/structure/types/manage/' . $this->type . '/fields/' . $instance->id();
$element_id = "edit-$field_name-$langcode-0-value";
$element_name = "{$field_name}[$langcode][0][value]";
diff --git a/core/modules/file/lib/Drupal/file/FileStorageController.php b/core/modules/file/lib/Drupal/file/FileStorageController.php
index fb72a5d..d3ca601 100644
--- a/core/modules/file/lib/Drupal/file/FileStorageController.php
+++ b/core/modules/file/lib/Drupal/file/FileStorageController.php
@@ -9,6 +9,7 @@ namespace Drupal\file;
use Drupal\Core\Entity\DatabaseStorageController;
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Language\Language;
/**
* File storage controller for files.
@@ -42,7 +43,7 @@ class FileStorageController extends DatabaseStorageController {
// neutral more often than language dependent. Until we have better
// flexible settings.
// @todo See http://drupal.org/node/258785 and followups.
- $entity->langcode = LANGUAGE_NOT_SPECIFIED;
+ $entity->langcode = Language::LANGCODE_NOT_SPECIFIED;
}
}
diff --git a/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php b/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php
index 6a0e80d..1390cc7 100644
--- a/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php
+++ b/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php
@@ -10,6 +10,7 @@ namespace Drupal\file\Plugin\Core\Entity;
use Drupal\Core\Entity\Entity;
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\Annotation\Translation;
+use Drupal\Core\Language\Language;
use Drupal\file\FileInterface;
/**
@@ -52,7 +53,7 @@ class File extends Entity implements FileInterface {
*
* @var string
*/
- public $langcode = LANGUAGE_NOT_SPECIFIED;
+ public $langcode = Language::LANGCODE_NOT_SPECIFIED;
/**
* The uid of the user who is associated with the file.
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php
index d50ecb6..ebce0b1 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php
@@ -7,6 +7,8 @@
namespace Drupal\file\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests that formatters are working properly.
*/
@@ -58,12 +60,12 @@ class FileFieldDisplayTest extends FileFieldTestBase {
// Check that the default formatter is displaying with the file name.
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$default_output = theme('file_link', array('file' => $node_file));
$this->assertRaw($default_output, t('Default formatter displaying correctly on full node view.'));
// Turn the "display" option off and check that the file is no longer displayed.
- $edit = array($field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][display]' => FALSE);
+ $edit = array($field_name . '[' . Language::LANGCODE_NOT_SPECIFIED . '][0][display]' => FALSE);
$this->drupalPost('node/' . $nid . '/edit', $edit, t('Save and keep published'));
$this->assertNoRaw($default_output, t('Field is hidden when "display" option is unchecked.'));
@@ -71,8 +73,8 @@ class FileFieldDisplayTest extends FileFieldTestBase {
// Add a description and make sure that it is displayed.
$description = $this->randomName();
$edit = array(
- $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][description]' => $description,
- $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][display]' => TRUE,
+ $field_name . '[' . Language::LANGCODE_NOT_SPECIFIED . '][0][description]' => $description,
+ $field_name . '[' . Language::LANGCODE_NOT_SPECIFIED . '][0][display]' => TRUE,
);
$this->drupalPost('node/' . $nid . '/edit', $edit, t('Save and keep published'));
$this->assertText($description);
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php
index fddbcca..8fcd58f 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php
@@ -7,6 +7,8 @@
namespace Drupal\file\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests that files are uploaded to proper locations.
*/
@@ -33,7 +35,7 @@ class FileFieldPathTest extends FileFieldTestBase {
// Check that the file was uploaded to the file root.
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$this->assertPathMatch('public://' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri)));
// Change the path to contain multiple subdirectories.
@@ -44,7 +46,7 @@ class FileFieldPathTest extends FileFieldTestBase {
// Check that the file was uploaded into the subdirectory.
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$this->assertPathMatch('public://foo/bar/baz/' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri)));
// Check the path when used with tokens.
@@ -56,7 +58,7 @@ class FileFieldPathTest extends FileFieldTestBase {
// Check that the file was uploaded into the subdirectory.
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
// Do token replacement using the same user which uploaded the file, not
// the user running the test case.
$data = array('user' => $this->admin_user);
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php
index a66fd8d..17c414b 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php
@@ -7,6 +7,8 @@
namespace Drupal\file\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests that formatters are working properly.
*/
@@ -65,7 +67,7 @@ class FileFieldRSSContentTest extends FileFieldTestBase {
// Get the uploaded file from the node.
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
// Check that the RSS enclosure appears in the RSS feed.
$this->drupalGet('rss.xml');
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php
index 3f2003a..f5c41ef 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php
@@ -7,6 +7,8 @@
namespace Drupal\file\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests file handling with node revisions.
*/
@@ -45,7 +47,7 @@ class FileFieldRevisionTest extends FileFieldTestBase {
// Check that the file exists on disk and in the database.
$node = node_load($nid, TRUE);
- $node_file_r1 = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file_r1 = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$node_vid_r1 = $node->vid;
$this->assertFileExists($node_file_r1, t('New file saved to disk on node creation.'));
$this->assertFileEntryExists($node_file_r1, t('File entry exists in database on node creation.'));
@@ -54,7 +56,7 @@ class FileFieldRevisionTest extends FileFieldTestBase {
// Upload another file to the same node in a new revision.
$this->replaceNodeFile($test_file, $field_name, $nid);
$node = node_load($nid, TRUE);
- $node_file_r2 = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file_r2 = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$node_vid_r2 = $node->vid;
$this->assertFileExists($node_file_r2, t('Replacement file exists on disk after creating new revision.'));
$this->assertFileEntryExists($node_file_r2, t('Replacement file entry exists in database after creating new revision.'));
@@ -62,7 +64,7 @@ class FileFieldRevisionTest extends FileFieldTestBase {
// Check that the original file is still in place on the first revision.
$node = node_revision_load($node_vid_r1);
- $this->assertEqual($node_file_r1, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('Original file still in place after replacing file in new revision.'));
+ $this->assertEqual($node_file_r1, file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']), t('Original file still in place after replacing file in new revision.'));
$this->assertFileExists($node_file_r1, t('Original file still in place after replacing file in new revision.'));
$this->assertFileEntryExists($node_file_r1, t('Original file entry still in place after replacing file in new revision'));
$this->assertFileIsPermanent($node_file_r1, t('Original file is still permanent.'));
@@ -71,7 +73,7 @@ class FileFieldRevisionTest extends FileFieldTestBase {
// Check that the file is still the same as the previous revision.
$this->drupalPost('node/' . $nid . '/edit', array('revision' => '1'), t('Save and keep published'));
$node = node_load($nid, TRUE);
- $node_file_r3 = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file_r3 = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$node_vid_r3 = $node->vid;
$this->assertEqual($node_file_r2, $node_file_r3, t('Previous revision file still in place after creating a new revision without a new file.'));
$this->assertFileIsPermanent($node_file_r3, t('New revision file is permanent.'));
@@ -79,7 +81,7 @@ class FileFieldRevisionTest extends FileFieldTestBase {
// Revert to the first revision and check that the original file is active.
$this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r1 . '/revert', array(), t('Revert'));
$node = node_load($nid, TRUE);
- $node_file_r4 = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file_r4 = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$node_vid_r4 = $node->vid;
$this->assertEqual($node_file_r1, $node_file_r4, t('Original revision file still in place after reverting to the original revision.'));
$this->assertFileIsPermanent($node_file_r4, t('Original revision file still permanent after reverting to the original revision.'));
@@ -93,8 +95,8 @@ class FileFieldRevisionTest extends FileFieldTestBase {
// Attach the second file to a user.
$user = $this->drupalCreateUser();
- $user->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'] = $node_file_r3->fid;
- $user->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['display'] = 1;
+ $user->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid'] = $node_file_r3->fid;
+ $user->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['display'] = 1;
$user->save();
$this->drupalGet('user/' . $user->uid . '/edit');
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php
index ac2f428..a26e464 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\file\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -134,7 +135,7 @@ abstract class FileFieldTestBase extends WebTestBase {
* Uploads a file to a node.
*/
function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, $extras = array()) {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array(
"title" => $this->randomName(),
'revision' => (string) (int) $new_revision,
@@ -186,7 +187,7 @@ abstract class FileFieldTestBase extends WebTestBase {
*/
function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) {
$edit = array(
- 'files[' . $field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_0]' => drupal_realpath($file->uri),
+ 'files[' . $field_name . '_' . Language::LANGCODE_NOT_SPECIFIED . '_0]' => drupal_realpath($file->uri),
'revision' => (string) (int) $new_revision,
);
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php
index faceb99..403ef45 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php
@@ -7,6 +7,8 @@
namespace Drupal\file\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests various validations.
*/
@@ -34,7 +36,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
$test_file = $this->getTestFile('text');
// Try to post a new node without uploading a file.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array("title" => $this->randomName());
$this->drupalPost('node/add/' . $type_name, $edit, t('Save and publish'));
$this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required file field was empty.'));
@@ -45,7 +47,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$this->assertFileExists($node_file, t('File exists after uploading to the required field.'));
$this->assertFileEntryExists($node_file, t('File entry exists after uploading to the required field.'));
@@ -61,7 +63,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
// Create a new node with the uploaded file into the multivalue field.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$this->assertFileExists($node_file, t('File exists after uploading to the required multiple value field.'));
$this->assertFileEntryExists($node_file, t('File entry exists after uploading to the required multipel value field.'));
}
@@ -91,7 +93,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
// Create a new node with the small file, which should pass.
$nid = $this->uploadNodeFile($small_file, $field_name, $type_name);
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize)));
$this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize)));
@@ -107,7 +109,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
// Upload the big file successfully.
$nid = $this->uploadNodeFile($large_file, $field_name, $type_name);
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize))));
$this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize))));
}
@@ -129,7 +131,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
// Check that the file can be uploaded with no extension checking.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$this->assertFileExists($node_file, t('File exists after uploading a file with no extension checking.'));
$this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with no extension checking.'));
@@ -147,7 +149,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
// Check that the file can be uploaded with extension checking.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$this->assertFileExists($node_file, t('File exists after uploading a file with extension checking.'));
$this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with extension checking.'));
}
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php
index 4991892..d749f57 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php
@@ -7,6 +7,8 @@
namespace Drupal\file\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests file field widget.
*/
@@ -44,7 +46,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// does not yet support file uploads.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$this->assertFileExists($node_file, t('New file saved to disk on node creation.'));
// Ensure the file can be downloaded.
@@ -71,13 +73,13 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), t('After clicking the "Remove" button, it is no longer displayed.'));
$this->assertFieldByXpath('//input[@type="submit"]', t('Upload'), t('After clicking the "Remove" button, the "Upload" button is displayed.'));
// Test label has correct 'for' attribute.
- $label = $this->xpath("//label[@for='edit-" . drupal_clean_css_identifier($field_name) . "-" . LANGUAGE_NOT_SPECIFIED . "-0-upload']");
+ $label = $this->xpath("//label[@for='edit-" . drupal_clean_css_identifier($field_name) . "-" . Language::LANGCODE_NOT_SPECIFIED . "-0-upload']");
$this->assertTrue(isset($label[0]), 'Label for upload found.');
// Save the node and ensure it does not have the file.
$this->drupalPost(NULL, array(), t('Save and keep published'));
$node = node_load($nid, TRUE);
- $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('File was successfully removed from the node.'));
+ $this->assertTrue(empty($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']), t('File was successfully removed from the node.'));
}
}
@@ -111,7 +113,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$this->drupalGet("node/add/$type_name");
foreach (array($field_name2, $field_name) as $each_field_name) {
for ($delta = 0; $delta < 3; $delta++) {
- $edit = array('files[' . $each_field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . $delta . '][]' => drupal_realpath($test_file->uri));
+ $edit = array('files[' . $each_field_name . '_' . Language::LANGCODE_NOT_SPECIFIED . '_' . $delta . '][]' => drupal_realpath($test_file->uri));
// If the Upload button doesn't exist, drupalPost() will automatically
// fail with an assertion message.
$this->drupalPost(NULL, $edit, t('Upload'));
@@ -142,11 +144,11 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$check_field_name = $field_name;
}
- $this->assertIdentical((string) $button['name'], $check_field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . $key. '_remove_button');
+ $this->assertIdentical((string) $button['name'], $check_field_name . '_' . Language::LANGCODE_NOT_SPECIFIED . '_' . $key. '_remove_button');
}
// "Click" the remove button (emulating either a nojs or js submission).
- $button_name = $current_field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . $delta . '_remove_button';
+ $button_name = $current_field_name . '_' . Language::LANGCODE_NOT_SPECIFIED . '_' . $delta . '_remove_button';
switch ($type) {
case 'nojs':
// drupalPost() takes a $submit parameter that is the value of the
@@ -174,7 +176,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// Ensure an "Upload" button for the current field is displayed with the
// correct name.
- $upload_button_name = $current_field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . $remaining . '_upload_button';
+ $upload_button_name = $current_field_name . '_' . Language::LANGCODE_NOT_SPECIFIED . '_' . $remaining . '_upload_button';
$buttons = $this->xpath('//input[@type="submit" and @value="Upload" and @name=:name]', array(':name' => $upload_button_name));
$this->assertTrue(is_array($buttons) && count($buttons) == 1, t('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type)));
@@ -194,7 +196,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches);
$nid = $matches[1];
$node = node_load($nid, TRUE);
- $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('Node was successfully saved without any files.'));
+ $this->assertTrue(empty($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']), t('Node was successfully saved without any files.'));
}
}
@@ -214,7 +216,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
$this->drupalPost("admin/structure/types/manage/$type_name/fields/$instance->id/field", $edit, t('Save field settings'));
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$this->assertFileExists($node_file, t('New file saved to disk on node creation.'));
// Ensure the private file is available to the user who uploaded it.
@@ -272,8 +274,8 @@ class FileFieldWidgetTest extends FileFieldTestBase {
// Add a comment with a file.
$text_file = $this->getTestFile('text');
$edit = array(
- 'files[field_' . $name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . 0 . ']' => drupal_realpath($text_file->uri),
- 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $comment_body = $this->randomName(),
+ 'files[field_' . $name . '_' . Language::LANGCODE_NOT_SPECIFIED . '_' . 0 . ']' => drupal_realpath($text_file->uri),
+ 'comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]' => $comment_body = $this->randomName(),
);
$this->drupalPost(NULL, $edit, t('Save'));
diff --git a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php
index 42c0b09..925ac7b 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php
@@ -7,6 +7,8 @@
namespace Drupal\file\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests file access on private nodes.
*/
@@ -48,7 +50,7 @@ class FilePrivateTest extends FileFieldTestBase {
$test_file = $this->getTestFile('text');
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name, TRUE, array('private' => TRUE));
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
// Ensure the file can be downloaded.
$this->drupalGet(file_create_url($node_file->uri));
$this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.'));
@@ -60,7 +62,7 @@ class FilePrivateTest extends FileFieldTestBase {
$this->drupalLogin($this->admin_user);
$nid = $this->uploadNodeFile($test_file, $no_access_field_name, $type_name, TRUE, array('private' => TRUE));
$node = node_load($nid, TRUE);
- $node_file = file_load($node->{$no_access_field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $node_file = file_load($node->{$no_access_field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
// Ensure the file cannot be downloaded.
$this->drupalGet(file_create_url($node_file->uri));
$this->assertResponse(403, t('Confirmed that access is denied for the file without view field access permission.'));
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
index f8f4807..65b7570 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
@@ -7,6 +7,8 @@
namespace Drupal\file\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests the file token replacement in strings.
*/
@@ -24,7 +26,7 @@ class FileTokenReplaceTest extends FileFieldTestBase {
*/
function testFileTokenReplacement() {
$token_service = \Drupal::token();
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$url_options = array(
'absolute' => TRUE,
'language' => $language_interface,
@@ -45,7 +47,7 @@ class FileTokenReplaceTest extends FileFieldTestBase {
// Load the node and the file.
$node = node_load($nid, TRUE);
- $file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $file = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
// Generate and test sanitized tokens.
$tests = array();
diff --git a/core/modules/file/lib/Drupal/file/Tests/SaveTest.php b/core/modules/file/lib/Drupal/file/Tests/SaveTest.php
index e2611e5..eeb9f77 100644
--- a/core/modules/file/lib/Drupal/file/Tests/SaveTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/SaveTest.php
@@ -7,6 +7,8 @@
namespace Drupal\file\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests saving files.
*/
@@ -43,7 +45,7 @@ class SaveTest extends FileManagedTestBase {
$this->assertEqual($loaded_file->status, $file->status, t("Status was saved correctly."));
$this->assertEqual($file->filesize, filesize($file->uri), t("File size was set correctly."), 'File');
$this->assertTrue($file->timestamp > 1, t("File size was set correctly."), 'File');
- $this->assertEqual($loaded_file->langcode, LANGUAGE_NOT_SPECIFIED, t("Langcode was defaulted correctly."));
+ $this->assertEqual($loaded_file->langcode, Language::LANGCODE_NOT_SPECIFIED, t("Langcode was defaulted correctly."));
// Resave the file, updating the existing record.
file_test_reset();
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 06d3fff..0d8f737 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -6,6 +6,7 @@
*/
use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Language\Language;
use Drupal\Core\Template\Attribute;
use Drupal\filter\Plugin\Core\Entity\FilterFormat;
@@ -275,7 +276,7 @@ function filter_permission_name($format) {
* @see filter_formats_reset()
*/
function filter_formats($account = NULL) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$formats = &drupal_static(__FUNCTION__, array());
// All available formats are cached for performance.
diff --git a/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php b/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php
index be4be40..f313cca 100644
--- a/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php
+++ b/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php
@@ -9,6 +9,7 @@ namespace Drupal\filter;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
+use Drupal\Core\Language\Language;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
@@ -31,7 +32,7 @@ class FilterPluginManager extends PluginManagerBase {
$annotation_namespaces = array('Drupal\filter\Annotation' => $namespaces['Drupal\filter']);
$this->discovery = new AnnotatedClassDiscovery('Filter', $namespaces, $annotation_namespaces, 'Drupal\filter\Annotation\Filter');
$this->discovery = new AlterDecorator($this->discovery, 'filter_info');
- $this->discovery = new CacheDecorator($this->discovery, 'filter_plugins:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'cache', array(
+ $this->discovery = new CacheDecorator($this->discovery, 'filter_plugins:' . language(Language::TYPE_INTERFACE)->langcode, 'cache', array(
'filter_formats' => TRUE,
));
}
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
index b07acac..6dc2f4c 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
@@ -7,6 +7,7 @@
namespace Drupal\filter\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -222,7 +223,7 @@ class FilterAdminTest extends WebTestBase {
$text = $body . '<random>' . $extra_text . '</random>';
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $text;
$edit["body[$langcode][0][format]"] = $basic;
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php
index 8667a5b..c811425 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php
@@ -7,6 +7,7 @@
namespace Drupal\filter\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -136,7 +137,7 @@ class FilterFormatAccessTest extends WebTestBase {
// the disallowed format does not.
$this->drupalLogin($this->web_user);
$this->drupalGet('node/add/page');
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$elements = $this->xpath('//select[@name=:name]/option', array(
':name' => "body[$langcode][0][format]",
':option' => $this->allowed_format->format,
@@ -206,7 +207,7 @@ class FilterFormatAccessTest extends WebTestBase {
* choose a new format before saving the page.
*/
function testFormatWidgetPermissions() {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$title_key = "title";
$body_value_key = "body[$langcode][0][value]";
$body_format_key = "body[$langcode][0][format]";
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php
index 442eff4..fb5b11b 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php
@@ -7,6 +7,7 @@
namespace Drupal\filter\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -64,7 +65,7 @@ class FilterHooksTest extends WebTestBase {
$this->assertText('hook_filter_format_update invoked.');
// Use the format created.
- $language_not_specified = LANGUAGE_NOT_SPECIFIED;
+ $language_not_specified = Language::LANGCODE_NOT_SPECIFIED;
$title = $this->randomName(8);
$edit = array(
"title" => $title,
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php
index aa3f390..9b3eea0 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php
@@ -7,6 +7,7 @@
namespace Drupal\filter\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -71,8 +72,8 @@ class FilterSecurityTest extends WebTestBase {
function testDisableFilterModule() {
// Create a new node.
$node = $this->drupalCreateNode(array('promote' => 1));
- $body_raw = $node->body[LANGUAGE_NOT_SPECIFIED][0]['value'];
- $format_id = $node->body[LANGUAGE_NOT_SPECIFIED][0]['format'];
+ $body_raw = $node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'];
+ $format_id = $node->body[Language::LANGCODE_NOT_SPECIFIED][0]['format'];
$this->drupalGet('node/' . $node->nid);
$this->assertText($body_raw, 'Node body found.');
diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php
index 65dd7c2..175f049 100644
--- a/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php
+++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php
@@ -7,6 +7,7 @@
namespace Drupal\forum\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Datetime\DrupalDateTime;
@@ -98,7 +99,7 @@ class ForumBlockTest extends WebTestBase {
// Comment on the first 5 topics.
$date = new DrupalDateTime();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
for ($index = 0; $index < 5; $index++) {
// Get the node from the topic title.
$node = $this->drupalGetNodeByTitle($topics[$index]);
@@ -168,7 +169,7 @@ class ForumBlockTest extends WebTestBase {
// changing the date.
$date->modify('+1 minute');
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array(
'title' => $title,
"body[$langcode][0][value]" => $body,
diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php
index 27e4384..e497f9b 100644
--- a/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php
+++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php
@@ -7,6 +7,7 @@
namespace Drupal\forum\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -42,7 +43,7 @@ class ForumIndexTest extends WebTestBase {
*/
function testForumIndexStatus() {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// The forum ID to use.
$tid = 1;
diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php
index bc145b0..dffeb2f 100644
--- a/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php
+++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php
@@ -7,6 +7,7 @@
namespace Drupal\forum\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -54,7 +55,7 @@ class ForumNodeAccessTest extends WebTestBase {
$this->drupalLogin($admin_user);
// Create a private node.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$private_node_title = $this->randomName(20);
$edit = array(
'title' => $private_node_title,
diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
index 0232b21..9f4b89a 100644
--- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
+++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
@@ -7,6 +7,7 @@
namespace Drupal\forum\Tests;
+use Drupal\Core\Language\Language;
use Drupal\Core\Entity\EntityInterface;
use Drupal\simpletest\WebTestBase;
@@ -211,7 +212,7 @@ class ForumTest extends WebTestBase {
// Test adding a comment to a forum topic.
$node = $this->createForumTopic($this->forum, FALSE);
$edit = array();
- $edit['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomName();
+ $edit['comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]'] = $this->randomName();
$this->drupalPost("node/$node->nid", $edit, t('Save'));
$this->assertResponse(200);
@@ -247,7 +248,7 @@ class ForumTest extends WebTestBase {
// Create an orphan forum item.
$this->drupalLogin($this->admin_user);
- $this->drupalPost('node/add/forum', array('title' => $this->randomName(10), 'body[' . LANGUAGE_NOT_SPECIFIED .'][0][value]' => $this->randomName(120)), t('Save'));
+ $this->drupalPost('node/add/forum', array('title' => $this->randomName(10), 'body[' . Language::LANGCODE_NOT_SPECIFIED .'][0][value]' => $this->randomName(120)), t('Save'));
$nid_count = db_query('SELECT COUNT(nid) FROM {node}')->fetchField();
$this->assertEqual(0, $nid_count, 'A forum node was not created when missing a forum vocabulary.');
@@ -477,7 +478,7 @@ class ForumTest extends WebTestBase {
// Post a reply to the topic.
$edit = array();
$edit['subject'] = $this->randomName();
- $edit['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomName();
+ $edit['comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]'] = $this->randomName();
$this->drupalPost("node/$node->nid", $edit, t('Save'));
$this->assertResponse(200);
@@ -504,7 +505,7 @@ class ForumTest extends WebTestBase {
$title = $this->randomName(20);
$body = $this->randomName(200);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array(
"title" => $title,
"body[$langcode][0][value]" => $body,
@@ -528,7 +529,7 @@ class ForumTest extends WebTestBase {
// Retrieve node object, ensure that the topic was created and in the proper forum.
$node = $this->drupalGetNodeByTitle($title);
$this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title)));
- $this->assertEqual($node->taxonomy_forums[LANGUAGE_NOT_SPECIFIED][0]['tid'], $tid, 'Saved forum topic was in the expected forum');
+ $this->assertEqual($node->taxonomy_forums[Language::LANGCODE_NOT_SPECIFIED][0]['tid'], $tid, 'Saved forum topic was in the expected forum');
// View forum topic.
$this->drupalGet('node/' . $node->nid);
@@ -590,7 +591,7 @@ class ForumTest extends WebTestBase {
if ($response == 200) {
// Edit forum node (including moving it to another forum).
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = 'node/' . $node->nid;
$edit["body[$langcode][0][value]"] = $this->randomName(256);
// Assume the topic is initially associated with $forum.
diff --git a/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php b/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php
index 529674a..73596c8 100644
--- a/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php
+++ b/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php
@@ -9,6 +9,7 @@ namespace Drupal\hal\Normalizer;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Entity\EntityNG;
+use Drupal\Core\Language\Language;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
/**
@@ -83,7 +84,7 @@ class EntityNormalizer extends NormalizerBase {
$langcode = language_get_default_langcode($typed_data_ids['entity_type'], $typed_data_ids['bundle']);
}
else {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
}
$entity = entity_create($typed_data_ids['entity_type'], array('langcode' => $langcode, 'type' => $typed_data_ids['bundle']));
diff --git a/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php b/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php
index d625234..f435de3 100644
--- a/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php
+++ b/core/modules/hal/lib/Drupal/hal/Normalizer/FieldNormalizer.php
@@ -8,6 +8,8 @@
namespace Drupal\hal\Normalizer;
use Drupal\Component\Utility\NestedArray;
+use Drupal\Core\Language\Language;
+
use Symfony\Component\Serializer\Exception\LogicException;
/**
@@ -43,7 +45,7 @@ class FieldNormalizer extends NormalizerBase {
// to the field item values.
else {
foreach ($entity->getTranslationLanguages() as $lang) {
- $context['langcode'] = $lang->langcode == 'und' ? LANGUAGE_DEFAULT : $lang->langcode;
+ $context['langcode'] = $lang->langcode == 'und' ? Language::LANGCODE_DEFAULT : $lang->langcode;
$translation = $entity->getTranslation($lang->langcode);
$translated_field = $translation->get($field_name);
$normalized_field_items = array_merge($normalized_field_items, $this->normalizeFieldItems($translated_field, $format, $context));
diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index a7696a6..00f21b6 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -5,6 +5,7 @@
* Exposes global functionality for creating image styles.
*/
+use Drupal\Core\Language\Language;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@@ -803,7 +804,7 @@ function image_style_path($style_name, $uri) {
* @see image_effect_definition_load()
*/
function image_effect_definitions() {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// hook_image_effect_info() includes translated strings, so each language is
// cached separately.
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php
index f667a67..dc51c16 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php
@@ -7,6 +7,8 @@
namespace Drupal\image\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests creation, deletion, and editing of image styles and effects.
*/
@@ -271,7 +273,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Test that image is displayed using newly created style.
$this->drupalGet('node/' . $nid);
- $this->assertRaw(image_style_url($style_name, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), format_string('Image displayed using style @style.', array('@style' => $style_name)));
+ $this->assertRaw(image_style_url($style_name, file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid'])->uri), format_string('Image displayed using style @style.', array('@style' => $style_name)));
// Rename the style and make sure the image field is updated.
$new_style_name = strtolower($this->randomName(10));
@@ -283,7 +285,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
$this->drupalPost($style_path . $style_name, $edit, t('Update style'));
$this->assertText(t('Changes to the style have been saved.'), format_string('Style %name was renamed to %new_name.', array('%name' => $style_name, '%new_name' => $new_style_name)));
$this->drupalGet('node/' . $nid);
- $this->assertRaw(image_style_url($new_style_name, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), 'Image displayed using style replacement style.');
+ $this->assertRaw(image_style_url($new_style_name, file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid'])->uri), 'Image displayed using style replacement style.');
// Delete the style and choose a replacement style.
$edit = array(
@@ -294,7 +296,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
$this->assertRaw($message);
$this->drupalGet('node/' . $nid);
- $this->assertRaw(image_style_url('thumbnail', file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), 'Image displayed using style replacement style.');
+ $this->assertRaw(image_style_url('thumbnail', file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid'])->uri), 'Image displayed using style replacement style.');
}
/**
@@ -360,7 +362,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
// Test that image is displayed using newly created style.
$this->drupalGet('node/' . $nid);
- $this->assertRaw(image_style_url($style_name, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), format_string('Image displayed using style @style.', array('@style' => $style_name)));
+ $this->assertRaw(image_style_url($style_name, file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid'])->uri), format_string('Image displayed using style @style.', array('@style' => $style_name)));
// Write empty manifest to staging.
$manifest_data = config('manifest.image.style')->get();
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
index c30c686..b679fb9 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
@@ -7,6 +7,8 @@
namespace Drupal\image\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Test class to check that formatters and display settings are working.
*/
@@ -56,7 +58,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$node = node_load($nid, TRUE);
// Test that the default formatter is being used.
- $image_uri = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri;
+ $image_uri = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid'])->uri;
$image_info = array(
'uri' => $image_uri,
'width' => 40,
@@ -157,13 +159,13 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
// and title fields do not display until the image has been attached.
$nid = $this->uploadNodeImage($test_image, $field_name, 'article');
$this->drupalGet('node/' . $nid . '/edit');
- $this->assertFieldByName($field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][alt]', '', 'Alt field displayed on article form.');
- $this->assertFieldByName($field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][title]', '', 'Title field displayed on article form.');
+ $this->assertFieldByName($field_name . '[' . Language::LANGCODE_NOT_SPECIFIED . '][0][alt]', '', 'Alt field displayed on article form.');
+ $this->assertFieldByName($field_name . '[' . Language::LANGCODE_NOT_SPECIFIED . '][0][title]', '', 'Title field displayed on article form.');
// Verify that the attached image is being previewed using the 'medium'
// style.
$node = node_load($nid, TRUE);
$image_info = array(
- 'uri' => file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri,
+ 'uri' => file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid'])->uri,
'width' => 220,
'height' => 110,
'style_name' => 'medium',
@@ -173,15 +175,15 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
// Add alt/title fields to the image and verify that they are displayed.
$image_info = array(
- 'uri' => file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri,
+ 'uri' => file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid'])->uri,
'alt' => $this->randomName(),
'title' => $this->randomName(),
'width' => 40,
'height' => 20,
);
$edit = array(
- $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][alt]' => $image_info['alt'],
- $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][title]' => $image_info['title'],
+ $field_name . '[' . Language::LANGCODE_NOT_SPECIFIED . '][0][alt]' => $image_info['alt'],
+ $field_name . '[' . Language::LANGCODE_NOT_SPECIFIED . '][0][title]' => $image_info['title'],
);
$this->drupalPost('node/' . $nid . '/edit', $edit, t('Save and keep published'));
$default_output = theme('image', $image_info);
@@ -190,8 +192,8 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
// Verify that alt/title longer than allowed results in a validation error.
$test_size = 2000;
$edit = array(
- $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][alt]' => $this->randomName($test_size),
- $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][title]' => $this->randomName($test_size),
+ $field_name . '[' . Language::LANGCODE_NOT_SPECIFIED . '][0][alt]' => $this->randomName($test_size),
+ $field_name . '[' . Language::LANGCODE_NOT_SPECIFIED . '][0][title]' => $this->randomName($test_size),
);
$this->drupalPost('node/' . $nid . '/edit', $edit, t('Save and keep published'));
$schema = $instance->getField()->getSchema();
@@ -241,7 +243,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
$nid = $this->uploadNodeImage($images[1], $field_name, 'article');
$node = node_load($nid, TRUE);
$image_info = array(
- 'uri' => file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri,
+ 'uri' => file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid'])->uri,
'width' => 40,
'height' => 20,
);
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
index 508c9bc..b670741 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\image\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -118,7 +119,7 @@ abstract class ImageFieldTestBase extends WebTestBase {
$edit = array(
'title' => $this->randomName(),
);
- $edit['files[' . $field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_0]'] = drupal_realpath($image->uri);
+ $edit['files[' . $field_name . '_' . Language::LANGCODE_NOT_SPECIFIED . '_0]'] = drupal_realpath($image->uri);
$this->drupalPost('node/add/' . $type, $edit, t('Save and publish'));
// Retrieve ID of the newly created node from the current URL.
diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc
index 59f1efa..33eaa6b 100644
--- a/core/modules/language/language.admin.inc
+++ b/core/modules/language/language.admin.inc
@@ -196,7 +196,7 @@ function _language_admin_common_controls(&$form, $language = NULL) {
'#required' => TRUE,
'#description' => t('Direction that text in this language is presented.'),
'#default_value' => @$language->direction,
- '#options' => array(LANGUAGE_LTR => t('Left to right'), LANGUAGE_RTL => t('Right to left')),
+ '#options' => array(Language::DIRECTION_LTR => t('Left to right'), Language::DIRECTION_RTL => t('Right to left')),
);
return $form;
}
diff --git a/core/modules/language/language.module b/core/modules/language/language.module
index 1dd936f..078ac2e 100644
--- a/core/modules/language/language.module
+++ b/core/modules/language/language.module
@@ -5,6 +5,8 @@
* Add language handling functionality to Drupal.
*/
+use Drupal\Core\Language\Language;
+
/**
* Implements hook_help().
*/
@@ -224,7 +226,7 @@ function language_element_info_alter(&$type) {
$type['language_select']['#process'] = array_merge($type['language_select']['#process'], array('language_process_language_select', 'form_process_select', 'ajax_process_form'));
$type['language_select']['#theme'] = 'select';
$type['language_select']['#theme_wrappers'] = array_merge($type['language_select']['#theme_wrappers'], array('form_element'));
- $type['language_select']['#languages'] = LANGUAGE_CONFIGURABLE;
+ $type['language_select']['#languages'] = Language::STATE_CONFIGURABLE;
$type['language_select']['#multiple'] = FALSE;
}
}
@@ -271,7 +273,7 @@ function language_element_info() {
function language_configuration_element_default_options() {
$language_options = array();
- $languages = language_list(LANGUAGE_ALL);
+ $languages = language_list(Language::STATE_ALL);
foreach ($languages as $langcode => $language) {
$language_options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name;
}
@@ -436,7 +438,7 @@ function language_get_default_langcode($entity_type, $bundle) {
}
$default_value = NULL;
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
switch ($configuration['langcode']) {
case 'site_default':
$default_value = language_default()->langcode;
@@ -534,7 +536,7 @@ function language_update_count() {
* TRUE if language is successfully deleted. Otherwise FALSE.
*/
function language_delete($langcode) {
- $languages = language_list(LANGUAGE_ALL);
+ $languages = language_list(Language::STATE_ALL);
if (isset($languages[$langcode]) && !$languages[$langcode]->locked) {
$language = $languages[$langcode];
@@ -566,10 +568,10 @@ function language_delete($langcode) {
* and checks to see if a related right to left CSS file should be included.
*/
function language_css_alter(&$css) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// If the current language is RTL, add the CSS file with the RTL overrides.
- if ($language_interface->direction == LANGUAGE_RTL) {
+ if ($language_interface->direction == Language::DIRECTION_RTL) {
foreach ($css as $data => $item) {
// Only provide RTL overrides for files.
if ($item['type'] == 'file') {
@@ -604,16 +606,16 @@ function language_language_types_info() {
language_negotiation_include();
return array(
- LANGUAGE_TYPE_INTERFACE => array(
+ Language::TYPE_INTERFACE => array(
'name' => t('User interface text'),
'description' => t('Order of language detection methods for user interface text. If a translation of user interface text is available in the detected language, it will be displayed.'),
),
- LANGUAGE_TYPE_CONTENT => array(
+ Language::TYPE_CONTENT => array(
'name' => t('Content'),
'description' => t('Order of language detection methods for content. If a version of content is available in the detected language, it will be displayed.'),
'fixed' => array(LANGUAGE_NEGOTIATION_INTERFACE),
),
- LANGUAGE_TYPE_URL => array(
+ Language::TYPE_URL => array(
'fixed' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_URL_FALLBACK),
),
);
@@ -628,7 +630,7 @@ function language_language_negotiation_info() {
$negotiation_info = array();
$negotiation_info[LANGUAGE_NEGOTIATION_URL] = array(
- 'types' => array(LANGUAGE_TYPE_CONTENT, LANGUAGE_TYPE_INTERFACE, LANGUAGE_TYPE_URL),
+ 'types' => array(Language::TYPE_CONTENT, Language::TYPE_INTERFACE, Language::TYPE_URL),
'callbacks' => array(
'negotiation' => 'language_from_url',
'language_switch' => 'language_switcher_url',
@@ -673,7 +675,7 @@ function language_language_negotiation_info() {
);
$negotiation_info[LANGUAGE_NEGOTIATION_INTERFACE] = array(
- 'types' => array(LANGUAGE_TYPE_CONTENT),
+ 'types' => array(Language::TYPE_CONTENT),
'callbacks' => array('negotiation' => 'language_from_interface'),
'file' => $file,
'weight' => 8,
@@ -682,7 +684,7 @@ function language_language_negotiation_info() {
);
$negotiation_info[LANGUAGE_NEGOTIATION_URL_FALLBACK] = array(
- 'types' => array(LANGUAGE_TYPE_URL),
+ 'types' => array(Language::TYPE_URL),
'callbacks' => array('negotiation' => 'language_url_fallback'),
'file' => $file,
'weight' => 8,
@@ -691,7 +693,7 @@ function language_language_negotiation_info() {
);
$negotiation_info[LANGUAGE_NEGOTIATION_USER_ADMIN] = array(
- 'types' => array(LANGUAGE_TYPE_INTERFACE),
+ 'types' => array(Language::TYPE_INTERFACE),
'callbacks' => array('negotiation' => 'language_from_user_admin'),
'file' => $file,
'weight' => 10,
@@ -853,7 +855,7 @@ function language_update_locked_weights() {
// Get maximum weight to update the system languages to keep them on bottom.
$max_weight = db_query('SELECT MAX(weight) FROM {language} WHERE locked = 0')->fetchField();
// Loop locked languages to maintain the existing order.
- foreach (language_list(LANGUAGE_LOCKED) as $language) {
+ foreach (language_list(Language::STATE_LOCKED) as $language) {
$max_weight++;
// Update system languages weight.
db_update('language')
diff --git a/core/modules/language/language.negotiation.inc b/core/modules/language/language.negotiation.inc
index 2182f4d..d205d76 100644
--- a/core/modules/language/language.negotiation.inc
+++ b/core/modules/language/language.negotiation.inc
@@ -7,6 +7,8 @@ use \Symfony\Component\HttpFoundation\Request;
* Language negotiation functions.
*/
+use Drupal\Core\Language\Language;
+
/**
* The language is determined using path prefix or domain.
*/
@@ -59,7 +61,7 @@ const LANGUAGE_NEGOTIATION_URL_DOMAIN = 'domain';
* The current interface language code.
*/
function language_from_interface() {
- return language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ return language(Language::TYPE_INTERFACE)->langcode;
}
/**
@@ -352,7 +354,7 @@ function language_from_url($languages, Request $request = NULL) {
* @return
* A valid language code.
*/
-function language_url_fallback($language = NULL, $request = NULL, $language_type = LANGUAGE_TYPE_INTERFACE) {
+function language_url_fallback($language = NULL, $request = NULL, $language_type = Language::TYPE_INTERFACE) {
$default = language_default();
$prefix = (config('language.negotiation')->get('url.source') == LANGUAGE_NEGOTIATION_URL_PREFIX);
@@ -439,7 +441,7 @@ function language_url_rewrite_url(&$path, &$options) {
// Language can be passed as an option, or we go for current URL language.
if (!isset($options['language'])) {
- $language_url = language(LANGUAGE_TYPE_URL);
+ $language_url = language(Language::TYPE_URL);
$options['language'] = $language_url;
}
// We allow only enabled languages here.
diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php
index 9ef236d..306bcef 100644
--- a/core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php
+++ b/core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php
@@ -7,6 +7,7 @@
namespace Drupal\language\Form;
+use Drupal\Core\Language\Language;
use Drupal\system\SystemConfigFormBase;
/**
@@ -29,7 +30,7 @@ class NegotiationSelectedForm extends SystemConfigFormBase {
$form['selected_langcode'] = array(
'#type' => 'language_select',
'#title' => t('Language'),
- '#languages' => LANGUAGE_CONFIGURABLE | LANGUAGE_SITE_DEFAULT,
+ '#languages' => Language::STATE_CONFIGURABLE | Language::STATE_SITE_DEFAULT,
'#default_value' => $config->get('selected_langcode'),
);
diff --git a/core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php b/core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php
index aba35d5..0cb5370 100644
--- a/core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php
+++ b/core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php
@@ -10,6 +10,7 @@ namespace Drupal\language\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Component\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
+use Drupal\Core\Language\Language as Lang;
/**
* Provides a 'Language' condition.
@@ -34,7 +35,7 @@ class Language extends ConditionPluginBase {
$form = parent::buildForm($form, $form_state);
if (language_multilingual()) {
// Fetch languages.
- $languages = language_list(LANGUAGE_ALL);
+ $languages = language_list(Lang::STATE_ALL);
$langcodes_options = array();
foreach ($languages as $language) {
// @todo $language->name is not wrapped with t(), it should be replaced
@@ -70,7 +71,7 @@ class Language extends ConditionPluginBase {
* {@inheritdoc}
*/
public function summary() {
- $language_list = language_list(LANGUAGE_ALL);
+ $language_list = language_list(Lang::STATE_ALL);
$selected = $this->configuration['langcodes'];
// Reduce the language list to an array of language names.
$language_names = array_reduce($language_list, function(&$result, $item) use ($selected) {
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php
index 55d6e8a..1bc67da 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php
@@ -83,7 +83,7 @@ class LanguageConfigurationElementTest extends WebTestBase {
// Current interface.
language_save_default_configuration('custom_type', 'custom_bundle', array('langcode' => 'current_interface', 'language_show' => TRUE));
$langcode = language_get_default_langcode('custom_type', 'custom_bundle');
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$this->assertEqual($langcode, $language_interface->langcode);
// Site's default.
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php
index b2d0bda..770337c 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationTest.php
@@ -7,6 +7,7 @@
namespace Drupal\language\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -145,7 +146,7 @@ class LanguageConfigurationTest extends WebTestBase {
drupal_static_reset('language_list');
$max_configurable_language_weight = $this->getHighestConfigurableLanguageWeight();
$replacements = array('@event' => $state);
- foreach (language_list(LANGUAGE_LOCKED) as $locked_language) {
+ foreach (language_list(Language::STATE_LOCKED) as $locked_language) {
$replacements['%language'] = $locked_language->name;
$this->assertTrue($locked_language->weight > $max_configurable_language_weight, format_string('System language %language has higher weight than configurable languages @event', $replacements));
}
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php
index a4a0e2d..f5875af 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php
@@ -57,7 +57,7 @@ class LanguageCustomLanguageConfigurationTest extends WebTestBase {
'predefined_langcode' => 'custom',
'langcode' => 'white space',
'name' => '<strong>evil markup</strong>',
- 'direction' => LANGUAGE_LTR,
+ 'direction' => Language::DIRECTION_LTR,
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
$this->assertRaw(t('%field may only contain characters a-z, underscores, or hyphens.', array('%field' => t('Language code'))));
@@ -69,7 +69,7 @@ class LanguageCustomLanguageConfigurationTest extends WebTestBase {
'predefined_langcode' => 'custom',
'langcode' => 'de',
'name' => 'German',
- 'direction' => LANGUAGE_LTR,
+ 'direction' => Language::DIRECTION_LTR,
);
// Add the language the first time.
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php
index 92a419b..088d655 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php
@@ -49,7 +49,7 @@ class LanguageDependencyInjectionTest extends WebTestBase {
drupal_language_initialize();
$expected = language_default();
- $result = language(LANGUAGE_TYPE_INTERFACE);
+ $result = language(Language::TYPE_INTERFACE);
foreach ($expected as $property => $value) {
$this->assertEqual($expected->$property, $result->$property, format_string('The dependency injected language object %prop property equals the new Language object %prop property.', array('%prop' => $property)));
}
@@ -79,7 +79,7 @@ class LanguageDependencyInjectionTest extends WebTestBase {
// The language system creates a Language object which contains the
// same properties as the new default language object.
$expected = new Language($new_language_default);
- $result = language(LANGUAGE_TYPE_INTERFACE);
+ $result = language(Language::TYPE_INTERFACE);
foreach ($expected as $property => $value) {
$this->assertEqual($expected->$property, $result->$property, format_string('The dependency injected language object %prop property equals the default language object %prop property.', array('%prop' => $property)));
}
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php
index 00bfd94..570ae2a 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php
@@ -181,10 +181,10 @@ class LanguageListTest extends WebTestBase {
$expected_all_languages = array('l4' => 'l4', 'l3' => 'l3', 'l2' => 'l2', 'l1' => 'l1', 'en' => 'en', 'und' => 'und', 'zxx' => 'zxx');
$expected_conf_languages = array('l3' => 'l3', 'l1' => 'l1', 'en' => 'en');
- $locked_languages = language_list(LANGUAGE_LOCKED);
+ $locked_languages = language_list(Language::STATE_LOCKED);
$this->assertEqual(array_diff_key($expected_locked_languages, $locked_languages), array(), 'Locked languages loaded correctly.');
- $all_languages = language_list(LANGUAGE_ALL);
+ $all_languages = language_list(Language::STATE_ALL);
$this->assertEqual(array_diff_key($expected_all_languages, $all_languages), array(), 'All languages loaded correctly.');
$conf_languages = language_list();
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php
index 8aea763..baef5ca 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php
@@ -7,6 +7,7 @@
namespace Drupal\language\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -54,7 +55,7 @@ class LanguageNegotiationInfoTest extends WebTestBase {
// negotiation settings with the proper flag enabled.
state()->set('language_test.content_language_type', TRUE);
$this->languageNegotiationUpdate();
- $type = LANGUAGE_TYPE_CONTENT;
+ $type = Language::TYPE_CONTENT;
$language_types = variable_get('language_types', language_types_get_default());
$this->assertTrue($language_types[$type], 'Content language type is configurable.');
@@ -96,7 +97,7 @@ class LanguageNegotiationInfoTest extends WebTestBase {
$last = state()->get('language_test.language_negotiation_last');
foreach (language_types_get_all() as $type) {
$langcode = $last[$type];
- $value = $type == LANGUAGE_TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en';
+ $value = $type == Language::TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en';
$this->assertEqual($langcode, $value, format_string('The negotiated language for %type is %language', array('%type' => $type, '%language' => $langcode)));
}
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php
index 47a61e7..c02db32 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php
@@ -7,6 +7,7 @@
namespace Drupal\language\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -42,7 +43,7 @@ class LanguageSwitchingTest extends WebTestBase {
*/
function testLanguageBlock() {
// Enable the language switching block.
- $block = $this->drupalPlaceBlock('language_block:' . LANGUAGE_TYPE_INTERFACE, array('machine_name' => 'test_language_block'));
+ $block = $this->drupalPlaceBlock('language_block:' . Language::TYPE_INTERFACE, array('machine_name' => 'test_language_block'));
// Add language.
$edit = array(
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
index e929171..0342773 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
@@ -143,7 +143,7 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$this->drupalPost('admin/config/regional/translate/translate', $edit, t('Save translations'));
// Configure URL language rewrite.
- variable_set('language_negotiation_url_type', LANGUAGE_TYPE_INTERFACE);
+ variable_set('language_negotiation_url_type', Language::TYPE_INTERFACE);
// Configure selected language negotiation to use zh-hans.
$edit = array('selected_langcode' => $langcode);
@@ -235,7 +235,7 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
}
// Unknown language prefix should return 404.
- variable_set('language_negotiation_' . LANGUAGE_TYPE_INTERFACE, language_language_negotiation_info());
+ variable_set('language_negotiation_' . Language::TYPE_INTERFACE, language_language_negotiation_info());
$this->drupalGet("$langcode_unknown/admin/config", array(), $http_header_browser_fallback);
$this->assertResponse(404, "Unknown language path prefix should return 404");
@@ -364,7 +364,7 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
protected function runTest($test) {
if (!empty($test['language_negotiation'])) {
$method_weights = array_flip($test['language_negotiation']);
- language_negotiation_set(LANGUAGE_TYPE_INTERFACE, $method_weights);
+ language_negotiation_set(Language::TYPE_INTERFACE, $method_weights);
}
if (!empty($test['language_negotiation_url_part'])) {
config('language.negotiation')
@@ -408,7 +408,7 @@ class LanguageUILanguageNegotiationTest extends WebTestBase {
$this->drupalGet('admin/config/regional/language/detection');
// Enable the language switcher block.
- $this->drupalPlaceBlock('language_block:' . LANGUAGE_TYPE_INTERFACE, array('machine_name' => 'test_language_block'));
+ $this->drupalPlaceBlock('language_block:' . Language::TYPE_INTERFACE, array('machine_name' => 'test_language_block'));
// Access the front page without specifying any valid URL language prefix
// and having as browser language preference a non-default language.
diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module
index cb97937..b83373a 100644
--- a/core/modules/language/tests/language_test/language_test.module
+++ b/core/modules/language/tests/language_test/language_test.module
@@ -8,13 +8,15 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
+use Drupal\Core\Language\Language;
+
/**
* Implements hook_init().
*/
function language_test_init() {
language_test_store_language_negotiation();
- if (isset(language(LANGUAGE_TYPE_INTERFACE)->langcode) && isset(language(LANGUAGE_TYPE_INTERFACE)->method_id)) {
- drupal_set_message(t('Language negotiation method: @name', array('@name' => language(LANGUAGE_TYPE_INTERFACE)->method_id)));
+ if (isset(language(Language::TYPE_INTERFACE)->langcode) && isset(language(Language::TYPE_INTERFACE)->method_id)) {
+ drupal_set_message(t('Language negotiation method: @name', array('@name' => language(Language::TYPE_INTERFACE)->method_id)));
}
}
@@ -40,7 +42,7 @@ function language_test_language_types_info() {
*/
function language_test_language_types_info_alter(array &$language_types) {
if (state()->get('language_test.content_language_type')) {
- unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']);
+ unset($language_types[Language::TYPE_CONTENT]['fixed']);
}
}
@@ -61,7 +63,7 @@ function language_test_language_negotiation_info() {
return array(
'test_language_negotiation_method' => array(
'name' => t('Test'),
- 'types' => array(LANGUAGE_TYPE_CONTENT, 'test_language_type', 'fixed_test_language_type'),
+ 'types' => array(Language::TYPE_CONTENT, 'test_language_type', 'fixed_test_language_type'),
) + $info,
'test_language_negotiation_method_ts' => array(
'name' => t('Type-specific test'),
diff --git a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php
index 0a6dc0b..1ec4ec4 100644
--- a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php
+++ b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php
@@ -7,6 +7,7 @@
namespace Drupal\link\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -72,7 +73,7 @@ class LinkFieldTest extends WebTestBase {
))
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
@@ -145,7 +146,7 @@ class LinkFieldTest extends WebTestBase {
))
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Verify that the title field works according to the field setting.
foreach (array(DRUPAL_DISABLED, DRUPAL_REQUIRED, DRUPAL_OPTIONAL) as $title_setting) {
@@ -257,7 +258,7 @@ class LinkFieldTest extends WebTestBase {
->setComponent($this->field['field_name'], $display_options)
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Create an entity with two link field values:
// - The first field item uses a URL only.
@@ -397,7 +398,7 @@ class LinkFieldTest extends WebTestBase {
->setComponent($this->field['field_name'], $display_options)
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Create an entity with two link field values:
// - The first field item uses a URL only.
diff --git a/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php b/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php
index 3f0d99b..093c787 100644
--- a/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php
+++ b/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php
@@ -68,7 +68,7 @@ class LocaleConfigSubscriber implements EventSubscriberInterface {
if ($account = $context->get('user.account')) {
$context->set('locale.language', language_load(user_preferred_langcode($account)));
}
- elseif ($language = $this->languageManager->getLanguage(LANGUAGE_TYPE_INTERFACE)) {
+ elseif ($language = $this->languageManager->getLanguage(Language::TYPE_INTERFACE)) {
$context->set('locale.language', $language);
}
}
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php
index 4f49d02..a6fb1c5 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php
@@ -7,6 +7,7 @@
namespace Drupal\locale\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -107,7 +108,7 @@ class LocalePathTest extends WebTestBase {
$edit = array(
'source' => 'node/' . $node->nid,
'alias' => $custom_path,
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
);
drupal_container()->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']);
$lookup_path = drupal_container()->get('path.alias_manager')->getPathAlias('node/' . $node->nid, 'en');
@@ -129,11 +130,11 @@ class LocalePathTest extends WebTestBase {
);
drupal_container()->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']);
- // Assign a custom path alias to second node with LANGUAGE_NOT_SPECIFIED.
+ // Assign a custom path alias to second node with Language::LANGCODE_NOT_SPECIFIED.
$edit = array(
'source' => 'node/' . $second_node->nid,
'alias' => $custom_path,
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
);
drupal_container()->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']);
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php
index f1c44dc..1547a72 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php
@@ -156,7 +156,7 @@ class LocaleTranslationTest extends WebTestBase {
locale_reset();
// Now we should get the proper fresh translation from t().
$this->assertTrue($name != $translation_to_en && t($name, array(), array('langcode' => 'en')) == $translation_to_en, t('t() works for English.'));
- $this->assertTrue(t($name, array(), array('langcode' => LANGUAGE_SYSTEM)) == $name, t('t() works for LANGUAGE_SYSTEM.'));
+ $this->assertTrue(t($name, array(), array('langcode' => Language::LANGCODE_SYSTEM)) == $name, 't() works for Language::LANGCODE_SYSTEM.');
$search = array(
'string' => $name,
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
index ee2b0c3..85e4b1c 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
@@ -62,7 +62,7 @@ class LocaleUninstallTest extends WebTestBase {
$language_manager->init();
// Check the UI language.
- $this->assertEqual(language(LANGUAGE_TYPE_INTERFACE)->langcode, $this->langcode, t('Current language: %lang', array('%lang' => language(LANGUAGE_TYPE_INTERFACE)->langcode)));
+ $this->assertEqual(language(Language::TYPE_INTERFACE)->langcode, $this->langcode, t('Current language: %lang', array('%lang' => language(Language::TYPE_INTERFACE)->langcode)));
// Enable multilingual workflow option for articles.
language_save_default_configuration('node', 'article', array('langcode' => 'site_default', 'language_show' => TRUE));
@@ -91,9 +91,9 @@ class LocaleUninstallTest extends WebTestBase {
// Change language negotiation options.
drupal_load('module', 'locale');
variable_set('language_types', language_types_get_default() + array('language_custom' => TRUE));
- variable_set('language_negotiation_' . LANGUAGE_TYPE_INTERFACE, language_language_negotiation_info());
- variable_set('language_negotiation_' . LANGUAGE_TYPE_CONTENT, language_language_negotiation_info());
- variable_set('language_negotiation_' . LANGUAGE_TYPE_URL, language_language_negotiation_info());
+ variable_set('language_negotiation_' . Language::TYPE_INTERFACE, language_language_negotiation_info());
+ variable_set('language_negotiation_' . Language::TYPE_CONTENT, language_language_negotiation_info());
+ variable_set('language_negotiation_' . Language::TYPE_URL, language_language_negotiation_info());
// Change language negotiation settings.
config('language.negotiation')
@@ -109,7 +109,7 @@ class LocaleUninstallTest extends WebTestBase {
// Visit the front page.
$this->drupalGet('');
// Check the init language logic.
- $this->assertEqual(language(LANGUAGE_TYPE_INTERFACE)->langcode, 'en', t('Language after uninstall: %lang', array('%lang' => language(LANGUAGE_TYPE_INTERFACE)->langcode)));
+ $this->assertEqual(language(Language::TYPE_INTERFACE)->langcode, 'en', t('Language after uninstall: %lang', array('%lang' => language(Language::TYPE_INTERFACE)->langcode)));
// Check JavaScript files deletion.
$this->assertTrue($result = !file_exists($js_file), t('JavaScript file deleted: %file', array('%file' => $result ? $js_file : t('found'))));
@@ -121,11 +121,11 @@ class LocaleUninstallTest extends WebTestBase {
// Check language negotiation.
require_once DRUPAL_ROOT . '/core/includes/language.inc';
$this->assertTrue(count(language_types_get_all()) == count(language_types_get_default()), t('Language types reset'));
- $language_negotiation = language_negotiation_method_get_first(LANGUAGE_TYPE_INTERFACE) == LANGUAGE_NEGOTIATION_SELECTED;
+ $language_negotiation = language_negotiation_method_get_first(Language::TYPE_INTERFACE) == LANGUAGE_NEGOTIATION_SELECTED;
$this->assertTrue($language_negotiation, t('Interface language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set'))));
- $language_negotiation = language_negotiation_method_get_first(LANGUAGE_TYPE_CONTENT) == LANGUAGE_NEGOTIATION_SELECTED;
+ $language_negotiation = language_negotiation_method_get_first(Language::TYPE_CONTENT) == LANGUAGE_NEGOTIATION_SELECTED;
$this->assertTrue($language_negotiation, t('Content language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set'))));
- $language_negotiation = language_negotiation_method_get_first(LANGUAGE_TYPE_URL) == LANGUAGE_NEGOTIATION_SELECTED;
+ $language_negotiation = language_negotiation_method_get_first(Language::TYPE_URL) == LANGUAGE_NEGOTIATION_SELECTED;
$this->assertTrue($language_negotiation, t('URL language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set'))));
// Check language negotiation method settings.
diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc
index 5173132..1f90503 100644
--- a/core/modules/locale/locale.bulk.inc
+++ b/core/modules/locale/locale.bulk.inc
@@ -157,7 +157,7 @@ function locale_translate_export_form($form, &$form_state) {
if (empty($language_options)) {
$form['langcode'] = array(
'#type' => 'value',
- '#value' => LANGUAGE_SYSTEM,
+ '#value' => Language::LANGCODE_SYSTEM,
);
$form['langcode_text'] = array(
'#type' => 'item',
@@ -172,7 +172,7 @@ function locale_translate_export_form($form, &$form_state) {
'#options' => $language_options,
'#default_value' => $language_default->langcode,
'#empty_option' => t('Source text only, no translations'),
- '#empty_value' => LANGUAGE_SYSTEM,
+ '#empty_value' => Language::LANGCODE_SYSTEM,
);
$form['content_options'] = array(
'#type' => 'details',
@@ -181,7 +181,7 @@ function locale_translate_export_form($form, &$form_state) {
'#tree' => TRUE,
'#states' => array(
'invisible' => array(
- ':input[name="langcode"]' => array('value' => LANGUAGE_SYSTEM),
+ ':input[name="langcode"]' => array('value' => Language::LANGCODE_SYSTEM),
),
),
);
@@ -217,7 +217,7 @@ function locale_translate_export_form($form, &$form_state) {
*/
function locale_translate_export_form_submit($form, &$form_state) {
// If template is required, language code is not given.
- if ($form_state['values']['langcode'] != LANGUAGE_SYSTEM) {
+ if ($form_state['values']['langcode'] != Language::LANGCODE_SYSTEM) {
$language = language_load($form_state['values']['langcode']);
}
else {
@@ -423,7 +423,7 @@ function locale_translate_batch_build($files, $options) {
*
* @param object $file
* A file object of the gettext file to be imported. The file object must
- * contain a language parameter (other than LANGUAGE_NOT_SPECIFIED). This
+ * contain a language parameter (other than Language::LANGCODE_NOT_SPECIFIED). This
* is used as the language of the import.
*
* @param array $options
@@ -448,7 +448,7 @@ function locale_translate_batch_import($file, $options, &$context) {
'customized' => LOCALE_NOT_CUSTOMIZED,
);
- if (isset($file->langcode) && $file->langcode != LANGUAGE_NOT_SPECIFIED) {
+ if (isset($file->langcode) && $file->langcode != Language::LANGCODE_NOT_SPECIFIED) {
try {
if (empty($context['sandbox'])) {
@@ -707,7 +707,7 @@ function locale_translate_file_attach_properties($file, $options = array()) {
$file->langcode = isset($options['langcode']) ? $options['langcode'] : $matches[5];
}
else {
- $file->langcode = LANGUAGE_NOT_SPECIFIED;
+ $file->langcode = Language::LANGCODE_NOT_SPECIFIED;
}
return $file;
}
diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install
index 0bcf093..af08d52 100644
--- a/core/modules/locale/locale.install
+++ b/core/modules/locale/locale.install
@@ -5,6 +5,8 @@
* Install, update, and uninstall functions for the Locale module.
*/
+use Drupal\Core\Language\Language;
+
/**
* Implements hook_install().
*/
@@ -663,9 +665,9 @@ function locale_update_8007() {
// Add all language type weight variables. As the function language_types()
// is not available its functionality is rebuild.
$language_types = update_variable_get('language_types', array(
- LANGUAGE_TYPE_INTERFACE => TRUE,
- LANGUAGE_TYPE_CONTENT => FALSE,
- LANGUAGE_TYPE_URL => FALSE,
+ Language::TYPE_INTERFACE => TRUE,
+ Language::TYPE_CONTENT => FALSE,
+ Language::TYPE_URL => FALSE,
));
foreach ($language_types as $language_type => $configurable) {
$variable_names[] = 'language_negotiation_methods_weight_' . $language_type;
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 31fd0fc..e778da8 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -10,6 +10,7 @@
* object files are supported.
*/
+use Drupal\Core\Language\Language;
use Drupal\locale\LocaleLookup;
use Drupal\locale\LocaleConfigSubscriber;
use Drupal\locale\SourceString;
@@ -362,7 +363,7 @@ function locale_translatable_language_list() {
* Language code to use for the lookup.
*/
function locale($string = NULL, $context = NULL, $langcode = NULL) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Use the advanced drupal_static() pattern, since this is called very often.
static $drupal_static_fast;
@@ -436,7 +437,7 @@ function locale_storage() {
* plural formula.
*/
function locale_get_plural($count, $langcode = NULL) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Used to locally cache the plural formulas for all languages.
$plural_formulas = &drupal_static(__FUNCTION__, array());
@@ -600,7 +601,7 @@ function locale_system_remove($components) {
*/
function locale_js_alter(&$javascript) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$dir = 'public://' . config('local.settings')->get('javascript.directory');
$parsed = state()->get('system.javascript_parsed') ?: array();
@@ -692,7 +693,7 @@ function locale_library_info() {
*/
function locale_library_info_alter(&$libraries, $module) {
if ($module == 'system' && isset($libraries['jquery.ui.datepicker'])) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// locale.datepicker.js should be added in the JS_LIBRARY group, so that
// this attach behavior will execute early. JS_LIBRARY is the default for
// hook_library_info_alter(), thus does not have to be specified explicitly.
@@ -702,7 +703,7 @@ function locale_library_info_alter(&$libraries, $module) {
'jquery' => array(
'ui' => array(
'datepicker' => array(
- 'isRTL' => $language_interface->direction == LANGUAGE_RTL,
+ 'isRTL' => $language_interface->direction == Language::DIRECTION_RTL,
'firstDay' => config('system.date')->get('first_day'),
),
),
@@ -873,8 +874,8 @@ function locale_system_file_system_settings_submit(&$form, $form_state) {
* Implements hook_preprocess_HOOK() for node.html.twig.
*/
function locale_preprocess_node(&$variables) {
- if ($variables['node']->langcode != LANGUAGE_NOT_SPECIFIED) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ if ($variables['node']->langcode != Language::LANGCODE_NOT_SPECIFIED) {
+ $language_interface = language(Language::TYPE_INTERFACE);
$node_language = language_load($variables['node']->langcode);
if ($node_language->langcode != $language_interface->langcode) {
@@ -1245,7 +1246,7 @@ function _locale_invalidate_js($langcode = NULL) {
function _locale_rebuild_js($langcode = NULL) {
$config = config('locale.settings');
if (!isset($langcode)) {
- $language = language(LANGUAGE_TYPE_INTERFACE);
+ $language = language(Language::TYPE_INTERFACE);
}
else {
// Get information about the locale.
diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc
index a109f5f..691d44d 100644
--- a/core/modules/locale/locale.pages.inc
+++ b/core/modules/locale/locale.pages.inc
@@ -5,6 +5,7 @@
* Interface translation summary, editing and deletion user interfaces.
*/
+use Drupal\Core\Language\Language;
use Drupal\locale\SourceString;
use Drupal\locale\TranslationString;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -107,7 +108,7 @@ function locale_translate_filters() {
}
// Pick the current interface language code for the filter.
- $default_langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ $default_langcode = language(Language::TYPE_INTERFACE)->langcode;
if (!isset($language_options[$default_langcode])) {
$available_langcodes = array_keys($language_options);
$default_langcode = array_shift($available_langcodes);
diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
index d731718..4a9c187 100644
--- a/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
+++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
@@ -7,6 +7,7 @@
namespace Drupal\menu\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -61,7 +62,7 @@ class MenuNodeTest extends WebTestBase {
// Create a node.
$node_title = $this->randomName();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array(
"title" => $node_title,
"body[$langcode][0][value]" => $this->randomString(),
diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php
index 79bd8de..dead752 100644
--- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php
+++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php
@@ -8,6 +8,7 @@
namespace Drupal\menu_link;
use Drupal\Core\Entity\EntityFormController;
+use Drupal\Core\Language\Language;
/**
* Form controller for the node edit forms.
@@ -124,7 +125,7 @@ class MenuLinkFormController extends EntityFormController {
$form['langcode'] = array(
'#type' => 'language_select',
'#title' => t('Language'),
- '#languages' => LANGUAGE_ALL,
+ '#languages' => Language::STATE_ALL,
'#default_value' => $menu_link->langcode,
);
diff --git a/core/modules/node/lib/Drupal/node/NodeAccessController.php b/core/modules/node/lib/Drupal/node/NodeAccessController.php
index cee9228..aacc22f 100644
--- a/core/modules/node/lib/Drupal/node/NodeAccessController.php
+++ b/core/modules/node/lib/Drupal/node/NodeAccessController.php
@@ -7,6 +7,7 @@
namespace Drupal\node;
+use Drupal\Core\Language\Language;
use Drupal\user\Plugin\Core\Entity\User;
use Drupal\Core\Entity\EntityAccessController;
use Drupal\Core\Entity\EntityInterface;
@@ -20,7 +21,7 @@ class NodeAccessController extends EntityAccessController {
/**
* {@inheritdoc}
*/
- public function access(EntityInterface $entity, $operation, $langcode = LANGUAGE_DEFAULT, User $account = NULL) {
+ public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, User $account = NULL) {
if (user_access('bypass node access', $account)) {
return TRUE;
}
diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php
index 5145a57..82504a0 100644
--- a/core/modules/node/lib/Drupal/node/NodeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeFormController.php
@@ -10,6 +10,7 @@ namespace Drupal\node;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Entity\EntityFormController;
+use Drupal\Core\Language\Language;
/**
* Form controller for the node edit forms.
@@ -107,7 +108,7 @@ class NodeFormController extends EntityFormController {
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $node->langcode,
- '#languages' => LANGUAGE_ALL,
+ '#languages' => Language::STATE_ALL,
'#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'],
);
diff --git a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php
index 465a492..7697423 100644
--- a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php
@@ -7,6 +7,7 @@
namespace Drupal\node\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -62,7 +63,7 @@ class MultiStepNodeFormBasicOptionsTest extends NodeTestBase {
))
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array(
'title' => 'a',
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
index 9c9c52e..4b3dc88 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
@@ -7,6 +7,8 @@
namespace Drupal\node\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests the interaction of the node access system with fields.
*/
@@ -58,7 +60,7 @@ class NodeAccessFieldTest extends NodeTestBase {
*/
function testNodeAccessAdministerField() {
// Create a page node.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$field_data = array();
$value = $field_data[0]['value'] = $this->randomName();
$node = $this->drupalCreateNode(array($this->field_name => $field_data));
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php
index fceb154..8ba7788 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php
@@ -78,7 +78,7 @@ class NodeAccessLanguageTest extends NodeTestBase {
// Creating a public node with no special langcode, like when no language
// module enabled.
$node_public_no_language = $this->drupalCreateNode(array('private' => FALSE));
- $this->assertTrue($node_public_no_language->langcode == LANGUAGE_NOT_SPECIFIED, 'Node created with not specified language.');
+ $this->assertTrue($node_public_no_language->langcode == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.');
// Tests that access is granted if requested with no language.
$this->assertNodeAccess($expected_node_access, $node_public_no_language, $web_user);
@@ -137,7 +137,7 @@ class NodeAccessLanguageTest extends NodeTestBase {
// Creating a private node with no special langcode, like when no language
// module enabled.
$node_private_no_language = $this->drupalCreateNode(array('private' => TRUE));
- $this->assertTrue($node_private_no_language->langcode == LANGUAGE_NOT_SPECIFIED, 'Node created with not specified language.');
+ $this->assertTrue($node_private_no_language->langcode == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.');
// Tests that access is not granted if requested with no language.
$this->assertNodeAccess($expected_node_access_no_access, $node_private_no_language, $web_user);
@@ -189,7 +189,7 @@ class NodeAccessLanguageTest extends NodeTestBase {
// Creating a public node with no special langcode, like when no language
// module enabled.
$node_no_language = $this->drupalCreateNode(array('private' => FALSE));
- $this->assertTrue($node_no_language->langcode == LANGUAGE_NOT_SPECIFIED, 'Node created with not specified language.');
+ $this->assertTrue($node_no_language->langcode == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.');
// Query the nodes table as the web user with the node access tag and no
// specific langcode.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php
index a9ae1c3..9d022c5 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php
@@ -7,6 +7,7 @@
namespace Drupal\node\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
index 55ab281..f531520 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
@@ -8,6 +8,7 @@
namespace Drupal\node\Tests;
use Drupal\Core\Database\Database;
+use Drupal\Core\Language\Language;
/**
* Tests creating and saving a node.
@@ -44,7 +45,7 @@ class NodeCreationTest extends NodeTestBase {
function testNodeCreation() {
// Create a node.
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName(8);
$edit["body[$langcode][0][value]"] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
@@ -66,7 +67,7 @@ class NodeCreationTest extends NodeTestBase {
'uid' => $this->loggedInUser->uid,
'name' => $this->loggedInUser->name,
'type' => 'page',
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'title' => 'testing_transaction_exception',
);
@@ -111,7 +112,7 @@ class NodeCreationTest extends NodeTestBase {
// Create a node.
$edit = array();
$edit["title"] = $this->randomName(8);
- $edit["body[" . LANGUAGE_NOT_SPECIFIED . "][0][value]"] = $this->randomName(16);
+ $edit["body[" . Language::LANGCODE_NOT_SPECIFIED . "][0][value]"] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the user was redirected to the home page.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php
index 9cc80f7..b284d96 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php
@@ -7,6 +7,8 @@
namespace Drupal\node\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests node_query_entity_field_access_alter().
*/
@@ -44,7 +46,7 @@ class NodeEntityFieldQueryAlterTest extends NodeTestBase {
// Creating 4 nodes with an entity field so we can test that sort of query
// alter. All field values starts with 'A' so we can identify and fetch them
// in the node_access_test module.
- $settings = array('langcode' => LANGUAGE_NOT_SPECIFIED);
+ $settings = array('langcode' => Language::LANGCODE_NOT_SPECIFIED);
for ($i = 0; $i < 4; $i++) {
$body = array(
'value' => 'A' . $this->randomName(32),
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php
index f072254..1915dbf 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php
@@ -7,6 +7,8 @@
namespace Drupal\node\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests changing view modes for nodes.
*/
@@ -34,7 +36,7 @@ class NodeEntityViewModeAlterTest extends NodeTestBase {
// Create a node.
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName(8);
$edit["body[$langcode][0][value]"] = t('Data that should appear only in the body for the node.');
$edit["body[$langcode][0][summary]"] = t('Extra data that should appear only in the teaser for the node.');
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
index 930bdf3..0206460 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
@@ -99,7 +99,7 @@ class NodeFieldMultilingualTestCase extends WebTestBase {
$this->assertTrue($node->language()->langcode == $langcode && $node->body->value == $body_value, 'Field language correctly changed.');
// Enable content language URL detection.
- language_negotiation_set(LANGUAGE_TYPE_CONTENT, array(LANGUAGE_NEGOTIATION_URL => 0));
+ language_negotiation_set(Language::TYPE_CONTENT, array(LANGUAGE_NEGOTIATION_URL => 0));
// Test multilingual field language fallback logic.
$this->drupalGet("it/node/{$node->id()}");
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php
index ce48614..c72dc25 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php
@@ -7,6 +7,8 @@
namespace Drupal\node\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Checks that the post information displays when enabled for a content type.
*/
@@ -39,7 +41,7 @@ class NodePostSettingsTest extends NodeTestBase {
// Create a node.
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName(8);
$edit["body[$langcode][0][value]"] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
@@ -62,7 +64,7 @@ class NodePostSettingsTest extends NodeTestBase {
// Create a node.
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName(8);
$edit["body[$langcode][0][value]"] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php
index 90a7305..746915e 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php
@@ -7,6 +7,8 @@
namespace Drupal\node\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests actions against revisions for user with access to all revisions.
*/
@@ -96,7 +98,7 @@ class NodeRevisionsAllTestCase extends NodeTestBase {
// Confirm the correct revision text appears on "view revisions" page.
$this->drupalGet("node/$node->nid/revisions/$node->vid/view");
- $this->assertText($node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], t('Correct text displays for version.'));
+ $this->assertText($node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'], t('Correct text displays for version.'));
// Confirm the correct log message appears on "revisions overview" page.
$this->drupalGet("node/$node->nid/revisions");
@@ -117,7 +119,7 @@ class NodeRevisionsAllTestCase extends NodeTestBase {
)),
'Revision reverted.');
$reverted_node = node_load($node->nid, TRUE);
- $this->assertTrue(($nodes[1]->body[LANGUAGE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[LANGUAGE_NOT_SPECIFIED][0]['value']), t('Node reverted correctly.'));
+ $this->assertTrue(($nodes[1]->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value']), t('Node reverted correctly.'));
// Confirm that this is not the current version.
$node = node_revision_load($node->vid);
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php
index 46244b8..27e49cd 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php
@@ -7,6 +7,8 @@
namespace Drupal\node\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests the node revision functionality.
*/
@@ -84,7 +86,7 @@ class NodeRevisionsTest extends NodeTestBase {
// Confirm the correct revision text appears on "view revisions" page.
$this->drupalGet("node/$node->nid/revisions/$node->vid/view");
- $this->assertText($node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], 'Correct text displays for version.');
+ $this->assertText($node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'], 'Correct text displays for version.');
// Confirm the correct log message appears on "revisions overview" page.
$this->drupalGet("node/$node->nid/revisions");
@@ -101,7 +103,7 @@ class NodeRevisionsTest extends NodeTestBase {
array('@type' => 'Basic page', '%title' => $nodes[1]->label(),
'%revision-date' => format_date($nodes[1]->revision_timestamp))), 'Revision reverted.');
$reverted_node = node_load($node->nid, TRUE);
- $this->assertTrue(($nodes[1]->body[LANGUAGE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[LANGUAGE_NOT_SPECIFIED][0]['value']), 'Node reverted correctly.');
+ $this->assertTrue(($nodes[1]->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value']), 'Node reverted correctly.');
// Confirm that this is not the default version.
$node = node_revision_load($node->vid);
@@ -134,7 +136,7 @@ class NodeRevisionsTest extends NodeTestBase {
// This will create a new revision that is not "front facing".
$new_node_revision = clone $node;
$new_body = $this->randomName();
- $new_node_revision->body[LANGUAGE_NOT_SPECIFIED][0]['value'] = $new_body;
+ $new_node_revision->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'] = $new_body;
// Save this as a non-default revision.
$new_node_revision->setNewRevision();
$new_node_revision->isDefaultRevision = FALSE;
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
index 633d3f3..90b7493 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
@@ -7,6 +7,8 @@
namespace Drupal\node\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Test node token replacement in strings.
*/
@@ -24,7 +26,7 @@ class NodeTokenReplaceTest extends NodeTestBase {
*/
function testNodeTokenReplacement() {
$token_service = \Drupal::token();
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$url_options = array(
'absolute' => TRUE,
'language' => $language_interface,
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php
index 2643981..27e31c6 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php
@@ -7,6 +7,8 @@
namespace Drupal\node\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests related to node type initial language.
*/
@@ -98,7 +100,7 @@ class NodeTypeInitialLanguageTest extends NodeTestBase {
* Tests language field visibility features.
*/
function testLanguageFieldVisibility() {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Creates a node to test Language field visibility feature.
$edit = array(
diff --git a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php
index b461492..8d963d4 100644
--- a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php
@@ -7,6 +7,8 @@
namespace Drupal\node\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests the node edit functionality.
*/
@@ -35,7 +37,7 @@ class PageEditTest extends NodeTestBase {
function testPageEdit() {
$this->drupalLogin($this->web_user);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$title_key = "title";
$body_key = "body[$langcode][0][value]";
// Create node to edit.
@@ -103,7 +105,7 @@ class PageEditTest extends NodeTestBase {
$this->drupalLogin($this->admin_user);
// Create node to edit.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$body_key = "body[$langcode][0][value]";
$edit = array();
$edit['title'] = $this->randomName(8);
diff --git a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
index 81456a3..d46c24e 100644
--- a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
@@ -7,6 +7,8 @@
namespace Drupal\node\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests the node entity preview functionality.
*/
@@ -38,7 +40,7 @@ class PagePreviewTest extends NodeTestBase {
'name' => $this->randomName(),
'description' => $this->randomName(),
'vid' => $this->randomName(),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'help' => '',
));
$vocabulary->save();
@@ -50,7 +52,7 @@ class PagePreviewTest extends NodeTestBase {
'name' => $this->randomName(),
'description' => $this->randomName(),
'vid' => $this->vocabulary->id(),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$term->save();
@@ -103,7 +105,7 @@ class PagePreviewTest extends NodeTestBase {
* Checks the node preview functionality.
*/
function testPagePreview() {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$title_key = "title";
$body_key = "body[$langcode][0][value]";
$term_key = "{$this->field_name}[$langcode]";
@@ -175,7 +177,7 @@ class PagePreviewTest extends NodeTestBase {
* Checks the node preview functionality, when using revisions.
*/
function testPagePreviewWithRevisions() {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$title_key = "title";
$body_key = "body[$langcode][0][value]";
$term_key = "{$this->field_name}[$langcode]";
diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php
index 6a28f7f..4924f56 100644
--- a/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php
@@ -6,6 +6,7 @@
*/
namespace Drupal\node\Tests\Views;
+use Drupal\Core\Language\Language;
/**
* Tests the node row plugin.
@@ -116,8 +117,8 @@ class RowPluginTest extends NodeTestBase {
$output = drupal_render($output);
foreach ($this->nodes as $node) {
$body = $node->body;
- $teaser = $body[LANGUAGE_NOT_SPECIFIED][0]['summary'];
- $full = $body[LANGUAGE_NOT_SPECIFIED][0]['value'];
+ $teaser = $body[Language::LANGCODE_NOT_SPECIFIED][0]['summary'];
+ $full = $body[Language::LANGCODE_NOT_SPECIFIED][0]['value'];
$this->assertFalse(strpos($output, $teaser) !== FALSE, 'Make sure the teaser appears in the output of the view.');
$this->assertTrue(strpos($output, $full) !== FALSE, 'Make sure the full text appears in the output of the view.');
}
@@ -128,8 +129,8 @@ class RowPluginTest extends NodeTestBase {
$output = drupal_render($output);
foreach ($this->nodes as $node) {
$body = $node->body;
- $teaser = $body[LANGUAGE_NOT_SPECIFIED][0]['summary'];
- $full = $body[LANGUAGE_NOT_SPECIFIED][0]['value'];
+ $teaser = $body[Language::LANGCODE_NOT_SPECIFIED][0]['summary'];
+ $full = $body[Language::LANGCODE_NOT_SPECIFIED][0]['value'];
$this->assertTrue(strpos($output, $teaser) !== FALSE, 'Make sure the teaser appears in the output of the view.');
$this->assertFalse(strpos($output, $full) !== FALSE, 'Make sure the full text does not appears in the output of the view if teaser is set as viewmode.');
}
diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc
index 139b2d2..3b05a80 100644
--- a/core/modules/node/node.admin.inc
+++ b/core/modules/node/node.admin.inc
@@ -6,6 +6,7 @@
*/
use Drupal\Core\Database\Query\SelectInterface;
+use Drupal\Core\Language\Language;
/**
* Page callback: Form constructor for the permission rebuild confirmation form.
@@ -110,7 +111,7 @@ function node_filters() {
// Language filter if language support is present.
if (language_multilingual()) {
- $languages = language_list(LANGUAGE_ALL);
+ $languages = language_list(Language::STATE_ALL);
foreach ($languages as $langcode => $language) {
// Make locked languages appear special in the list.
$language_options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name;
@@ -517,7 +518,7 @@ function node_admin_nodes() {
$nodes = node_load_multiple($nids);
// Prepare the list of nodes.
- $languages = language_list(LANGUAGE_ALL);
+ $languages = language_list(Language::STATE_ALL);
$destination = drupal_get_destination();
$form['nodes'] = array(
'#type' => 'table',
@@ -525,7 +526,7 @@ function node_admin_nodes() {
'#empty' => t('No content available.'),
);
foreach ($nodes as $node) {
- $l_options = $node->langcode != LANGUAGE_NOT_SPECIFIED && isset($languages[$node->langcode]) ? array('language' => $languages[$node->langcode]) : array();
+ $l_options = $node->langcode != Language::LANGCODE_NOT_SPECIFIED && isset($languages[$node->langcode]) ? array('language' => $languages[$node->langcode]) : array();
$form['nodes'][$node->nid]['title'] = array(
'#type' => 'link',
'#title' => $node->label(),
diff --git a/core/modules/node/node.install b/core/modules/node/node.install
index b0735d3..67cd0c3 100644
--- a/core/modules/node/node.install
+++ b/core/modules/node/node.install
@@ -5,6 +5,8 @@
* Install, update and uninstall functions for the node module.
*/
+use Drupal\Core\Language\Language;
+
/**
* Implements hook_schema().
*/
@@ -516,7 +518,7 @@ function node_update_8002() {
function node_update_8003() {
$types = db_query('SELECT type FROM {node_type}')->fetchCol();
foreach ($types as $type) {
- update_variable_set('node_type_language_default_' . $type, LANGUAGE_NOT_SPECIFIED);
+ update_variable_set('node_type_language_default_' . $type, Language::LANGCODE_NOT_SPECIFIED);
$node_type_language = update_variable_get('node_type_language_' . $type, 0);
if ($node_type_language == 0) {
update_variable_set('node_type_language_show_' . $type, FALSE);
@@ -524,7 +526,7 @@ function node_update_8003() {
if ($node_type_language == 2) {
// Translation was enabled, so enable it again and
// unhide the language selector. Because if language is
- // LANGUAGE_NOT_SPECIFIED and the selector hidden, translation
+ // Language::LANGCODE_NOT_SPECIFIED and the selector hidden, translation
// cannot be enabled.
update_variable_set('node_type_language_show_' . $type, TRUE);
update_variable_set('node_type_language_translation_enabled_' . $type, TRUE);
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 1e1084e..6d7b1c9 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -8,6 +8,7 @@
* API pattern.
*/
+use Drupal\Core\Language\Language;
use Symfony\Component\HttpFoundation\Response;
use Drupal\Core\Cache\CacheBackendInterface;
@@ -677,7 +678,7 @@ function node_type_update_nodes($old_type, $type) {
* type object by $type->disabled being set to TRUE.
*/
function _node_types_build($rebuild = FALSE) {
- $cid = 'node_types:' . language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ $cid = 'node_types:' . language(Language::TYPE_INTERFACE)->langcode;
if (!$rebuild) {
$_node_types = &drupal_static(__FUNCTION__);
@@ -2039,7 +2040,7 @@ function node_block_access($block) {
*/
function node_feed($nids = FALSE, $channel = array()) {
global $base_url;
- $language_content = language(LANGUAGE_TYPE_CONTENT);
+ $language_content = language(Language::TYPE_CONTENT);
$rss_config = config('system.rss');
if ($nids === FALSE) {
@@ -2292,7 +2293,7 @@ function node_form_search_form_alter(&$form, $form_state) {
// Languages:
$language_options = array();
- foreach (language_list(LANGUAGE_ALL) as $langcode => $language) {
+ foreach (language_list(Language::STATE_ALL) as $langcode => $language) {
// Make locked languages appear special in the list.
$language_options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name;
}
@@ -2502,7 +2503,7 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) {
// Load languages the node exists in.
$node_translations = $node->getTranslationLanguages();
// Load the language from content negotiation.
- $content_negotiation_langcode = language(LANGUAGE_TYPE_CONTENT)->langcode;
+ $content_negotiation_langcode = language(Language::TYPE_CONTENT)->langcode;
// If there is a translation available, use it.
if (isset($node_translations[$content_negotiation_langcode])) {
$langcode = $content_negotiation_langcode;
diff --git a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
index d0b98ac..7cb310a 100644
--- a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
+++ b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
@@ -7,6 +7,7 @@
namespace Drupal\number\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -76,7 +77,7 @@ class NumberFieldTest extends WebTestBase {
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', 'Widget is displayed');
$this->assertRaw('placeholder="0.00"');
diff --git a/core/modules/openid/openid.inc b/core/modules/openid/openid.inc
index 8d5aae9..a4b9b2c 100644
--- a/core/modules/openid/openid.inc
+++ b/core/modules/openid/openid.inc
@@ -5,6 +5,8 @@
* OpenID utility functions.
*/
+use Drupal\Core\Language\Language;
+
/**
* Diffie-Hellman Key Exchange Default Value.
*
@@ -83,7 +85,7 @@ function openid_redirect_http($url, $message) {
* Creates a js auto-submit redirect for (for the 2.x protocol)
*/
function openid_redirect($url, $message) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
$output .= '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $language_interface->langcode . '" lang="' . $language_interface->langcode . '">' . "\n";
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php
index 693605a..5ede47b 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php
@@ -7,6 +7,7 @@
namespace Drupal\options\Tests;
+use Drupal\Core\Language\Language;
use Drupal\field\FieldValidationException;
/**
@@ -27,7 +28,7 @@ class OptionsDynamicValuesValidationTest extends OptionsDynamicValuesTest {
function testDynamicAllowedValues() {
// Verify that the test passes against every value we had.
foreach ($this->test as $key => $value) {
- $this->entity->test_options[LANGUAGE_NOT_SPECIFIED][0]['value'] = $value;
+ $this->entity->test_options[Language::LANGCODE_NOT_SPECIFIED][0]['value'] = $value;
try {
field_attach_validate($this->entity);
$this->pass("$key should pass");
@@ -39,7 +40,7 @@ class OptionsDynamicValuesValidationTest extends OptionsDynamicValuesTest {
}
// Now verify that the test does not pass against anything else.
foreach ($this->test as $key => $value) {
- $this->entity->test_options[LANGUAGE_NOT_SPECIFIED][0]['value'] = is_numeric($value) ? (100 - $value) : ('X' . $value);
+ $this->entity->test_options[Language::LANGCODE_NOT_SPECIFIED][0]['value'] = is_numeric($value) ? (100 - $value) : ('X' . $value);
$pass = FALSE;
try {
field_attach_validate($this->entity);
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
index efd8d5c..984a205 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
@@ -7,6 +7,7 @@
namespace Drupal\options\Tests;
+use Drupal\Core\Language\Language;
use Drupal\field\FieldException;
/**
@@ -33,7 +34,7 @@ class OptionsFieldTest extends OptionsFieldUnitTestBase {
* Test that allowed values can be updated.
*/
function testUpdateAllowedValues() {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// All three options appear.
$entity = entity_create('entity_test', array());
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
index cbb3c7f..91f7498 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
@@ -7,6 +7,7 @@
namespace Drupal\options\Tests;
+use Drupal\Core\Language\Language;
use Drupal\field\Tests\FieldTestBase;
/**
@@ -89,7 +90,7 @@ class OptionsWidgetsTest extends FieldTestBase {
))
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Create an entity.
$entity_init = field_test_create_entity();
@@ -146,7 +147,7 @@ class OptionsWidgetsTest extends FieldTestBase {
))
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Create an entity.
$entity_init = field_test_create_entity();
@@ -237,7 +238,7 @@ class OptionsWidgetsTest extends FieldTestBase {
))
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Create an entity.
$entity_init = field_test_create_entity();
@@ -336,7 +337,7 @@ class OptionsWidgetsTest extends FieldTestBase {
))
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Create an entity.
$entity_init = field_test_create_entity();
@@ -456,7 +457,7 @@ class OptionsWidgetsTest extends FieldTestBase {
))
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Create an entity.
$entity_init = field_test_create_entity();
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
index 455a3f6..f592b72 100644
--- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
+++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
@@ -7,6 +7,8 @@
namespace Drupal\path\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests URL aliases for translated nodes.
*/
@@ -74,7 +76,7 @@ class PathLanguageTest extends PathTestBase {
$this->drupalGet('node/' . $english_node->nid . '/translate');
$this->clickLink(t('Add translation'));
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $this->randomName();
$french_alias = $this->randomName();
diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc
index 773431c..930c1df 100644
--- a/core/modules/path/path.admin.inc
+++ b/core/modules/path/path.admin.inc
@@ -5,6 +5,8 @@
* Administrative page callbacks for the path module.
*/
+use Drupal\Core\Language\Language;
+
/**
* Returns a listing of all defined URL aliases.
*
@@ -16,7 +18,7 @@ function path_admin_overview($keys = NULL) {
$build['path_admin_filter_form'] = drupal_get_form('path_admin_filter_form', $keys);
// Enable language column if language.module is enabled or if we have any
// alias with a language.
- $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => LANGUAGE_NOT_SPECIFIED))->fetchField();
+ $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => Language::LANGCODE_NOT_SPECIFIED))->fetchField();
$multilanguage = (module_exists('language') || $alias_exists);
$header = array();
@@ -127,7 +129,7 @@ function path_admin_edit($path = array()) {
* @see path_admin_form_submit()
* @see path_admin_form_delete_submit()
*/
-function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'langcode' => LANGUAGE_NOT_SPECIFIED, 'pid' => NULL)) {
+function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'langcode' => Language::LANGCODE_NOT_SPECIFIED, 'pid' => NULL)) {
$form['source'] = array(
'#type' => 'textfield',
'#title' => t('Existing system path'),
@@ -160,7 +162,7 @@ function path_admin_form($form, &$form_state, $path = array('source' => '', 'ali
'#type' => 'select',
'#title' => t('Language'),
'#options' => $language_options,
- '#empty_value' => LANGUAGE_NOT_SPECIFIED,
+ '#empty_value' => Language::LANGCODE_NOT_SPECIFIED,
'#empty_option' => t('- None -'),
'#default_value' => $path['langcode'],
'#weight' => -10,
@@ -222,7 +224,7 @@ function path_admin_form_validate($form, &$form_state) {
$pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
// Language is only set if language.module is enabled, otherwise save for all
// languages.
- $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : LANGUAGE_NOT_SPECIFIED;
+ $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGCODE_NOT_SPECIFIED;
$has_alias = db_query("SELECT COUNT(alias) FROM {url_alias} WHERE pid <> :pid AND alias = :alias AND langcode = :langcode", array(
':pid' => $pid,
@@ -255,7 +257,7 @@ function path_admin_form_submit($form, &$form_state) {
$alias = $form_state['values']['alias'];
// Language is only set if language.module is enabled, otherwise save for all
// languages.
- $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : LANGUAGE_NOT_SPECIFIED;
+ $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGCODE_NOT_SPECIFIED;
drupal_container()->get('path.crud')->save($source, $alias, $langcode, $pid);
diff --git a/core/modules/path/path.module b/core/modules/path/path.module
index 03be41b..396cd25 100644
--- a/core/modules/path/path.module
+++ b/core/modules/path/path.module
@@ -7,6 +7,7 @@
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Language\Language;
use Drupal\taxonomy\Plugin\Core\Entity\Term;
/**
@@ -100,7 +101,7 @@ function path_form_node_form_alter(&$form, $form_state) {
$path = array();
if (!empty($node->nid)) {
$conditions = array('source' => 'node/' . $node->nid);
- if ($node->langcode != LANGUAGE_NOT_SPECIFIED) {
+ if ($node->langcode != Language::LANGCODE_NOT_SPECIFIED) {
$conditions['langcode'] = $node->langcode;
}
$path = drupal_container()->get('path.crud')->load($conditions);
@@ -112,7 +113,7 @@ function path_form_node_form_alter(&$form, $form_state) {
'pid' => NULL,
'source' => isset($node->nid) ? 'node/' . $node->nid : NULL,
'alias' => '',
- 'langcode' => isset($node->langcode) ? $node->langcode : LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED,
);
$form['path'] = array(
@@ -190,7 +191,7 @@ function path_node_insert(EntityInterface $node) {
if (!empty($alias)) {
// Ensure fields for programmatic executions.
$source = 'node/' . $node->nid;
- $langcode = isset($node->langcode) ? $node->langcode : LANGUAGE_NOT_SPECIFIED;
+ $langcode = isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED;
drupal_container()->get('path.crud')->save($source, $alias, $langcode);
}
}
@@ -211,7 +212,7 @@ function path_node_update(EntityInterface $node) {
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
$source = 'node/' . $node->nid;
- $langcode = isset($node->langcode) ? $node->langcode : LANGUAGE_NOT_SPECIFIED;
+ $langcode = isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED;
drupal_container()->get('path.crud')->save($source, $alias, $langcode, $path['pid']);
}
}
@@ -240,7 +241,7 @@ function path_form_taxonomy_term_form_alter(&$form, $form_state) {
'pid' => NULL,
'source' => $term->id() ? 'taxonomy/term/' . $term->id() : NULL,
'alias' => '',
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
);
$form['path'] = array(
'#access' => user_access('create url aliases') || user_access('administer url aliases'),
@@ -299,7 +300,7 @@ function path_taxonomy_term_insert(Term $term) {
if (!empty($term->path->alias)) {
// Ensure fields for programmatic executions.
$source = 'taxonomy/term/' . $term->id();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
Drupal::service('path.crud')->save($source, $term->path->alias, $langcode);
}
}
@@ -320,7 +321,7 @@ function path_taxonomy_term_update(Term $term) {
$pid = (!empty($term->path->pid) ? $term->path->pid : NULL);
// Ensure fields for programmatic executions.
$source = 'taxonomy/term/' . $term->id();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
Drupal::service('path.crud')->save($source, $term->path->alias, $langcode, $pid);
}
}
diff --git a/core/modules/php/lib/Drupal/php/Tests/PhpFilterTest.php b/core/modules/php/lib/Drupal/php/Tests/PhpFilterTest.php
index ffab8c5..f954bdd 100644
--- a/core/modules/php/lib/Drupal/php/Tests/PhpFilterTest.php
+++ b/core/modules/php/lib/Drupal/php/Tests/PhpFilterTest.php
@@ -7,6 +7,8 @@
namespace Drupal\php\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests to make sure the PHP filter actually evaluates PHP code when used.
*/
@@ -37,7 +39,7 @@ class PhpFilterTest extends PhpTestBase {
// Change filter to PHP filter and see that PHP code is evaluated.
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["body[$langcode][0][format]"] = $this->php_code_format->format;
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
$this->assertRaw(t('Basic page %title has been updated.', array('%title' => $node->label())), 'PHP code filter turned on.');
diff --git a/core/modules/picture/lib/Drupal/picture/Tests/PictureFieldDisplayTest.php b/core/modules/picture/lib/Drupal/picture/Tests/PictureFieldDisplayTest.php
index c8cd4cb..3d61841 100644
--- a/core/modules/picture/lib/Drupal/picture/Tests/PictureFieldDisplayTest.php
+++ b/core/modules/picture/lib/Drupal/picture/Tests/PictureFieldDisplayTest.php
@@ -7,6 +7,7 @@
namespace Drupal\picture\Tests;
+use Drupal\Core\Language\Language;
use Drupal\breakpoint\Plugin\Core\Entity\Breakpoint;
use Drupal\image\Tests\ImageFieldTestBase;
@@ -122,7 +123,7 @@ class PictureFieldDisplayTest extends ImageFieldTestBase {
$node = node_load($nid, TRUE);
// Test that the default formatter is being used.
- $image_uri = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri;
+ $image_uri = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['fid'])->uri;
$image_info = array(
'uri' => $image_uri,
'width' => 40,
diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
index 5d917a4..bf47b46 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
@@ -7,6 +7,7 @@
namespace Drupal\rdf\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -102,7 +103,7 @@ class RdfaMarkupTest extends WebTestBase {
$admin_user = $this->drupalCreateUser(array('edit own article content', 'revert article revisions', 'administer content types'));
$this->drupalLogin($admin_user);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$bundle_name = "article";
$field_name = 'file_test';
@@ -163,7 +164,7 @@ class RdfaMarkupTest extends WebTestBase {
$tag1 = $this->randomName(8);
$tag2 = $this->randomName(8);
$edit = array();
- $edit['field_tags[' . LANGUAGE_NOT_SPECIFIED . ']'] = "$tag1, $tag2";
+ $edit['field_tags[' . Language::LANGCODE_NOT_SPECIFIED . ']'] = "$tag1, $tag2";
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
$term_1_id = key(taxonomy_term_load_multiple_by_name($tag1));
$taxonomy_term_1_uri = url('taxonomy/term/' . $term_1_id, array('absolute' => TRUE));
diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php
index b78cabd..0e6e4bb 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php
@@ -7,6 +7,7 @@
namespace Drupal\rdf\Tests;
+use Drupal\Core\Language\Language;
use Drupal\Core\Entity\EntityInterface;
use Drupal\simpletest\WebTestBase;
@@ -125,7 +126,7 @@ class TrackerAttributesTest extends WebTestBase {
// Adds new comment to ensure the tracker is updated accordingly.
$comment = array(
'subject' => $this->randomName(),
- 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(),
+ 'comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomName(),
);
$this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save'));
diff --git a/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php b/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php
index 96ec810..3ef6594 100644
--- a/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php
+++ b/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php
@@ -7,6 +7,7 @@
namespace Drupal\rest\Tests;
+use Drupal\Core\Language\Language;
use Drupal\rest\Tests\RESTTestBase;
/**
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php
index 30073d7..5ea6932 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php
@@ -7,6 +7,8 @@
namespace Drupal\search\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests that comment count display toggles properly on comment status of node
*
@@ -58,7 +60,7 @@ class SearchCommentCountToggleTest extends SearchTestBase {
// Create a comment array
$edit_comment = array();
$edit_comment['subject'] = $this->randomName();
- $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomName();
+ $edit_comment['comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]'] = $this->randomName();
// Post comment to the test node with comment
$this->drupalPost('comment/reply/' . $this->searchable_nodes['1 comment']->nid, $edit_comment, t('Save'));
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php
index 04d78a4..4d2a7ed 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php
@@ -7,6 +7,8 @@
namespace Drupal\search\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Test integration searching comments.
*/
@@ -75,9 +77,9 @@ class SearchCommentTest extends SearchTestBase {
// Post a comment using 'Full HTML' text format.
$edit_comment = array();
$edit_comment['subject'] = 'Test comment subject';
- $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = '<h1>' . $comment_body . '</h1>';
+ $edit_comment['comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]'] = '<h1>' . $comment_body . '</h1>';
$full_html_format_id = 'full_html';
- $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][format]'] = $full_html_format_id;
+ $edit_comment['comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][format]'] = $full_html_format_id;
$this->drupalPost('comment/reply/' . $node->nid, $edit_comment, t('Save'));
// Invoke search index update.
@@ -103,7 +105,7 @@ class SearchCommentTest extends SearchTestBase {
// Verify that comment is rendered using proper format.
$this->assertText($comment_body, 'Comment body text found in search results.');
$this->assertNoRaw(t('n/a'), 'HTML in comment body is not hidden.');
- $this->assertNoRaw(check_plain($edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]']), 'HTML in comment body is not escaped.');
+ $this->assertNoRaw(check_plain($edit_comment['comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]']), 'HTML in comment body is not escaped.');
// Hide comments.
$this->drupalLogin($this->admin_user);
@@ -136,7 +138,7 @@ class SearchCommentTest extends SearchTestBase {
// Post a comment using 'Full HTML' text format.
$edit_comment = array();
$edit_comment['subject'] = $this->comment_subject;
- $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = '<h1>' . $comment_body . '</h1>';
+ $edit_comment['comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]'] = '<h1>' . $comment_body . '</h1>';
$this->drupalPost('comment/reply/' . $this->node->nid, $edit_comment, t('Save'));
$this->drupalLogout();
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php
index 894fd67..8d91a82 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php
@@ -7,6 +7,8 @@
namespace Drupal\search\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Test config page.
*/
@@ -42,7 +44,7 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
$this->search_node = $node;
// Link the node to itself to test that it's only indexed once. The content
// also needs the word "pizza" so we can use it as the search keyword.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$body_key = "body[$langcode][0][value]";
$edit[$body_key] = l($node->label(), 'node/' . $node->nid) . ' pizza sandwich';
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save and keep published'));
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php
index 118cbf7..0f3d574 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php
@@ -7,6 +7,8 @@
namespace Drupal\search\Tests;
+use Drupal\Core\Language\Language;
+
// The search index can contain different types of content. Typically the type
// is 'node'. Here we test with _test_ and _test2_ as the type.
const SEARCH_TYPE = '_test_';
@@ -37,10 +39,10 @@ class SearchMatchTest extends SearchTestBase {
config('search.settings')->set('index.minimum_word_size', 3)->save();
for ($i = 1; $i <= 7; ++$i) {
- search_index($i, SEARCH_TYPE, $this->getText($i), LANGUAGE_NOT_SPECIFIED);
+ search_index($i, SEARCH_TYPE, $this->getText($i), Language::LANGCODE_NOT_SPECIFIED);
}
for ($i = 1; $i <= 5; ++$i) {
- search_index($i + 7, SEARCH_TYPE_2, $this->getText2($i), LANGUAGE_NOT_SPECIFIED);
+ search_index($i + 7, SEARCH_TYPE_2, $this->getText2($i), Language::LANGCODE_NOT_SPECIFIED);
}
// No getText builder function for Japanese text; just a simple array.
foreach (array(
@@ -48,7 +50,7 @@ class SearchMatchTest extends SearchTestBase {
14 => 'ドルーパルが大好きよ!',
15 => 'コーヒーとケーキ',
) as $i => $jpn) {
- search_index($i, SEARCH_TYPE_JPN, $jpn, LANGUAGE_NOT_SPECIFIED);
+ search_index($i, SEARCH_TYPE_JPN, $jpn, Language::LANGCODE_NOT_SPECIFIED);
}
search_update_totals();
}
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php
index 1e3bf78..119bd4c 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php
@@ -7,6 +7,8 @@
namespace Drupal\search\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests that numbers can be searched, with more complex matching.
*/
@@ -47,7 +49,7 @@ class SearchNumberMatchingTest extends SearchTestBase {
$info = array(
'body' => array(array('value' => $num)),
'type' => 'page',
- 'language' => LANGUAGE_NOT_SPECIFIED,
+ 'language' => Language::LANGCODE_NOT_SPECIFIED,
);
$this->nodes[] = $this->drupalCreateNode($info);
}
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php
index 6e81e5e..e52dfd4 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php
@@ -7,6 +7,8 @@
namespace Drupal\search\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests that numbers can be searched.
*/
@@ -53,7 +55,7 @@ class SearchNumbersTest extends SearchTestBase {
$info = array(
'body' => array(array('value' => $num)),
'type' => 'page',
- 'language' => LANGUAGE_NOT_SPECIFIED,
+ 'language' => Language::LANGCODE_NOT_SPECIFIED,
'title' => $doc . ' number',
);
$this->nodes[$doc] = $this->drupalCreateNode($info);
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
index 63d9434..f6c8646 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
@@ -7,6 +7,8 @@
namespace Drupal\search\Tests;
+use Drupal\Core\Language\Language;
+
class SearchRankingTest extends SearchTestBase {
/**
@@ -70,7 +72,7 @@ class SearchRankingTest extends SearchTestBase {
// Add a comment to one of the nodes.
$edit = array();
$edit['subject'] = 'my comment title';
- $edit['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = 'some random comment';
+ $edit['comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]'] = 'some random comment';
$this->drupalGet('comment/reply/' . $nodes['comments'][1]->nid);
$this->drupalPost(NULL, $edit, t('Preview'));
$this->drupalPost(NULL, $edit, t('Save'));
diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc
index eaae71a..aed41f6 100644
--- a/core/modules/search/search.pages.inc
+++ b/core/modules/search/search.pages.inc
@@ -5,6 +5,8 @@
* User page callbacks for the Search module.
*/
+use Drupal\Core\Language\Language;
+
/**
* Page callback: Presents the search form and/or search results.
*
@@ -122,12 +124,12 @@ function template_preprocess_search_results(&$variables) {
* - content_attributes: HTML attributes for the content.
*/
function template_preprocess_search_result(&$variables) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$result = $variables['result'];
$variables['url'] = check_url($result['link']);
$variables['title'] = check_plain($result['title']);
- if (isset($result['language']) && $result['language'] != $language_interface->langcode && $result['language'] != LANGUAGE_NOT_SPECIFIED) {
+ if (isset($result['language']) && $result['language'] != $language_interface->langcode && $result['language'] != Language::LANGCODE_NOT_SPECIFIED) {
$variables['title_attributes']['lang'] = $result['language'];
$variables['content_attributes']['lang'] = $result['language'];
}
diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
index ce90382..46ad0cc 100644
--- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
+++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
@@ -7,6 +7,7 @@
namespace Drupal\serialization\Tests;
+use Drupal\Core\Language\Language;
use Drupal\serialization\Encoder\JsonEncoder;
use Drupal\serialization\Normalizer\ComplexDataNormalizer;
use Drupal\serialization\Normalizer\TypedDataNormalizer;
@@ -82,7 +83,7 @@ class EntitySerializationTest extends NormalizerTestBase {
array('value' => $this->entity->uuid()),
),
'langcode' => array(
- array('value' => LANGUAGE_NOT_SPECIFIED),
+ array('value' => Language::LANGCODE_NOT_SPECIFIED),
),
'default_langcode' => array(
array('value' => NULL),
@@ -138,7 +139,7 @@ class EntitySerializationTest extends NormalizerTestBase {
'id' => '<id><value>' . $this->entity->id() . '</value></id>',
'revision_id' => '<revision_id><value>' . $this->entity->getRevisionId() . '</value></revision_id>',
'uuid' => '<uuid><value>' . $this->entity->uuid() . '</value></uuid>',
- 'langcode' => '<langcode><value>' . LANGUAGE_NOT_SPECIFIED . '</value></langcode>',
+ 'langcode' => '<langcode><value>' . Language::LANGCODE_NOT_SPECIFIED . '</value></langcode>',
'default_langcode' => '<default_langcode><value/></default_langcode>',
'name' => '<name><value>' . $this->values['name'] . '</value></name>',
'type' => '<type><value>entity_test_mulrev</value></type>',
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
index 6e791b3..f07e249 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
@@ -14,6 +14,7 @@ use Drupal\Core\Config\StorageComparerManifest;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Database\ConnectionNotDefinedException;
use Drupal\Core\DrupalKernel;
+use Drupal\Core\Language\Language;
use ReflectionMethod;
use ReflectionObject;
@@ -846,7 +847,7 @@ abstract class TestBase {
*/
protected function prepareEnvironment() {
global $user, $conf;
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// When running the test runner within a test, back up the original database
// prefix and re-set the new/nested prefix in drupal_valid_test_ua().
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index af86db7..760aeed 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -12,6 +12,7 @@ use Drupal\Component\Utility\NestedArray;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\ConnectionNotDefinedException;
+use Drupal\Core\Language\Language;
use PDO;
use stdClass;
use DOMDocument;
@@ -215,7 +216,7 @@ abstract class WebTestBase extends TestBase {
* - status: NODE_PUBLISHED.
* - sticky: NODE_NOT_STICKY.
* - type: 'page'.
- * - langcode: LANGUAGE_NOT_SPECIFIED.
+ * - langcode: Language::LANGCODE_NOT_SPECIFIED.
* - uid: The currently logged in user, or the user running test.
* - revision: 1. (Backwards-compatible binary flag indicating whether a
* new revision should be created; use 1 to specify a new revision.)
@@ -235,7 +236,7 @@ abstract class WebTestBase extends TestBase {
'status' => NODE_PUBLISHED,
'sticky' => NODE_NOT_STICKY,
'type' => 'page',
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
);
// Add in comment settings for nodes.
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php
index 0a65746..7256c30 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php
@@ -7,6 +7,8 @@
namespace Drupal\statistics\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests statistics token replacement in strings.
*/
@@ -23,7 +25,7 @@ class StatisticsTokenReplaceTest extends StatisticsTestBase {
* Creates a node, then tests the statistics tokens generated from it.
*/
function testStatisticsTokenReplacement() {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Create user and node.
$user = $this->drupalCreateUser(array('create page content'));
diff --git a/core/modules/system/language.api.php b/core/modules/system/language.api.php
index 7c7375f..fb165a4 100644
--- a/core/modules/system/language.api.php
+++ b/core/modules/system/language.api.php
@@ -25,9 +25,9 @@
* The current path.
*/
function hook_language_switch_links_alter(array &$links, $type, $path) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(\Drupal\Core\Language\Language::TYPE_INTERFACE);
- if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language_interface->langcode])) {
+ if ($type == \Drupal\Core\Language\Language::TYPE_CONTENT && isset($links[$language_interface->langcode])) {
foreach ($links[$language_interface->langcode] as $link) {
$link['attributes']['class'][] = 'active-language';
}
@@ -189,7 +189,7 @@ function hook_language_fallback_candidates_alter(array &$fallback_candidates) {
* Here is a code snippet to transliterate some text:
* @code
* // Use the current default interface language.
- * $langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ * $langcode = language(\Drupal\Core\Language\Language::TYPE_INTERFACE)->langcode;
* // Instantiate the transliteration class.
* $trans = drupal_container()->get('transliteration');
* // Use this to transliterate some text.
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
index 746ab99..bb97d52 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Common;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -207,8 +208,8 @@ class CascadingStylesheetsTest extends WebTestBase {
*/
function testAlter() {
// Switch the language to a right to left language and add system.base.css.
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
- $language_interface->direction = LANGUAGE_RTL;
+ $language_interface = language(Language::TYPE_INTERFACE);
+ $language_interface->direction = Language::DIRECTION_RTL;
$path = drupal_get_path('module', 'system');
drupal_add_css($path . '/system.base.css');
@@ -217,7 +218,7 @@ class CascadingStylesheetsTest extends WebTestBase {
$this->assert(strpos($styles, $path . '/system.base-rtl.css') !== FALSE, 'CSS is alterable as right to left overrides are added.');
// Change the language back to left to right.
- $language_interface->direction = LANGUAGE_LTR;
+ $language_interface->direction = Language::DIRECTION_LTR;
}
/**
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
index 1f2575c..118a059 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Common;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -90,7 +91,7 @@ class FormatDateTest extends WebTestBase {
function testFormatDate() {
global $user;
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$timestamp = strtotime('2007-03-26T00:00:00+00:00');
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test all parameters.');
@@ -107,7 +108,7 @@ class FormatDateTest extends WebTestBase {
'predefined_langcode' => 'custom',
'langcode' => self::LANGCODE,
'name' => self::LANGCODE,
- 'direction' => LANGUAGE_LTR,
+ 'direction' => Language::DIRECTION_LTR,
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php
index aa2a237..0b7b200 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Entity;
+use Drupal\Core\Language\Language;
use Drupal\Core\Database\Database;
/**
@@ -140,7 +141,7 @@ class EntityCrudHookTest extends EntityUnitTestBase {
'comment' => 2,
'promote' => 0,
'sticky' => 0,
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'created' => REQUEST_TIME,
'changed' => REQUEST_TIME,
));
@@ -158,7 +159,7 @@ class EntityCrudHookTest extends EntityUnitTestBase {
'created' => REQUEST_TIME,
'changed' => REQUEST_TIME,
'status' => 1,
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$this->assertHookMessageOrder(array(
@@ -283,7 +284,7 @@ class EntityCrudHookTest extends EntityUnitTestBase {
'comment' => 2,
'promote' => 0,
'sticky' => 0,
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'created' => REQUEST_TIME,
'changed' => REQUEST_TIME,
));
@@ -342,7 +343,7 @@ class EntityCrudHookTest extends EntityUnitTestBase {
$vocabulary = entity_create('taxonomy_vocabulary', array(
'name' => 'Test vocabulary',
'vid' => 'test',
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'description' => NULL,
'module' => 'entity_crud_hook_test',
));
@@ -352,7 +353,7 @@ class EntityCrudHookTest extends EntityUnitTestBase {
$term = entity_create('taxonomy_term', array(
'vid' => $vocabulary->id(),
'name' => 'Test term',
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'description' => NULL,
'format' => 1,
));
@@ -411,7 +412,7 @@ class EntityCrudHookTest extends EntityUnitTestBase {
$vocabulary = entity_create('taxonomy_vocabulary', array(
'name' => 'Test vocabulary',
'vid' => 'test',
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'description' => NULL,
'module' => 'entity_crud_hook_test',
));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
index 29e1462..3c76f56 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
@@ -10,6 +10,7 @@ namespace Drupal\system\Tests\Entity;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Field\FieldInterface;
use Drupal\Core\Entity\Field\FieldItemInterface;
+use Drupal\Core\Language\Language;
use Drupal\Core\TypedData\TypedDataInterface;
/**
@@ -182,8 +183,8 @@ class EntityFieldTest extends EntityUnitTestBase {
$this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type)));
// Access the language field.
- $this->assertEqual(LANGUAGE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual(language_load(LANGUAGE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(language_load(Language::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
// Change the language by code.
$entity->langcode->value = language_default()->langcode;
@@ -191,7 +192,7 @@ class EntityFieldTest extends EntityUnitTestBase {
$this->assertEqual(language_default(), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
// Revert language by code then try setting it by language object.
- $entity->langcode->value = LANGUAGE_NOT_SPECIFIED;
+ $entity->langcode->value = Language::LANGCODE_NOT_SPECIFIED;
$entity->langcode->language = language_default();
$this->assertEqual(language_default()->langcode, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
$this->assertEqual(language_default(), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
@@ -325,8 +326,8 @@ class EntityFieldTest extends EntityUnitTestBase {
// Access the name field.
$this->assertEqual(1, $entity->id->value, format_string('%entity_type: ID value can be read.', array('%entity_type' => $entity_type)));
$this->assertTrue(is_string($entity->uuid->value), format_string('%entity_type: UUID value can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual(LANGUAGE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
- $this->assertEqual(language_load(LANGUAGE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(Language::LANGCODE_NOT_SPECIFIED, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type)));
+ $this->assertEqual(language_load(Language::LANGCODE_NOT_SPECIFIED), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type)));
$this->assertEqual($this->entity_user->uid, $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type)));
$this->assertEqual($this->entity_user->name, $entity->user_id->entity->name, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type)));
$this->assertEqual($this->entity_field_text, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type)));
@@ -489,7 +490,7 @@ class EntityFieldTest extends EntityUnitTestBase {
// the user name and other user entity strings as well.
$target_strings = array(
$entity->uuid->value,
- LANGUAGE_NOT_SPECIFIED,
+ Language::LANGCODE_NOT_SPECIFIED,
$this->entity_name,
// Bundle name.
$entity->bundle(),
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php
index 78ce17d..d3334ab 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Entity;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -63,7 +64,7 @@ class EntityFormTest extends WebTestBase {
* The entity type to run the tests with.
*/
protected function assertFormCRUD($entity_type) {
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$name1 = $this->randomName(8);
$name2 = $this->randomName(10);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php
index 958bfb5..f42ea78 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php
@@ -7,6 +7,8 @@
namespace Drupal\system\Tests\Entity;
+use Drupal\Core\Language\Language;
+
/**
* Tests the basic Entity API.
*/
@@ -83,11 +85,11 @@ class EntityQueryTest extends EntityUnitTestBase {
$bundles[] = $bundle;
}
// Each unit is a list of field name, langcode and a column-value array.
- $units[] = array($figures, LANGUAGE_NOT_SPECIFIED, array(
+ $units[] = array($figures, Language::LANGCODE_NOT_SPECIFIED, array(
'color' => 'red',
'shape' => 'triangle',
));
- $units[] = array($figures, LANGUAGE_NOT_SPECIFIED, array(
+ $units[] = array($figures, Language::LANGCODE_NOT_SPECIFIED, array(
'color' => 'blue',
'shape' => 'circle',
));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
index 012b909..1cfb1e0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
@@ -58,9 +58,9 @@ class EntityTranslationFormTest extends WebTestBase {
$web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer content types'));
$this->drupalLogin($web_user);
- // Create a node with language LANGUAGE_NOT_SPECIFIED.
+ // Create a node with language Language::LANGCODE_NOT_SPECIFIED.
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName(8);
$edit["body[$langcode][0][value]"] = $this->randomName(16);
@@ -85,14 +85,14 @@ class EntityTranslationFormTest extends WebTestBase {
// Enable language selector.
$this->drupalGet('admin/structure/types/manage/page');
- $edit = array('language_configuration[language_show]' => TRUE, 'language_configuration[langcode]' => LANGUAGE_NOT_SPECIFIED);
+ $edit = array('language_configuration[language_show]' => TRUE, 'language_configuration[langcode]' => Language::LANGCODE_NOT_SPECIFIED);
$this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
$this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.');
// Create a node with language.
$edit = array();
$langcode = $this->langcodes[0];
- $field_langcode = LANGUAGE_NOT_SPECIFIED;
+ $field_langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName(8);
$edit["body[$field_langcode][0][value]"] = $this->randomName(16);
$edit['langcode'] = $langcode;
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
index f5c1c52..3a9a412 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
@@ -110,13 +110,13 @@ class EntityTranslationTest extends EntityUnitTestBase {
'name' => 'test',
'user_id' => $GLOBALS['user']->uid,
));
- $this->assertEqual($entity->language()->langcode, LANGUAGE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity->language()->langcode, Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type)));
$this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type)));
// Set the value in default language.
$entity->set($this->field_name, array(0 => array('value' => 'default value')));
// Get the value.
- $this->assertEqual($entity->getTranslation(LANGUAGE_DEFAULT)->get($this->field_name)->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity->getTranslation(Language::LANGCODE_DEFAULT)->get($this->field_name)->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type)));
// Set the value in a certain language. As the entity is not
// language-specific it should use the default language and so ignore the
@@ -229,9 +229,9 @@ class EntityTranslationTest extends EntityUnitTestBase {
$entity = entity_create($entity_type, array('name' => $name, 'user_id' => $uid));
$entity->save();
$entity = entity_load($entity_type, $entity->id());
- $this->assertEqual($entity->language()->langcode, LANGUAGE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type)));
- $this->assertEqual($name, $entity->getTranslation(LANGUAGE_DEFAULT)->get('name')->value, format_string('%entity_type: The entity name has been correctly stored as language neutral.', array('%entity_type' => $entity_type)));
- $this->assertEqual($uid, $entity->getTranslation(LANGUAGE_DEFAULT)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as language neutral.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($entity->language()->langcode, Language::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($name, $entity->getTranslation(Language::LANGCODE_DEFAULT)->get('name')->value, format_string('%entity_type: The entity name has been correctly stored as language neutral.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($uid, $entity->getTranslation(Language::LANGCODE_DEFAULT)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as language neutral.', array('%entity_type' => $entity_type)));
// As fields, translatable properties should ignore the given langcode and
// use neutral language if the entity is not translatable.
$this->assertEqual($name, $entity->getTranslation($langcode)->get('name')->value, format_string('%entity_type: The entity name defaults to neutral language.', array('%entity_type' => $entity_type)));
@@ -248,9 +248,9 @@ class EntityTranslationTest extends EntityUnitTestBase {
$this->assertEqual($name, $entity->getTranslation($langcode)->get('name')->value, format_string('%entity_type: The entity name has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type)));
$this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type)));
// Translatable properties on a translatable entity should use default
- // language if LANGUAGE_NOT_SPECIFIED is passed.
- $this->assertEqual($name, $entity->getTranslation(LANGUAGE_NOT_SPECIFIED)->get('name')->value, format_string('%entity_type: The entity name defaults to the default language.', array('%entity_type' => $entity_type)));
- $this->assertEqual($uid, $entity->getTranslation(LANGUAGE_NOT_SPECIFIED)->get('user_id')->target_id, format_string('%entity_type: The entity author defaults to the default language.', array('%entity_type' => $entity_type)));
+ // language if Language::LANGCODE_NOT_SPECIFIED is passed.
+ $this->assertEqual($name, $entity->getTranslation(Language::LANGCODE_NOT_SPECIFIED)->get('name')->value, format_string('%entity_type: The entity name defaults to the default language.', array('%entity_type' => $entity_type)));
+ $this->assertEqual($uid, $entity->getTranslation(Language::LANGCODE_NOT_SPECIFIED)->get('user_id')->target_id, format_string('%entity_type: The entity author defaults to the default language.', array('%entity_type' => $entity_type)));
$this->assertEqual($name, $entity->get('name')->value, format_string('%entity_type: The entity name can be retrieved without specifying a language.', array('%entity_type' => $entity_type)));
$this->assertEqual($uid, $entity->get('user_id')->target_id, format_string('%entity_type: The entity author can be retrieved without specifying a language.', array('%entity_type' => $entity_type)));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php
index f5c589b..09044e6 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php
@@ -49,10 +49,10 @@ class LanguageSelectElementTest extends WebTestBase {
$this->drupalGet('form-test/language_select');
// Check that the language fields were rendered on the page.
- $ids = array('edit-languages-all' => LANGUAGE_ALL,
- 'edit-languages-configurable' => LANGUAGE_CONFIGURABLE,
- 'edit-languages-locked' => LANGUAGE_LOCKED,
- 'edit-languages-config-and-locked' => LANGUAGE_CONFIGURABLE | LANGUAGE_LOCKED);
+ $ids = array('edit-languages-all' => Language::STATE_ALL,
+ 'edit-languages-configurable' => Language::STATE_CONFIGURABLE,
+ 'edit-languages-locked' => Language::STATE_LOCKED,
+ 'edit-languages-config-and-locked' => Language::STATE_CONFIGURABLE | Language::STATE_LOCKED);
foreach ($ids as $id => $flags) {
$this->assertField($id, format_string('The @id field was found on the page.', array('@id' => $id)));
$options = array();
@@ -90,7 +90,7 @@ class LanguageSelectElementTest extends WebTestBase {
$values = drupal_json_decode($this->drupalGetContent());
$this->assertEqual($values['languages_all'], 'xx');
$this->assertEqual($values['languages_configurable'], 'en');
- $this->assertEqual($values['languages_locked'], LANGUAGE_NOT_SPECIFIED);
+ $this->assertEqual($values['languages_locked'], Language::LANGCODE_NOT_SPECIFIED);
$this->assertEqual($values['languages_config_and_locked'], 'dummy_value');
$this->assertEqual($values['language_custom_options'], 'opt2');
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php
index 155fdb8..3dad764 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Mail;
+use Drupal\Core\Language\Language;
use Drupal\Core\Mail\MailInterface;
use Drupal\simpletest\WebTestBase;
@@ -49,7 +50,7 @@ class MailTest extends WebTestBase implements MailInterface {
* Assert that the pluggable mail system is functional.
*/
public function testPluggableFramework() {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Use MailTestCase for sending a message.
$message = drupal_mail('simpletest', 'mail_test', 'testing@example.com', $language_interface->langcode);
@@ -64,7 +65,7 @@ class MailTest extends WebTestBase implements MailInterface {
* @see simpletest_mail_alter()
*/
public function testCancelMessage() {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Reset the class variable holding a copy of the last sent message.
self::$sent_message = NULL;
diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
index 2801321..c2d6593 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
@@ -7,6 +7,8 @@
namespace Drupal\system\Tests\Menu;
+use Drupal\Core\Language\Language;
+
/**
* Menu breadcrumbs related tests.
*/
@@ -60,7 +62,7 @@ class BreadcrumbTest extends MenuTestBase {
$admin = $home + array('admin' => t('Administration'));
$config = $admin + array('admin/config' => t('Configuration'));
$type = 'article';
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Verify breadcrumbs for default local tasks.
$expected = array(
diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php b/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php
index cd432a7..8936815 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php
@@ -148,7 +148,7 @@ class AliasTest extends PathUnitTestBase {
// Test the situation where the alias and language are the same, but
// the source differs. The newer alias record should be returned.
$pathObject->save('user/2', 'bar');
- $this->assertEqual($aliasManager->getSystemPath('bar'), 'user/2', 'Newer alias record is returned when comparing two LANGUAGE_NOT_SPECIFIED paths with the same alias.');
+ $this->assertEqual($aliasManager->getSystemPath('bar'), 'user/2', 'Newer alias record is returned when comparing two Language::LANGCODE_NOT_SPECIFIED paths with the same alias.');
}
/**
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php
index ff16e61..4d98340 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\System;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -51,7 +52,7 @@ class DateFormatsLanguageTest extends WebTestBase {
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
// Set language negotiation.
- $language_type = LANGUAGE_TYPE_INTERFACE;
+ $language_type = Language::TYPE_INTERFACE;
$edit = array(
"{$language_type}[enabled][language-url]" => TRUE,
);
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php
index 7e89cf7..9d96be8 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\System;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
class PageTitleFilteringTest extends WebTestBase {
@@ -69,7 +70,7 @@ class PageTitleFilteringTest extends WebTestBase {
drupal_set_title($title, PASS_THROUGH);
$this->assertTrue(strpos(drupal_get_title(), '<em>') !== FALSE, 'Tags in title are not converted to entities when $output is PASS_THROUGH.');
// Generate node content.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array(
"title" => '!SimpleTest! ' . $title . $this->randomName(20),
"body[$langcode][0][value]" => '!SimpleTest! test body' . $this->randomName(200),
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
index e869c71..d32f297 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\System;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -32,7 +33,7 @@ class TokenReplaceTest extends WebTestBase {
$node = $this->drupalCreateNode(array('uid' => $account->uid));
$node->title = '<blink>Blinking Text</blink>';
global $user;
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$source = '[node:title]'; // Title of the node we passed in
$source .= '[node:author:name]'; // Node author's name
@@ -78,7 +79,7 @@ class TokenReplaceTest extends WebTestBase {
*/
function testSystemTokenRecognition() {
$token_service = \Drupal::token();
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Generate prefixes and suffixes for the token context.
$tests = array(
@@ -108,7 +109,7 @@ class TokenReplaceTest extends WebTestBase {
*/
function testSystemSiteTokenReplacement() {
$token_service = \Drupal::token();
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$url_options = array(
'absolute' => TRUE,
'language' => $language_interface,
@@ -152,7 +153,7 @@ class TokenReplaceTest extends WebTestBase {
*/
function testSystemDateTokenReplacement() {
$token_service = \Drupal::token();
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Set time to one hour before request.
$date = REQUEST_TIME - 3600;
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php
index 621f114..3fb464e 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/FieldUpgradePathTest.php
@@ -6,6 +6,7 @@
*/
namespace Drupal\system\Tests\Upgrade;
+use Drupal\Core\Language\Language;
/**
* Tests upgrade of system variables.
@@ -235,7 +236,7 @@ class FieldUpgradePathTest extends UpgradePathTestBase {
));
field_attach_load('node', array(2 => $entity), FIELD_LOAD_CURRENT, array('field_id' => $deleted_field['uuid'], 'deleted' => 1));
$deleted_value = $entity->get('test_deleted_field');
- $this->assertEqual($deleted_value[LANGUAGE_NOT_SPECIFIED][0]['value'], 'Some deleted value');
+ $this->assertEqual($deleted_value[Language::LANGCODE_NOT_SPECIFIED][0]['value'], 'Some deleted value');
// Check that creation of a new node works as expected.
$value = $this->randomName();
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php
index 6b669a5..4771869 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php
@@ -9,6 +9,8 @@ namespace Drupal\system\Tests\Upgrade;
use Drupal\Core\Database\DatabaseException;
+use Drupal\Core\Language\Language;
+
/**
* Tests upgrading a filled database with language data.
*
@@ -42,7 +44,7 @@ class LanguageUpgradePathTest extends UpgradePathTestBase {
// Ensure Catalan was properly upgraded to be the new default language.
$this->assertTrue(language_default()->langcode == 'ca', 'Catalan is the default language');
- $languages = language_list(LANGUAGE_ALL);
+ $languages = language_list(Language::STATE_ALL);
foreach ($languages as $language) {
$this->assertTrue($language->default == ($language->langcode == 'ca'), format_string('@language default property properly set', array('@language' => $language->name)));
}
@@ -69,7 +71,7 @@ class LanguageUpgradePathTest extends UpgradePathTestBase {
$translation_source_nid = 52;
$translation_nid = 53;
// Check directly for the $node->langcode property.
- $this->assertEqual(node_load($language_none_nid)->langcode, LANGUAGE_NOT_SPECIFIED, "'language' property was renamed to 'langcode' for LANGUAGE_NOT_SPECIFIED node.");
+ $this->assertEqual(node_load($language_none_nid)->langcode, Language::LANGCODE_NOT_SPECIFIED, "'language' property was renamed to 'langcode' for Language::LANGCODE_NOT_SPECIFIED node.");
$this->assertEqual(node_load($spanish_nid)->langcode, 'ca', "'language' property was renamed to 'langcode' for Catalan node.");
// Check that the translation table works correctly.
$this->drupalGet("node/$translation_source_nid/translate");
@@ -98,9 +100,9 @@ class LanguageUpgradePathTest extends UpgradePathTestBase {
$this->assertEqual($term->langcode, 'ca');
// A langcode property was added to files. Check that existing files got
- // assigned LANGUAGE_NOT_SPECIFIED.
+ // assigned Language::LANGCODE_NOT_SPECIFIED.
$file = db_query('SELECT * FROM {file_managed} WHERE fid = :fid', array(':fid' => 1))->fetchObject();
- $this->assertEqual($file->langcode, LANGUAGE_NOT_SPECIFIED);
+ $this->assertEqual($file->langcode, Language::LANGCODE_NOT_SPECIFIED);
// Check if language negotiation weights were renamed properly. This is a
// reproduction of the previous weights from the dump.
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php
index cb68737..c85f5e4 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php
@@ -7,6 +7,8 @@
namespace Drupal\system\Tests\Upgrade;
+use Drupal\Core\Language\Language;
+
/**
* Tests upgrading a filled database with user picture data.
*
@@ -44,7 +46,7 @@ class UserPictureUpgradePathTest extends UpgradePathTestBase {
$this->assertIdentical($instance['settings']['default_image'][0], $file->id(), 'Default user picture has been migrated.');
$this->assertEqual($file->uri, 'public://user_pictures_dir/druplicon.png', 'File id matches the uri expected.');
$this->assertEqual($file->filename, 'druplicon.png');
- $this->assertEqual($file->langcode, LANGUAGE_NOT_SPECIFIED);
+ $this->assertEqual($file->langcode, Language::LANGCODE_NOT_SPECIFIED);
$this->assertEqual($file->filemime, 'image/png');
$this->assertFalse(empty($file->uuid));
@@ -67,7 +69,7 @@ class UserPictureUpgradePathTest extends UpgradePathTestBase {
// Check the user picture and file usage record.
$user = user_load(1);
- $file = file_load($user->user_picture[LANGUAGE_NOT_SPECIFIED][0]['fid']);
+ $file = file_load($user->user_picture[Language::LANGCODE_NOT_SPECIFIED][0]['fid']);
$this->assertEqual('public://user_pictures_dir/faked_image.png', $file->uri);
$usage = file_usage()->listUsage($file);
$this->assertEqual(1, $usage['file']['user'][1]);
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index aa79df9..f0ad115 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -1795,7 +1795,7 @@ function hook_custom_theme() {
*/
function hook_watchdog(array $log_entry) {
global $base_url;
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(\Drupal\Core\Language\Language::TYPE_INTERFACE);
$severity_list = array(
WATCHDOG_EMERGENCY => t('Emergency'),
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index b7b4209..3824136 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -2,6 +2,7 @@
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Database\Database;
+use Drupal\Core\Language\Language;
/**
* @file
@@ -1308,8 +1309,8 @@ function system_update_8004() {
// Files can be language-specific (e.g., a scanned document) or not (e.g.,
// a photograph). For a site being updated, Drupal does not have a way to
// determine which existing files are language-specific and in what
- // language. Our best guess is to set all of them to LANGUAGE_NOT_SPECIFIED.
- $langcode_field['initial'] = LANGUAGE_NOT_SPECIFIED;
+ // language. Our best guess is to set all of them to Language::LANGCODE_NOT_SPECIFIED.
+ $langcode_field['initial'] = Language::LANGCODE_NOT_SPECIFIED;
db_add_field('file_managed', 'langcode', $langcode_field);
}
}
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index 7c7343c..bf0977b 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -7,6 +7,7 @@
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\Cache;
+use Drupal\Core\Language\Language;
use Drupal\Core\Database\Database;
use Drupal\Core\Utility\ModuleInfo;
use Drupal\Core\TypedData\Primitive;
@@ -484,7 +485,7 @@ function system_element_info() {
);
$types['language_select'] = array(
'#input' => TRUE,
- '#default_value' => LANGUAGE_NOT_SPECIFIED,
+ '#default_value' => Language::LANGCODE_NOT_SPECIFIED,
);
$types['weight'] = array(
'#input' => TRUE,
diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php
index 9da187d..fe12b22 100644
--- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php
+++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php
@@ -9,6 +9,7 @@ namespace Drupal\entity_test;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityAccessController;
+use Drupal\Core\Language\Language;
use Drupal\user\Plugin\Core\Entity\User;
/**
@@ -21,7 +22,7 @@ class EntityTestAccessController extends EntityAccessController {
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, User $account) {
if ($operation === 'view') {
- if ($langcode != LANGUAGE_DEFAULT) {
+ if ($langcode != Language::LANGCODE_DEFAULT) {
return user_access('view test entity translations', $account);
}
return user_access('view test entity', $account);
diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php
index acea3a1..185fdab 100644
--- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php
+++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php
@@ -7,6 +7,7 @@
namespace Drupal\entity_test;
use Drupal\Core\Entity\EntityFormControllerNG;
+use Drupal\Core\Language\Language;
/**
* Form controller for the test entity edit forms.
@@ -47,7 +48,7 @@ class EntityTestFormController extends EntityFormControllerNG {
'#title' => t('Language'),
'#type' => 'language_select',
'#default_value' => $entity->language()->langcode,
- '#languages' => LANGUAGE_ALL,
+ '#languages' => Language::STATE_ALL,
);
return $form;
diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php
index aa6bda3..25167c7 100644
--- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php
+++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php
@@ -10,6 +10,7 @@ namespace Drupal\entity_test\Plugin\Core\Entity;
use Drupal\Core\Entity\EntityNG;
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\Annotation\Translation;
+use Drupal\Core\Language\Language;
/**
* Defines the test entity class.
@@ -89,7 +90,7 @@ class EntityTest extends EntityNG {
/**
* Overrides Drupal\entity\Entity::label().
*/
- public function label($langcode = LANGUAGE_DEFAULT) {
+ public function label($langcode = Language::LANGCODE_DEFAULT) {
$info = $this->entityInfo();
if (isset($info['entity_keys']['label']) && $info['entity_keys']['label'] == 'name') {
return $this->getTranslation($langcode)->name->value;
diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module
index 97657a1..e273584 100644
--- a/core/modules/system/tests/modules/form_test/form_test.module
+++ b/core/modules/system/tests/modules/form_test/form_test.module
@@ -7,6 +7,7 @@
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Database;
+use Drupal\Core\Language\Language;
use Drupal\form_test\Callbacks;
use Drupal\form_test\FormTestObject;
use Drupal\form_test\SystemConfigFormTestForm;
@@ -1334,26 +1335,26 @@ function form_test_language_select() {
$form['languages_all'] = array(
'#type' => 'language_select',
- '#languages' => LANGUAGE_ALL,
+ '#languages' => Language::STATE_ALL,
'#default_value' => 'xx',
);
$form['languages_configurable'] = array(
'#type' => 'language_select',
- '#languages' => LANGUAGE_CONFIGURABLE,
+ '#languages' => Language::STATE_CONFIGURABLE,
'#default_value' => 'en',
);
$form['languages_locked'] = array(
'#type' => 'language_select',
- '#languages' => LANGUAGE_LOCKED,
+ '#languages' => Language::STATE_LOCKED,
);
$form['languages_config_and_locked'] = array(
'#type' => 'language_select',
- '#languages' => LANGUAGE_CONFIGURABLE | LANGUAGE_LOCKED,
+ '#languages' => Language::STATE_CONFIGURABLE | Language::STATE_LOCKED,
'#default_value' => 'dummy_value',
);
$form['language_custom_options'] = array(
'#type' => 'language_select',
- '#languages' => LANGUAGE_CONFIGURABLE | LANGUAGE_LOCKED,
+ '#languages' => Language::STATE_CONFIGURABLE | Language::STATE_LOCKED,
'#options' => array('opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option'),
'#default_value' => 'opt2',
);
@@ -2264,7 +2265,7 @@ function form_test_two_instances() {
'uid' => $user->uid,
'name' => (isset($user->name) ? $user->name : ''),
'type' => 'page',
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$node2 = clone($node1);
$return['node_form_1'] = entity_get_form($node1);
diff --git a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php
index 07ba59e..139a01f 100644
--- a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php
+++ b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/CachedMockBlockManager.php
@@ -7,6 +7,7 @@
namespace Drupal\plugin_test\Plugin;
+use Drupal\Core\Language\Language;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
/**
@@ -24,6 +25,6 @@ class CachedMockBlockManager extends MockBlockManager {
// The CacheDecorator allows us to cache these plugin definitions for
// quicker retrieval. In this case we are generating a cache key by
// language.
- $this->discovery = new CacheDecorator($this->discovery, 'mock_block:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'cache', 1542646800, array('plugin_test'));
+ $this->discovery = new CacheDecorator($this->discovery, 'mock_block:' . language(Language::TYPE_INTERFACE)->langcode, 'cache', 1542646800, array('plugin_test'));
}
}
diff --git a/core/modules/system/tests/upgrade/drupal-7.language.database.php b/core/modules/system/tests/upgrade/drupal-7.language.database.php
index 5687361..5ecf769 100644
--- a/core/modules/system/tests/upgrade/drupal-7.language.database.php
+++ b/core/modules/system/tests/upgrade/drupal-7.language.database.php
@@ -422,7 +422,7 @@ db_insert('variable')->fields(array(
// Add sample nodes to test language assignment and translation functionality.
// The first node is also used for testing comment language functionality. This
-// is a simple node with LANGUAGE_NOT_SPECIFIED as language code. The second
+// is a simple node with Language::LANGCODE_NOT_SPECIFIED as language code. The second
// node is a Catalan node (language code 'ca'). The third and fourth node are a
// translation set with an English source translation (language code 'en') and
// a Chuvash translation (language code 'cv').
@@ -545,7 +545,7 @@ db_insert('node_revision')->fields(array(
'vid' => '70',
'uid' => '6',
'title' => 'Node title 50',
- 'log' => 'Added a LANGUAGE_NOT_SPECIFIED node to comment on.',
+ 'log' => 'Added a Language::LANGCODE_NOT_SPECIFIED node to comment on.',
'timestamp' => '1314997642',
'status' => '1',
'comment' => '2',
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php
index 55c3e07..28741ec 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Term.php
@@ -10,6 +10,7 @@ namespace Drupal\taxonomy\Plugin\Core\Entity;
use Drupal\Core\Entity\EntityNG;
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\Annotation\Translation;
+use Drupal\Core\Language\Language;
use Drupal\taxonomy\TermInterface;
/**
@@ -121,8 +122,8 @@ class Term extends EntityNG implements TermInterface {
* @var array
*/
protected $values = array(
- 'langcode' => array(LANGUAGE_DEFAULT => array(0 => array('value' => LANGUAGE_NOT_SPECIFIED))),
- 'weight' => array(LANGUAGE_DEFAULT => array(0 => array('value' => 0))),
+ 'langcode' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => Language::LANGCODE_NOT_SPECIFIED))),
+ 'weight' => array(Language::LANGCODE_DEFAULT => array(0 => array('value' => 0))),
);
/**
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php
index 24d252b..832a0cf 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php
@@ -8,6 +8,7 @@
namespace Drupal\taxonomy;
use Drupal\Core\Entity\EntityFormControllerNG;
+use Drupal\Core\Language\Language;
/**
* Base for controller for taxonomy term edit forms.
@@ -45,7 +46,7 @@ class TermFormController extends EntityFormControllerNG {
$form['langcode'] = array(
'#type' => 'language_select',
'#title' => t('Language'),
- '#languages' => LANGUAGE_ALL,
+ '#languages' => Language::STATE_ALL,
'#default_value' => $term->langcode->value,
'#access' => !is_null($language_configuration['language_show']) && $language_configuration['language_show'],
);
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php
index 778b1a0..5a34e15 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php
@@ -9,6 +9,8 @@ namespace Drupal\taxonomy\Tests;
use Drupal\Core\Datetime\DrupalDateTime;
+use Drupal\Core\Language\Language;
+
/**
* Test for legacy node bug.
*/
@@ -35,7 +37,7 @@ class LegacyTest extends TaxonomyTestBase {
*/
function testTaxonomyLegacyNode() {
// Posts an article with a taxonomy term and a date prior to 1970.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$date = new DrupalDateTime('1969-01-01 00:00:00');
$edit = array();
$edit['title'] = $this->randomName();
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
index d4be486..118e813 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
@@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests the rendering of term reference fields in RSS feeds.
*/
@@ -92,7 +94,7 @@ class RssTest extends TaxonomyTestBase {
// Post an article.
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName();
$edit[$this->instance['field_name'] . '[' . $langcode . '][]'] = $term1->id();
$this->drupalPost('node/add/article', $edit, t('Save'));
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php
index 77b9b1c..a8aefcb 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php
@@ -7,6 +7,7 @@
namespace Drupal\taxonomy\Tests;
+use Drupal\Core\Language\Language;
use Drupal\Core\Entity\Field\FieldInterface;
use Drupal\Core\Entity\Field\FieldItemInterface;
use Drupal\field\Tests\FieldUnitTestBase;
@@ -39,7 +40,7 @@ class TaxonomyTermReferenceItemTest extends FieldUnitTestBase {
$vocabulary = entity_create('taxonomy_vocabulary', array(
'name' => $this->randomName(),
'vid' => drupal_strtolower($this->randomName()),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$vocabulary->save();
$field = array(
@@ -65,7 +66,7 @@ class TaxonomyTermReferenceItemTest extends FieldUnitTestBase {
$this->term = entity_create('taxonomy_term', array(
'name' => $this->randomName(),
'vid' => $vocabulary->id(),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$this->term->save();
}
@@ -101,7 +102,7 @@ class TaxonomyTermReferenceItemTest extends FieldUnitTestBase {
$term2 = entity_create('taxonomy_term', array(
'name' => $this->randomName(),
'vid' => $this->term->vid->value,
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$term2->save();
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php
index 9ce20e8..4ae4823 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\taxonomy\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -39,7 +40,7 @@ abstract class TaxonomyTestBase extends WebTestBase {
'name' => $this->randomName(),
'description' => $this->randomName(),
'vid' => drupal_strtolower($this->randomName()),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'weight' => mt_rand(0, 10),
));
$vocabulary->save();
@@ -58,7 +59,7 @@ abstract class TaxonomyTestBase extends WebTestBase {
// Use the first available text format.
'format' => $format->format,
'vid' => $vocabulary->id(),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$term->save();
return $term;
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
index 627f762..8284e39 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
@@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests a taxonomy term reference field that allows multiple vocabularies.
*/
@@ -86,7 +88,7 @@ class TermFieldMultipleVocabularyTest extends TaxonomyTestBase {
$term2 = $this->createTerm($this->vocabulary2);
// Submit an entity with both terms.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$this->drupalGet('test-entity/add/test_bundle');
$this->assertFieldByName("{$this->field_name}[$langcode][]", '', 'Widget is displayed');
$edit = array(
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
index 27184d8..541d7be 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
@@ -7,6 +7,7 @@
namespace Drupal\taxonomy\Tests;
+use Drupal\Core\Language\Language;
use Drupal\field\FieldValidationException;
/**
@@ -77,7 +78,7 @@ class TermFieldTest extends TaxonomyTestBase {
*/
function testTaxonomyTermFieldValidation() {
// Test valid and invalid values with field_attach_validate().
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$entity = field_test_create_entity();
$term = $this->createTerm($this->vocabulary);
$entity->{$this->field_name}[$langcode][0]['tid'] = $term->id();
@@ -109,7 +110,7 @@ class TermFieldTest extends TaxonomyTestBase {
$term = $this->createTerm($this->vocabulary);
// Display creation form.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$this->drupalGet('test-entity/add/test_bundle');
$this->assertFieldByName("{$this->field_name}[$langcode]", '', 'Widget is displayed.');
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php
index 4c2202c..d6280c8 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php
@@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests the hook implementations that maintain the taxonomy index.
*/
@@ -105,7 +107,7 @@ class TermIndexTest extends TaxonomyTestBase {
// Post an article.
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $this->randomName();
$edit["{$this->field_name_1}[$langcode][]"] = $term_1->id();
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php
index f9fb10b..4fff183 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php
@@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Tests for taxonomy term functions.
*/
@@ -108,7 +110,7 @@ class TermTest extends TaxonomyTestBase {
// Post an article.
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $this->randomName();
$edit[$this->instance['field_name'] . '[' . $langcode . '][]'] = $term1->id();
@@ -160,7 +162,7 @@ class TermTest extends TaxonomyTestBase {
);
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $this->randomName();
// Insert the terms in a comma separated list. Vocabulary 1 is a
@@ -517,7 +519,7 @@ class TermTest extends TaxonomyTestBase {
// Create a term and a node using it.
$term = $this->createTerm($this->vocabulary);
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array();
$edit["title"] = $this->randomName(8);
$edit["body[$langcode][0][value]"] = $this->randomName(16);
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php
index f719fd7..15e0ccb 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php
@@ -7,6 +7,7 @@
namespace Drupal\taxonomy\Tests;
+use Drupal\Core\Language\Language;
use Drupal\translation_entity\Tests\EntityTranslationUITest;
/**
@@ -59,7 +60,7 @@ class TermTranslationUITest extends EntityTranslationUITest {
'name' => $this->bundle,
'description' => $this->randomName(),
'vid' => $this->bundle,
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'weight' => mt_rand(0, 10),
));
$this->vocabulary->save();
@@ -108,7 +109,7 @@ class TermTranslationUITest extends EntityTranslationUITest {
'name' => 'untranslatable_voc',
'description' => $this->randomName(),
'vid' => 'untranslatable_voc',
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'weight' => mt_rand(0, 10),
));
$untranslatable_vocabulary->save();
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php
index 2d3657e..9bd8b2f 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php
@@ -7,6 +7,8 @@
namespace Drupal\taxonomy\Tests;
+use Drupal\Core\Language\Language;
+
/**
* Test taxonomy token replacement in strings.
*/
@@ -25,7 +27,7 @@ class TokenReplaceTest extends TaxonomyTestBase {
$this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access'));
$this->drupalLogin($this->admin_user);
$this->vocabulary = $this->createVocabulary();
- $this->langcode = LANGUAGE_NOT_SPECIFIED;
+ $this->langcode = Language::LANGCODE_NOT_SPECIFIED;
$field = array(
'field_name' => 'taxonomy_' . $this->vocabulary->id(),
@@ -65,7 +67,7 @@ class TokenReplaceTest extends TaxonomyTestBase {
*/
function testTaxonomyTokenReplacement() {
$token_service = \Drupal::token();
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
// Create two taxonomy terms.
$term1 = $this->createTerm($this->vocabulary);
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php
index e71cf97..74c546b 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\taxonomy\Tests\Views;
+use Drupal\Core\Language\Language;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
@@ -139,7 +140,7 @@ abstract class TaxonomyTestBase extends ViewTestBase {
// Use the first available text format.
'format' => $format->format,
'vid' => $this->vocabulary->id(),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$term->save();
return $term;
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php
index 96e8697..f6d7f42 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php
@@ -8,6 +8,7 @@
namespace Drupal\taxonomy;
use Drupal\Core\Entity\EntityFormController;
+use Drupal\Core\Language\Language;
/**
* Base form controller for vocabulary edit forms.
@@ -53,7 +54,7 @@ class VocabularyFormController extends EntityFormController {
$form['langcode'] = array(
'#type' => 'language_select',
'#title' => t('Vocabulary language'),
- '#languages' => LANGUAGE_ALL,
+ '#languages' => Language::STATE_ALL,
'#default_value' => $vocabulary->langcode,
);
if (module_exists('language')) {
diff --git a/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php b/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php
index 052cfe3..dbc8524 100644
--- a/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php
+++ b/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php
@@ -8,6 +8,7 @@
namespace Drupal\text\Tests\Formatter;
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Language\Language;
use Drupal\entity\Plugin\Core\Entity\EntityDisplay;
use Drupal\simpletest\DrupalUnitTestBase;
@@ -89,7 +90,7 @@ class TextPlainUnitTest extends DrupalUnitTestBase {
));
$this->display->save();
- $this->langcode = LANGUAGE_NOT_SPECIFIED;
+ $this->langcode = Language::LANGCODE_NOT_SPECIFIED;
}
/**
diff --git a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
index e12553f..9aed6ee 100644
--- a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
+++ b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
@@ -7,6 +7,7 @@
namespace Drupal\text\Tests;
+use Drupal\Core\Language\Language;
use Drupal\field\FieldValidationException;
use Drupal\simpletest\WebTestBase;
@@ -67,7 +68,7 @@ class TextFieldTest extends WebTestBase {
// Test valid and invalid values with field_attach_validate().
$entity = field_test_create_entity();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
for ($i = 0; $i <= $max_length + 2; $i++) {
$entity->{$this->field['field_name']}[$langcode][0]['value'] = str_repeat('x', $i);
try {
@@ -119,7 +120,7 @@ class TextFieldTest extends WebTestBase {
->setComponent($this->field_name)
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
@@ -181,7 +182,7 @@ class TextFieldTest extends WebTestBase {
->setComponent($this->field_name)
->save();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
// Disable all text formats besides the plain text fallback format.
$this->drupalLogin($this->admin_user);
diff --git a/core/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php b/core/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php
index df81ba3..113c724 100644
--- a/core/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php
+++ b/core/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php
@@ -7,6 +7,7 @@
namespace Drupal\text\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -69,7 +70,7 @@ class TextTranslationTest extends WebTestBase {
$this->drupalLogin($this->translator);
// Create content.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$body = $this->randomName();
$edit = array(
'title' => $this->randomName(),
@@ -112,7 +113,7 @@ class TextTranslationTest extends WebTestBase {
// Populate the body field: the first item gets the "Full HTML" input
// format, the second one "Basic HTML".
$formats = array('full_html', 'basic_html');
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
foreach ($body as $delta => $value) {
$edit = array(
"body[$langcode][$delta][value]" => $value,
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index 5bc4534..c9f0c22 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -5,6 +5,7 @@
* Administration toolbar for quick access to top level administration items.
*/
+use Drupal\Core\Language\Language;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Template\Attribute;
use Drupal\Component\Utility\Crypt;
@@ -625,7 +626,7 @@ function toolbar_library_info() {
*/
function _toolbar_get_subtree_hash() {
global $user;
- $cid = $user->uid . ':' . language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ $cid = $user->uid . ':' . language(Language::TYPE_INTERFACE)->langcode;
if ($cache = cache('toolbar')->get($cid)) {
$hash = $cache->data;
}
diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
index 0e7c429..20883ad 100644
--- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
+++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
@@ -7,6 +7,7 @@
namespace Drupal\tracker\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -110,7 +111,7 @@ class TrackerTest extends WebTestBase {
));
$comment = array(
'subject' => $this->randomName(),
- 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
+ 'comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
);
$this->drupalPost('comment/reply/' . $other_published_my_comment->nid, $comment, t('Save'));
@@ -170,7 +171,7 @@ class TrackerTest extends WebTestBase {
// Add a comment to the page.
$comment = array(
'subject' => $this->randomName(),
- 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
+ 'comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
);
// The new comment is automatically viewed by the current user.
$this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save'));
@@ -183,7 +184,7 @@ class TrackerTest extends WebTestBase {
// Add another comment as other_user.
$comment = array(
'subject' => $this->randomName(),
- 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
+ 'comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
);
// If the comment is posted in the same second as the last one then Drupal
// can't tell the difference, so we wait one second here.
@@ -216,7 +217,7 @@ class TrackerTest extends WebTestBase {
$this->drupalLogin($this->other_user);
$comment = array(
'subject' => $this->randomName(),
- 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
+ 'comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
);
$this->drupalPost('comment/reply/' . $nodes[3]->nid, $comment, t('Save'));
diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php b/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php
index 91efe67..1ae4ba6 100644
--- a/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php
+++ b/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php
@@ -7,6 +7,7 @@
namespace Drupal\tracker\Tests\Views;
+use Drupal\Core\Language\Language;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\Tests\ViewTestData;
@@ -43,7 +44,7 @@ abstract class TrackerTestBase extends ViewTestBase {
$this->comment = entity_create('comment', array(
'nid' => $this->node->id(),
'subject' => $this->randomName(),
- 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
+ 'comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
));
}
diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
index df2c386..4fc436a 100644
--- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
+++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
@@ -8,6 +8,7 @@
namespace Drupal\translation\Tests;
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -105,7 +106,7 @@ class TranslationTest extends WebTestBase {
// Attempt a resubmission of the form - this emulates using the back button
// to return to the page then resubmitting the form without a refresh.
$edit = array();
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $this->randomName();
$edit["body[$langcode][0][value]"] = $this->randomName();
$this->drupalPost('node/add/page', $edit, t('Save'), array('query' => array('translation' => $node->nid, 'language' => 'es')));
@@ -114,7 +115,7 @@ class TranslationTest extends WebTestBase {
// Update original and mark translation as outdated.
$node_body = $this->randomName();
- $node->body[LANGUAGE_NOT_SPECIFIED][0]['value'] = $node_body;
+ $node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'] = $node_body;
$edit = array();
$edit["body[$langcode][0][value]"] = $node_body;
$edit['translation[retranslate]'] = TRUE;
@@ -135,9 +136,9 @@ class TranslationTest extends WebTestBase {
// Confirm that language neutral is an option for translators when there are
// disabled languages.
$this->drupalGet('node/add/page');
- $this->assertFieldByXPath('//select[@name="langcode"]//option', LANGUAGE_NOT_SPECIFIED, 'Language neutral is available in language selection with disabled languages.');
- $node2 = $this->createPage($this->randomName(), $this->randomName(), LANGUAGE_NOT_SPECIFIED);
- $this->assertRaw($node2->body[LANGUAGE_NOT_SPECIFIED][0]['value'], 'Language neutral content created with disabled languages available.');
+ $this->assertFieldByXPath('//select[@name="langcode"]//option', Language::LANGCODE_NOT_SPECIFIED, 'Language neutral is available in language selection with disabled languages.');
+ $node2 = $this->createPage($this->randomName(), $this->randomName(), Language::LANGCODE_NOT_SPECIFIED);
+ $this->assertRaw($node2->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'], 'Language neutral content created with disabled languages available.');
// Leave just one language installed and check that the translation overview
// page is still accessible.
@@ -215,7 +216,7 @@ class TranslationTest extends WebTestBase {
// Create a language neutral node and check that the language switcher is
// left untouched.
- $node2 = $this->createPage($this->randomName(), $this->randomName(), LANGUAGE_NOT_SPECIFIED);
+ $node2 = $this->createPage($this->randomName(), $this->randomName(), Language::LANGCODE_NOT_SPECIFIED);
$node2_en = (object) array('nid' => $node2->nid, 'langcode' => 'en');
$node2_es = (object) array('nid' => $node2->nid, 'langcode' => 'es');
$node2_it = (object) array('nid' => $node2->nid, 'langcode' => 'it');
@@ -324,7 +325,7 @@ class TranslationTest extends WebTestBase {
}
else {
// It's installed. No need to do anything.
- $this->assertTrue(true, 'Language [' . $langcode . '] already installed.');
+ $this->assertTrue(TRUE, 'Language [' . $langcode . '] already installed.');
}
}
@@ -343,7 +344,7 @@ class TranslationTest extends WebTestBase {
*/
function createPage($title, $body, $langcode = NULL) {
$edit = array();
- $field_langcode = LANGUAGE_NOT_SPECIFIED;
+ $field_langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit["title"] = $title;
$edit["body[$field_langcode][0][value]"] = $body;
if (!empty($langcode)) {
@@ -377,10 +378,10 @@ class TranslationTest extends WebTestBase {
function createTranslation(EntityInterface $node, $title, $body, $langcode) {
$this->drupalGet('node/add/page', array('query' => array('translation' => $node->nid, 'target' => $langcode)));
- $field_langcode = LANGUAGE_NOT_SPECIFIED;
+ $field_langcode = Language::LANGCODE_NOT_SPECIFIED;
$body_key = "body[$field_langcode][0][value]";
$this->assertFieldByXPath('//input[@id="edit-title"]', $node->label(), "Original title value correctly populated.");
- $this->assertFieldByXPath("//textarea[@name='$body_key']", $node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], "Original body value correctly populated.");
+ $this->assertFieldByXPath("//textarea[@name='$body_key']", $node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'], "Original body value correctly populated.");
$edit = array();
$edit["title"] = $title;
diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module
index f62832d..fcb2adb 100644
--- a/core/modules/translation/translation.module
+++ b/core/modules/translation/translation.module
@@ -20,6 +20,7 @@
*/
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Language\Language;
use Drupal\entity\Plugin\Core\Entity\EntityDisplay;
/**
@@ -85,7 +86,7 @@ function translation_menu() {
* @see translation_menu()
*/
function _translation_tab_access($node) {
- if ($node->langcode != LANGUAGE_NOT_SPECIFIED && translation_supported_type($node->type) && node_access('view', $node)) {
+ if ($node->langcode != Language::LANGCODE_NOT_SPECIFIED && translation_supported_type($node->type) && node_access('view', $node)) {
return translation_user_can_translate_node($node);
}
return FALSE;
@@ -176,7 +177,7 @@ function translation_form_node_type_form_alter(&$form, &$form_state) {
*/
function translation_node_type_language_translation_enabled_validate($element, &$form_state, $form) {
if (language_is_locked($form_state['values']['language_configuration']['langcode']) && !$form_state['values']['language_configuration']['language_show'] && $form_state['values']['node_type_language_translation_enabled']) {
- foreach (language_list(LANGUAGE_LOCKED) as $language) {
+ foreach (language_list(Language::STATE_LOCKED) as $language) {
$locked_languages[] = $language->name;
}
form_set_error('node_type_language_translation_enabled', t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(", ", $locked_languages))));
@@ -203,7 +204,7 @@ function translation_form_node_form_alter(&$form, &$form_state) {
// Disable languages for existing translations, so it is not possible
// to switch this node to some language which is already in the
// translation set. Also remove the language neutral option.
- unset($form['langcode']['#options'][LANGUAGE_NOT_SPECIFIED]);
+ unset($form['langcode']['#options'][Language::LANGCODE_NOT_SPECIFIED]);
foreach (translation_node_get_translations($node->tnid) as $langcode => $translation) {
if ($translation->nid != $node->nid) {
unset($form['langcode']['#options'][$langcode]);
@@ -252,7 +253,7 @@ function translation_node_view(EntityInterface $node, EntityDisplay $display, $v
// If the site has no translations or is not multilingual we have no content
// translation links to display.
if (isset($node->tnid) && language_multilingual() && $translations = translation_node_get_translations($node->tnid)) {
- $languages = language_list(LANGUAGE_ALL);
+ $languages = language_list(Language::STATE_ALL);
// There might be a language provider enabled defining custom language
// switch links which need to be taken into account while generating the
@@ -547,7 +548,7 @@ function translation_language_switch_links_alter(array &$links, $type, $path) {
// have translations it might be a language neutral node, in which case we
// must leave the language switch links unaltered. This is true also for
// nodes not having translation support enabled.
- if (empty($node) || $node->langcode == LANGUAGE_NOT_SPECIFIED || !translation_supported_type($node->type)) {
+ if (empty($node) || $node->langcode == Language::LANGCODE_NOT_SPECIFIED || !translation_supported_type($node->type)) {
return;
}
$translations = array($node->langcode => $node);
diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php b/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php
index 4ffc6ef..906248a 100644
--- a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php
+++ b/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php
@@ -8,6 +8,7 @@
namespace Drupal\translation_entity;
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Language\Language;
/**
* Base class for entity translation controllers.
@@ -171,7 +172,7 @@ class EntityTranslationController implements EntityTranslationControllerInterfac
'#submit' => array(array($this, 'entityFormSourceChange')),
),
);
- foreach (language_list(LANGUAGE_CONFIGURABLE) as $language) {
+ foreach (language_list(Language::STATE_CONFIGURABLE) as $language) {
if (isset($translations[$language->langcode])) {
$form['source_langcode']['source']['#options'][$language->langcode] = $language->name;
}
@@ -184,7 +185,7 @@ class EntityTranslationController implements EntityTranslationControllerInterfac
$language_widget = isset($form['langcode']) && $form['langcode']['#type'] == 'language_select';
if ($language_widget && $has_translations) {
$form['langcode']['#options'] = array();
- foreach (language_list(LANGUAGE_CONFIGURABLE) as $language) {
+ foreach (language_list(Language::STATE_CONFIGURABLE) as $language) {
if (empty($translations[$language->langcode]) || $language->langcode == $entity_langcode) {
$form['langcode']['#options'][$language->langcode] = $language->name;
}
diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php
index 41600ac..d94cd78 100644
--- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php
+++ b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php
@@ -7,6 +7,7 @@
namespace Drupal\translation_entity\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -69,7 +70,7 @@ class EntityTranslationSettingsTest extends WebTestBase {
// language is set as default and the language selector is hidden.
$edit = array(
'entity_types[comment]' => TRUE,
- 'settings[comment][comment_node_article][settings][language][langcode]' => LANGUAGE_NOT_SPECIFIED,
+ 'settings[comment][comment_node_article][settings][language][langcode]' => Language::LANGCODE_NOT_SPECIFIED,
'settings[comment][comment_node_article][settings][language][language_show]' => FALSE,
'settings[comment][comment_node_article][translatable]' => TRUE,
'settings[comment][comment_node_article][fields][comment_body]' => TRUE,
diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php
index 61f9182..f78b799 100644
--- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php
+++ b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php
@@ -9,6 +9,7 @@ namespace Drupal\translation_entity\Tests;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityNG;
+use Drupal\Core\Language\Language;
use Drupal\Core\TypedData\ComplexDataInterface;
/**
@@ -223,7 +224,7 @@ abstract class EntityTranslationUITest extends EntityTranslationTestBase {
*/
protected function getEditValues($values, $langcode, $new = FALSE) {
$edit = $values[$langcode];
- $langcode = $new ? LANGUAGE_NOT_SPECIFIED : $langcode;
+ $langcode = $new ? Language::LANGCODE_NOT_SPECIFIED : $langcode;
foreach ($values[$langcode] as $property => $value) {
if (is_array($value)) {
$edit["{$property}[$langcode][0][value]"] = $value[0]['value'];
diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationWorkflowsTest.php b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationWorkflowsTest.php
index 9957552..de7db85 100644
--- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationWorkflowsTest.php
+++ b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationWorkflowsTest.php
@@ -7,6 +7,7 @@
namespace Drupal\translation_entity\Tests;
+use Drupal\Core\Language\Language;
use Drupal\user\Plugin\Core\Entity\User;
/**
@@ -179,7 +180,7 @@ class EntityTranslationWorkflowsTest extends EntityTranslationTestBase {
* Assert that the current page does not contain shared form elements.
*/
protected function assertNoSharedElements() {
- $language_none = LANGUAGE_NOT_SPECIFIED;
+ $language_none = Language::LANGCODE_NOT_SPECIFIED;
return $this->assertNoFieldByXPath("//input[@name='field_test_text[$language_none][0][value]']", NULL, 'Shared elements are not available on the translation form.');
}
diff --git a/core/modules/translation_entity/translation_entity.admin.inc b/core/modules/translation_entity/translation_entity.admin.inc
index 8c184b5..9f44bdf 100644
--- a/core/modules/translation_entity/translation_entity.admin.inc
+++ b/core/modules/translation_entity/translation_entity.admin.inc
@@ -6,6 +6,7 @@
*/
use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Language\Language;
use Drupal\field\Plugin\Core\Entity\Field;
use Drupal\field\Plugin\Core\Entity\FieldInstance;
@@ -253,7 +254,7 @@ function translation_entity_form_language_content_settings_validate(array $form,
$values = $bundle_settings['settings']['language'];
if (language_is_locked($values['langcode']) && empty($values['language_show'])) {
- foreach (language_list(LANGUAGE_LOCKED) as $language) {
+ foreach (language_list(Language::STATE_LOCKED) as $language) {
$locked_languages[] = $language->name;
}
form_set_error($name, t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(', ', $locked_languages))));
@@ -336,9 +337,9 @@ function _translation_entity_update_field_translatability($settings) {
$field = field_info_field($field_name);
if ($field['translatable'] != $translatable) {
// If a field is untranslatable, it can have no data except under
- // LANGUAGE_NOT_SPECIFIED. Thus we need a field to be translatable before
+ // Language::LANGCODE_NOT_SPECIFIED. Thus we need a field to be translatable before
// we convert data to the entity language. Conversely we need to switch
- // data back to LANGUAGE_NOT_SPECIFIED before making a field
+ // data back to Language::LANGCODE_NOT_SPECIFIED before making a field
// untranslatable lest we lose information.
$field_operations = array(
array('translation_entity_translatable_switch', array($translatable, $field_name)),
@@ -398,7 +399,7 @@ function translation_entity_translatable_form(array $form, array &$form_state, $
* This submit handler maintains consistency between the translatability of an
* entity and the language under which the field data is stored. When a field is
* marked as translatable, all the data in
- * $entity->{field_name}[LANGUAGE_NOT_SPECIFIED] is moved to
+ * $entity->{field_name}[Language::LANGCODE_NOT_SPECIFIED] is moved to
* $entity->{field_name}[$entity_language]. When a field is marked as
* untranslatable the opposite process occurs. Note that marking a field as
* untranslatable will cause all of its translations to be permanently removed,
@@ -421,9 +422,9 @@ function translation_entity_translatable_form_submit(array $form, array $form_st
}
// If a field is untranslatable, it can have no data except under
- // LANGUAGE_NOT_SPECIFIED. Thus we need a field to be translatable before we
+ // Language::LANGCODE_NOT_SPECIFIED. Thus we need a field to be translatable before we
// convert data to the entity language. Conversely we need to switch data back
- // to LANGUAGE_NOT_SPECIFIED before making a field untranslatable lest we lose
+ // to Language::LANGCODE_NOT_SPECIFIED before making a field untranslatable lest we lose
// information.
$operations = array(
array('translation_entity_translatable_batch', array(!$translatable, $field_name)),
@@ -464,7 +465,7 @@ function translation_entity_translatable_switch($translatable, $field_name) {
}
/**
- * Batch callback: Converts field data to or from LANGUAGE_NOT_SPECIFIED.
+ * Batch callback: Converts field data to or from Language::LANGCODE_NOT_SPECIFIED.
*
* @param bool $translatable
* Indicator of whether the field should be made translatable (TRUE) or
@@ -535,7 +536,7 @@ function translation_entity_translatable_batch($translatable, $field_name, &$con
$langcode = $entity->language()->langcode;
// Skip process for language neutral entities.
- if ($langcode == LANGUAGE_NOT_SPECIFIED) {
+ if ($langcode == Language::LANGCODE_NOT_SPECIFIED) {
continue;
}
@@ -545,27 +546,27 @@ function translation_entity_translatable_batch($translatable, $field_name, &$con
// we need to store the new translations and only after we can remove the
// old ones. Otherwise we might have data loss, since the removal of the
// old translations might occur before the new ones are stored.
- if ($translatable && isset($entity->{$field_name}[LANGUAGE_NOT_SPECIFIED])) {
+ if ($translatable && isset($entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED])) {
// If the field is being switched to translatable and has data for
- // LANGUAGE_NOT_SPECIFIED then we need to move the data to the right
+ // Language::LANGCODE_NOT_SPECIFIED then we need to move the data to the right
// language.
- $entity->{$field_name}[$langcode] = $entity->{$field_name}[LANGUAGE_NOT_SPECIFIED];
+ $entity->{$field_name}[$langcode] = $entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED];
// Store the original value.
_translation_entity_update_field($entity_type, $entity, $field_name);
- $entity->{$field_name}[LANGUAGE_NOT_SPECIFIED] = array();
+ $entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED] = array();
// Remove the language neutral value.
_translation_entity_update_field($entity_type, $entity, $field_name);
}
elseif (!$translatable && isset($entity->{$field_name}[$langcode])) {
// The field has been marked untranslatable and has data in the entity
- // language: we need to move it to LANGUAGE_NOT_SPECIFIED and drop the
+ // language: we need to move it to Language::LANGCODE_NOT_SPECIFIED and drop the
// other translations.
- $entity->{$field_name}[LANGUAGE_NOT_SPECIFIED] = $entity->{$field_name}[$langcode];
+ $entity->{$field_name}[Language::LANGCODE_NOT_SPECIFIED] = $entity->{$field_name}[$langcode];
// Store the original value.
_translation_entity_update_field($entity_type, $entity, $field_name);
// Remove translations.
foreach ($entity->{$field_name} as $langcode => $items) {
- if ($langcode != LANGUAGE_NOT_SPECIFIED) {
+ if ($langcode != Language::LANGCODE_NOT_SPECIFIED) {
$entity->{$field_name}[$langcode] = array();
}
}
diff --git a/core/modules/translation_entity/translation_entity.install b/core/modules/translation_entity/translation_entity.install
index 0279b92..977d5fd 100644
--- a/core/modules/translation_entity/translation_entity.install
+++ b/core/modules/translation_entity/translation_entity.install
@@ -5,6 +5,8 @@
* Installation functions for Entity Translation module.
*/
+use Drupal\Core\Language\Language;
+
/**
* Implements hook_schema().
*/
@@ -84,7 +86,7 @@ function translation_entity_install() {
// hook_module_implements_alter() is run among the last ones.
module_set_weight('translation_entity', 10);
language_negotiation_include();
- language_negotiation_set(LANGUAGE_TYPE_CONTENT, array(LANGUAGE_NEGOTIATION_URL => 0));
+ language_negotiation_set(Language::TYPE_CONTENT, array(LANGUAGE_NEGOTIATION_URL => 0));
}
/**
diff --git a/core/modules/translation_entity/translation_entity.module b/core/modules/translation_entity/translation_entity.module
index 82bd66d..f51c2cb 100644
--- a/core/modules/translation_entity/translation_entity.module
+++ b/core/modules/translation_entity/translation_entity.module
@@ -65,7 +65,7 @@ function translation_entity_module_implements_alter(&$implementations, $hook) {
function translation_entity_language_types_info_alter(array &$language_types) {
// Make content language negotiation configurable by removing its predefined
// configuration.
- unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']);
+ unset($language_types[Language::TYPE_CONTENT]['fixed']);
}
/**
@@ -312,7 +312,7 @@ function translation_entity_view_access(EntityInterface $entity, $langcode, $acc
*/
function translation_entity_add_access(EntityInterface $entity, Language $source = NULL, Language $target = NULL) {
$source = !empty($source) ? $source : $entity->language();
- $target = !empty($target) ? $target : language(LANGUAGE_TYPE_CONTENT);
+ $target = !empty($target) ? $target : language(Language::TYPE_CONTENT);
$translations = $entity->getTranslationLanguages();
$languages = language_list();
return $source->langcode != $target->langcode && isset($languages[$source->langcode]) && isset($languages[$target->langcode]) && !isset($translations[$target->langcode]) && translation_entity_access($entity, 'create');
@@ -328,7 +328,7 @@ function translation_entity_add_access(EntityInterface $entity, Language $source
* content language.
*/
function translation_entity_edit_access(EntityInterface $entity, Language $language = NULL) {
- $language = !empty($language) ? $language : language(LANGUAGE_TYPE_CONTENT);
+ $language = !empty($language) ? $language : language(Language::TYPE_CONTENT);
$translations = $entity->getTranslationLanguages();
$languages = language_list();
return isset($languages[$language->langcode]) && $language->langcode != $entity->language()->langcode && isset($translations[$language->langcode]) && translation_entity_access($entity, 'update');
@@ -344,7 +344,7 @@ function translation_entity_edit_access(EntityInterface $entity, Language $langu
* content language.
*/
function translation_entity_delete_access(EntityInterface $entity, Language $language = NULL) {
- $language = !empty($language) ? $language : language(LANGUAGE_TYPE_CONTENT);
+ $language = !empty($language) ? $language : language(Language::TYPE_CONTENT);
$translations = $entity->getTranslationLanguages();
$languages = language_list();
return isset($languages[$language->langcode]) && $language->langcode != $entity->language()->langcode && isset($translations[$language->langcode]) && translation_entity_access($entity, 'delete');
@@ -649,14 +649,14 @@ function translation_entity_field_language_alter(&$display_language, $context) {
foreach ($entity->translation as $langcode => $translation) {
if ($langcode == $context['langcode'] || !translation_entity_view_access($entity, $langcode)) {
// Unset unaccessible field translations: if the field is untranslatable
- // unsetting a language different from LANGUAGE_NOT_SPECIFIED has no
+ // unsetting a language different from Language::LANGCODE_NOT_SPECIFIED has no
// effect.
foreach ($instances as $instance) {
// @todo BC entities have the same value accessibile both with the
- // entity language and with LANGUAGE_DEFAULT. We need need to unset
+ // entity language and with Language::LANGCODE_DEFAULT. We need need to unset
// both until we remove the BC layer.
if ($langcode == $entity_langcode) {
- unset($entity->{$instance['field_name']}[LANGUAGE_DEFAULT]);
+ unset($entity->{$instance['field_name']}[Language::LANGCODE_DEFAULT]);
}
unset($entity->{$instance['field_name']}[$langcode]);
}
@@ -947,7 +947,7 @@ function translation_entity_language_configuration_element_validate($element, ar
$key = $form_state['translation_entity']['key'];
$values = $form_state['values'][$key];
if (language_is_locked($values['langcode']) && !$values['language_show'] && $values['translation_entity']) {
- foreach (language_list(LANGUAGE_LOCKED) as $language) {
+ foreach (language_list(Language::STATE_LOCKED) as $language) {
$locked_languages[] = $language->name;
}
// @todo Set the correct form element name as soon as the element parents
diff --git a/core/modules/translation_entity/translation_entity.pages.inc b/core/modules/translation_entity/translation_entity.pages.inc
index 38ae80b..c7de9e2 100644
--- a/core/modules/translation_entity/translation_entity.pages.inc
+++ b/core/modules/translation_entity/translation_entity.pages.inc
@@ -165,12 +165,12 @@ function translation_entity_overview(EntityInterface $entity) {
* A renderable array of language switch links.
*/
function _translation_entity_get_switch_links($path) {
- $links = language_negotiation_get_switch_links(LANGUAGE_TYPE_CONTENT, $path);
+ $links = language_negotiation_get_switch_links(Language::TYPE_CONTENT, $path);
if (empty($links)) {
// If content language is set up to fall back to the interface language,
- // then there will be no switch links for LANGUAGE_TYPE_CONTENT, ergo we
+ // then there will be no switch links for Language::TYPE_CONTENT, ergo we
// also need to use interface switch links.
- $links = language_negotiation_get_switch_links(LANGUAGE_TYPE_INTERFACE, $path);
+ $links = language_negotiation_get_switch_links(Language::TYPE_INTERFACE, $path);
}
return $links;
}
@@ -192,7 +192,7 @@ function _translation_entity_get_switch_links($path) {
*/
function translation_entity_add_page(EntityInterface $entity, Language $source = NULL, Language $target = NULL) {
$source = !empty($source) ? $source : $entity->language();
- $target = !empty($target) ? $target : language(LANGUAGE_TYPE_CONTENT);
+ $target = !empty($target) ? $target : language(Language::TYPE_CONTENT);
// @todo Exploit the upcoming hook_entity_prepare() when available.
translation_entity_prepare_translation($entity, $source, $target);
$info = $entity->entityInfo();
@@ -218,7 +218,7 @@ function translation_entity_add_page(EntityInterface $entity, Language $source =
* A processed form array ready to be rendered.
*/
function translation_entity_edit_page(EntityInterface $entity, Language $language = NULL) {
- $language = !empty($language) ? $language : language(LANGUAGE_TYPE_CONTENT);
+ $language = !empty($language) ? $language : language(Language::TYPE_CONTENT);
$info = $entity->entityInfo();
$operation = isset($info['default_operation']) ? $info['default_operation'] : 'default';
$form_state['langcode'] = $language->langcode;
diff --git a/core/modules/user/lib/Drupal/user/AccountFormController.php b/core/modules/user/lib/Drupal/user/AccountFormController.php
index ca8e638..f11143e 100644
--- a/core/modules/user/lib/Drupal/user/AccountFormController.php
+++ b/core/modules/user/lib/Drupal/user/AccountFormController.php
@@ -8,6 +8,7 @@
namespace Drupal\user;
use Drupal\Core\Entity\EntityFormController;
+use Drupal\Core\Language\Language;
/**
* Form controller for the user account forms.
@@ -22,7 +23,7 @@ abstract class AccountFormController extends EntityFormController {
global $user;
$config = config('user.settings');
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$register = empty($account->uid);
$admin = user_access('administer users');
@@ -180,7 +181,7 @@ abstract class AccountFormController extends EntityFormController {
// Is default the interface language?
include_once DRUPAL_ROOT . '/core/includes/language.inc';
- $interface_language_is_default = language_negotiation_method_get_first(LANGUAGE_TYPE_INTERFACE) != LANGUAGE_NEGOTIATION_SELECTED;
+ $interface_language_is_default = language_negotiation_method_get_first(Language::TYPE_INTERFACE) != LANGUAGE_NEGOTIATION_SELECTED;
$form['language'] = array(
'#type' => language_multilingual() ? 'details' : 'container',
'#title' => t('Language settings'),
@@ -192,7 +193,7 @@ abstract class AccountFormController extends EntityFormController {
$form['language']['preferred_langcode'] = array(
'#type' => 'language_select',
'#title' => t('Site language'),
- '#languages' => LANGUAGE_CONFIGURABLE,
+ '#languages' => Language::STATE_CONFIGURABLE,
'#default_value' => $user_preferred_langcode,
'#description' => $interface_language_is_default ? t("This account's preferred language for e-mails and site presentation.") : t("This account's preferred language for e-mails."),
);
@@ -200,7 +201,7 @@ abstract class AccountFormController extends EntityFormController {
$form['language']['preferred_admin_langcode'] = array(
'#type' => 'language_select',
'#title' => t('Administration pages language'),
- '#languages' => LANGUAGE_CONFIGURABLE,
+ '#languages' => Language::STATE_CONFIGURABLE,
'#default_value' => $user_preferred_admin_langcode,
'#access' => user_access('access administration pages', $account),
);
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
index 44c4562..6797848 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php
@@ -10,6 +10,7 @@ namespace Drupal\user\Plugin\Core\Entity;
use Drupal\Core\Entity\Entity;
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\Annotation\Translation;
+use Drupal\Core\Language\Language;
use Drupal\user\UserInterface;
/**
@@ -142,21 +143,21 @@ class User extends Entity implements UserInterface {
*
* @var string
*/
- public $langcode = LANGUAGE_NOT_SPECIFIED;
+ public $langcode = Language::LANGCODE_NOT_SPECIFIED;
/**
* The user's preferred langcode for receiving emails and viewing the site.
*
* @var string
*/
- public $preferred_langcode = LANGUAGE_NOT_SPECIFIED;
+ public $preferred_langcode = Language::LANGCODE_NOT_SPECIFIED;
/**
* The user's preferred langcode for viewing administration pages.
*
* @var string
*/
- public $preferred_admin_langcode = LANGUAGE_NOT_SPECIFIED;
+ public $preferred_admin_langcode = Language::LANGCODE_NOT_SPECIFIED;
/**
* The email address used for initial account creation.
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
index 83aa5b2..5b622e1 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
@@ -7,6 +7,7 @@
namespace Drupal\user\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -287,7 +288,7 @@ class UserCancelTest extends WebTestBase {
$node = $this->drupalCreateNode(array('uid' => $account->uid));
// Create comment.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array();
$edit['subject'] = $this->randomName(8);
$edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
index 1cd12bc..a07006f 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
@@ -7,6 +7,7 @@
namespace Drupal\user\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -110,7 +111,7 @@ class UserPictureTest extends WebTestBase {
->save();
$edit = array(
- 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomString(),
+ 'comment_body[' . Language::LANGCODE_NOT_SPECIFIED . '][0][value]' => $this->randomString(),
);
$this->drupalPost('comment/reply/' . $node->nid, $edit, t('Save'));
$this->assertRaw(file_uri_target($file->uri), 'User picture found on comment.');
@@ -134,6 +135,6 @@ class UserPictureTest extends WebTestBase {
// Load actual user data from database.
$account = user_load($this->web_user->uid, TRUE);
- return file_load($account->user_picture[LANGUAGE_NOT_SPECIFIED][0]['fid'], TRUE);
+ return file_load($account->user_picture[Language::LANGCODE_NOT_SPECIFIED][0]['fid'], TRUE);
}
}
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
index db649b0..0462424 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
@@ -7,6 +7,7 @@
namespace Drupal\user\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
class UserRegistrationTest extends WebTestBase {
@@ -243,7 +244,7 @@ class UserRegistrationTest extends WebTestBase {
// Check user fields.
$accounts = entity_load_multiple_by_properties('user', array('name' => $name, 'mail' => $mail));
$new_user = reset($accounts);
- $this->assertEqual($new_user->test_user_field[LANGUAGE_NOT_SPECIFIED][0]['value'], $value, 'The field value was correclty saved.');
+ $this->assertEqual($new_user->test_user_field[Language::LANGCODE_NOT_SPECIFIED][0]['value'], $value, 'The field value was correclty saved.');
// Check that the 'add more' button works.
$field['cardinality'] = FIELD_CARDINALITY_UNLIMITED;
@@ -271,9 +272,9 @@ class UserRegistrationTest extends WebTestBase {
// Check user fields.
$accounts = entity_load_multiple_by_properties('user', array('name' => $name, 'mail' => $mail));
$new_user = reset($accounts);
- $this->assertEqual($new_user->test_user_field[LANGUAGE_NOT_SPECIFIED][0]['value'], $value, format_string('@js : The field value was correclty saved.', array('@js' => $js)));
- $this->assertEqual($new_user->test_user_field[LANGUAGE_NOT_SPECIFIED][1]['value'], $value + 1, format_string('@js : The field value was correclty saved.', array('@js' => $js)));
- $this->assertEqual($new_user->test_user_field[LANGUAGE_NOT_SPECIFIED][2]['value'], $value + 2, format_string('@js : The field value was correclty saved.', array('@js' => $js)));
+ $this->assertEqual($new_user->test_user_field[Language::LANGCODE_NOT_SPECIFIED][0]['value'], $value, format_string('@js : The field value was correclty saved.', array('@js' => $js)));
+ $this->assertEqual($new_user->test_user_field[Language::LANGCODE_NOT_SPECIFIED][1]['value'], $value + 1, format_string('@js : The field value was correclty saved.', array('@js' => $js)));
+ $this->assertEqual($new_user->test_user_field[Language::LANGCODE_NOT_SPECIFIED][2]['value'], $value + 2, format_string('@js : The field value was correclty saved.', array('@js' => $js)));
}
}
}
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php
index ab4c706..85925e7 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php
@@ -7,6 +7,7 @@
namespace Drupal\user\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
/**
@@ -100,7 +101,7 @@ class UserSignatureTest extends WebTestBase {
$this->assertFieldByName('signature[value]', $edit['signature[value]'], 'Submitted signature text found.');
// Create a comment.
- $langcode = LANGUAGE_NOT_SPECIFIED;
+ $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array();
$edit['subject'] = $this->randomName(8);
$edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
index e7fbec7..71d4a78 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
@@ -43,7 +43,7 @@ class UserTokenReplaceTest extends WebTestBase {
*/
function testUserTokenReplacement() {
$token_service = \Drupal::token();
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$url_options = array(
'absolute' => TRUE,
'language' => $language_interface,
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index 4f22958..9819cde 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -6,6 +6,7 @@
*/
use Drupal\Component\Uuid\Uuid;
+use Drupal\Core\Language\Language;
/**
* Implements hook_schema().
@@ -689,7 +690,7 @@ function user_update_8011() {
'status' => FILE_STATUS_PERMANENT,
'filename' => drupal_basename($destination),
'uuid' => $uuid->generate(),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'filesize' => filesize($destination),
'filemime' => file_get_mimetype($destination),
'timestamp' => REQUEST_TIME,
@@ -838,7 +839,7 @@ function user_update_8012(&$sandbox) {
'bundle' => 'user',
'entity_id' => $uid,
'revision_id' => $uid,
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'delta' => 0,
'user_picture_fid' => $fid,
))
@@ -849,7 +850,7 @@ function user_update_8012(&$sandbox) {
'bundle' => 'user',
'entity_id' => $uid,
'revision_id' => $uid,
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'delta' => 0,
'user_picture_fid' => $fid,
))
@@ -1047,7 +1048,7 @@ function user_update_8017() {
->set('uuid', $uuid->generate())
->set('label', $role->name)
->set('weight', $role->weight)
- ->set('langcode', LANGUAGE_NOT_SPECIFIED)
+ ->set('langcode', Language::LANGCODE_NOT_SPECIFIED)
->save();
}
diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc
index 5817d9c..c3af21a 100644
--- a/core/modules/user/user.pages.inc
+++ b/core/modules/user/user.pages.inc
@@ -5,6 +5,7 @@
* User page callback file for the user module.
*/
+use Drupal\Core\Language\Language;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -67,7 +68,7 @@ function user_pass_validate($form, &$form_state) {
}
function user_pass_submit($form, &$form_state) {
- $language_interface = language(LANGUAGE_TYPE_INTERFACE);
+ $language_interface = language(Language::TYPE_INTERFACE);
$account = $form_state['values']['account'];
// Mail one time login URL and instructions using current language.
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
index 7df986e..a66b76d 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\cache;
+use Drupal\Core\Language\Language;
use Drupal\views\ViewExecutable;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\views\Plugin\views\PluginBase;
@@ -286,7 +287,7 @@ abstract class CachePluginBase extends PluginBase {
'build_info' => $build_info,
'roles' => array_keys($user->roles),
'super-user' => $user->uid == 1, // special caching for super user.
- 'langcode' => language(LANGUAGE_TYPE_INTERFACE)->langcode,
+ 'langcode' => language(Language::TYPE_INTERFACE)->langcode,
'base_url' => $GLOBALS['base_url'],
);
foreach (array('exposed_info', 'page', 'sort', 'order', 'items_per_page', 'offset') as $key) {
@@ -315,7 +316,7 @@ abstract class CachePluginBase extends PluginBase {
'roles' => array_keys($user->roles),
'super-user' => $user->uid == 1, // special caching for super user.
'theme' => $GLOBALS['theme'],
- 'langcode' => language(LANGUAGE_TYPE_INTERFACE)->langcode,
+ 'langcode' => language(Language::TYPE_INTERFACE)->langcode,
'base_url' => $GLOBALS['base_url'],
);
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
index d527836..4da5800 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\display;
+use Drupal\Core\Language\Language;
use Drupal\views\Plugin\views\area\AreaPluginBase;
use Drupal\views\ViewExecutable;
use \Drupal\views\Plugin\views\PluginBase;
@@ -1209,7 +1210,7 @@ abstract class DisplayPluginBase extends PluginBase {
$languages = array(
'***CURRENT_LANGUAGE***' => t("Current user's language"),
'***DEFAULT_LANGUAGE***' => t("Default site language"),
- LANGUAGE_NOT_SPECIFIED => t('Language neutral'),
+ Language::LANGCODE_NOT_SPECIFIED => t('Language neutral'),
);
if (\Drupal::moduleHandler()->moduleExists('language')) {
$languages = array_merge($languages, language_list());
@@ -1578,7 +1579,7 @@ abstract class DisplayPluginBase extends PluginBase {
$languages = array(
'***CURRENT_LANGUAGE***' => t("Current user's language"),
'***DEFAULT_LANGUAGE***' => t("Default site language"),
- LANGUAGE_NOT_SPECIFIED => t('Language neutral'),
+ Language::LANGCODE_NOT_SPECIFIED => t('Language neutral'),
);
$languages = array_merge($languages, views_language_list());
diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php
index d6d7226..d5b51d8 100644
--- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php
@@ -7,6 +7,7 @@
namespace Drupal\views\Tests;
+use Drupal\Core\Language\Language;
use Drupal\simpletest\WebTestBase;
use Drupal\views\ViewExecutable;
@@ -51,7 +52,7 @@ class DefaultViewsTest extends WebTestBase {
'name' => $this->randomName(),
'description' => $this->randomName(),
'vid' => drupal_strtolower($this->randomName()),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'help' => '',
'nodes' => array('page' => 'page'),
'weight' => mt_rand(0, 10),
@@ -98,7 +99,7 @@ class DefaultViewsTest extends WebTestBase {
$node = $this->drupalCreateNode($values);
- search_index($node->nid, 'node', $node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], LANGUAGE_NOT_SPECIFIED);
+ search_index($node->nid, 'node', $node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'], Language::LANGCODE_NOT_SPECIFIED);
$comment = array(
'uid' => $user->uid,
@@ -153,7 +154,7 @@ class DefaultViewsTest extends WebTestBase {
// Use the first available text format.
'format' => $format->format,
'vid' => $vocabulary->id(),
- 'langcode' => LANGUAGE_NOT_SPECIFIED,
+ 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
));
$term->save();
return $term;
diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php
index f1a06a3..bb52895 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php
@@ -7,6 +7,8 @@
namespace Drupal\views\Tests\Wizard;
+use Drupal\Core\Language\Language;
+
/**
* Tests the ability of the views wizard to create views filtered by taxonomy.
*/
@@ -106,7 +108,7 @@ class TaggedWithTest extends WizardTestBase {
$node_add_path = 'node/add/' . $this->node_type_with_tags->type;
// Create three nodes, with different tags.
- $tag_field = $this->tag_field['field_name'] . '[' . LANGUAGE_NOT_SPECIFIED . ']';
+ $tag_field = $this->tag_field['field_name'] . '[' . Language::LANGCODE_NOT_SPECIFIED . ']';
$edit = array();
$edit['title'] = $node_tag1_title = $this->randomName();
$edit[$tag_field] = 'tag1';
diff --git a/core/modules/views/lib/Drupal/views/ViewsData.php b/core/modules/views/lib/Drupal/views/ViewsData.php
index a7fb96e..887ae1e 100644
--- a/core/modules/views/lib/Drupal/views/ViewsData.php
+++ b/core/modules/views/lib/Drupal/views/ViewsData.php
@@ -10,6 +10,7 @@ namespace Drupal\views;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\Core\Language\Language;
/**
* Class to manage and lazy load cached views data.
@@ -84,7 +85,7 @@ class ViewsData {
$this->cacheBackend = $cache_backend;
$this->moduleHandler = $module_handler;
- $this->langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ $this->langcode = language(Language::TYPE_INTERFACE)->langcode;
$this->skipCache = $config->get('views.settings')->get('skip_cache');
}
diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php
index 6c5532b..2be06b5 100644
--- a/core/modules/views/views.api.php
+++ b/core/modules/views/views.api.php
@@ -318,7 +318,7 @@ function hook_views_query_substitutions(ViewExecutable $view) {
return array(
'***CURRENT_VERSION***' => VERSION,
'***CURRENT_TIME***' => REQUEST_TIME,
- '***CURRENT_LANGUAGE***' => language(LANGUAGE_TYPE_CONTENT)->langcode,
+ '***CURRENT_LANGUAGE***' => language(\Drupal\Core\Language\Language::TYPE_CONTENT)->langcode,
'***DEFAULT_LANGUAGE***' => language_default()->langcode,
);
}
diff --git a/core/modules/views/views.module b/core/modules/views/views.module
index 99b29c0..a2a9437 100644
--- a/core/modules/views/views.module
+++ b/core/modules/views/views.module
@@ -11,6 +11,7 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Database\Query\AlterableInterface;
+use Drupal\Core\Language\Language;
use Drupal\views\ViewExecutable;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\views\Plugin\Core\Entity\View;
@@ -621,14 +622,15 @@ function views_add_contextual_links(&$render_element, $location, ViewExecutable
* array.
* @param int $flags
* (optional) Specifies the state of the languages that have to be returned.
- * It can be: LANGUAGE_CONFIGURABLE, LANGUAGE_LOCKED, LANGUAGE_ALL.
+ * It can be: Language::STATE_CONFIGURABLE, Language::STATE_LOCKED,
+ * Language::STATE_ALL.
*
* @return array
* An array of language names (or $field) keyed by the langcode.
*
* @see locale_language_list()
*/
-function views_language_list($field = 'name', $flags = LANGUAGE_ALL) {
+function views_language_list($field = 'name', $flags = Language::STATE_ALL) {
$languages = language_list($flags);
$list = array();
foreach ($languages as $language) {
@@ -1718,7 +1720,7 @@ function views_cache_set($cid, $data, $use_language = FALSE) {
return;
}
if ($use_language) {
- $cid .= ':' . language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ $cid .= ':' . language(Language::TYPE_INTERFACE)->langcode;
}
cache('views_info')->set($cid, $data);
@@ -1742,7 +1744,7 @@ function views_cache_get($cid, $use_language = FALSE) {
return FALSE;
}
if ($use_language) {
- $cid .= ':' . language(LANGUAGE_TYPE_INTERFACE)->langcode;
+ $cid .= ':' . language(Language::TYPE_INTERFACE)->langcode;
}
return cache('views_info')->get($cid);
diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc
index bd9500d..049815c 100644
--- a/core/modules/views/views.theme.inc
+++ b/core/modules/views/views.theme.inc
@@ -5,6 +5,7 @@
* Preprocessors and helper functions to make theming easier.
*/
+use Drupal\Core\Language\Language;
use Drupal\Core\Template\Attribute;
use Drupal\views\ViewExecutable;
@@ -1007,7 +1008,7 @@ function template_preprocess_views_view_rss(&$vars) {
$vars['link'] = check_url(url($path, $url_options));
}
- $vars['langcode'] = check_plain(language(LANGUAGE_TYPE_INTERFACE)->langcode);
+ $vars['langcode'] = check_plain(language(Language::TYPE_INTERFACE)->langcode);
$vars['namespaces'] = new Attribute($style->namespaces);
$vars['items'] = $items;
$vars['channel_elements'] = format_xml_elements($style->channel_elements);
diff --git a/core/modules/views/views.views_execution.inc b/core/modules/views/views.views_execution.inc
index 1b06ebd..5b0966a 100644
--- a/core/modules/views/views.views_execution.inc
+++ b/core/modules/views/views.views_execution.inc
@@ -5,6 +5,7 @@
* Provides views runtime hooks for views.module.
*/
+use Drupal\Core\Language\Language;
use Drupal\views\ViewExecutable;
/**
@@ -16,7 +17,7 @@ function views_views_query_substitutions(ViewExecutable $view) {
return array(
'***CURRENT_VERSION***' => VERSION,
'***CURRENT_TIME***' => REQUEST_TIME,
- '***CURRENT_LANGUAGE***' => language(LANGUAGE_TYPE_CONTENT)->langcode,
+ '***CURRENT_LANGUAGE***' => language(Language::TYPE_CONTENT)->langcode,
'***DEFAULT_LANGUAGE***' => language_default()->langcode,
);
}
diff --git a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php
index 3a35a29..6aac5e4 100644
--- a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php
+++ b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewUIObjectTest.php
@@ -7,17 +7,12 @@
namespace Drupal\views_ui\Tests;
+use Drupal\Core\Language\Language;
use Drupal\Tests\UnitTestCase;
use Drupal\views\ViewExecutable;
use Drupal\views_ui\ViewUI;
use Symfony\Component\DependencyInjection\Container;
-// Needed because the Entity class uses this constant.
-// @todo Remove once http://drupal.org/node/1620010 is in.
-if (!defined('LANGUAGE_NOT_SPECIFIED')) {
- define('LANGUAGE_NOT_SPECIFIED', 'und');
-}
-
if (!defined('DRUPAL_CORE_COMPATIBILITY')) {
define('DRUPAL_CORE_COMPATIBILITY', '8.x');
}
@@ -46,7 +41,7 @@ class ViewUIObjectTest extends UnitTestCase {
$method_args['setStatus'] = array(TRUE);
$method_args['setNewRevision'] = array(FALSE);
$method_args['enforceIsNew'] = array(FALSE);
- $method_args['label'] = array(LANGUAGE_NOT_SPECIFIED);
+ $method_args['label'] = array(Language::LANGCODE_NOT_SPECIFIED);
$method_args['isDefaultRevision'] = array(TRUE);
$reflection = new \ReflectionClass('Drupal\Core\Config\Entity\ConfigEntityInterface');
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityAccessCheckTest.php
index a1604aa..895a198 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityAccessCheckTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityAccessCheckTest.php
@@ -7,14 +7,6 @@
namespace Drupal\Tests\Core\Entity;
-// @todo Remove once http://drupal.org/node/1620010 is committed.
-if (!defined('LANGUAGE_DEFAULT')) {
- define('LANGUAGE_DEFAULT', 'und');
-}
-if (!defined('LANGUAGE_NOT_SPECIFIED')) {
- define('LANGUAGE_NOT_SPECIFIED', 'und');
-}
-
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Drupal\Core\Entity\EntityAccessCheck;
diff --git a/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php
index f171580..9285899 100644
--- a/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php
+++ b/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php
@@ -17,12 +17,6 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
-// Needed because the Entity class uses this constant.
-// @todo Remove once http://drupal.org/node/1620010 is in.
-if (!defined('LANGUAGE_NOT_SPECIFIED')) {
- define('LANGUAGE_NOT_SPECIFIED', 'und');
-}
-
/**
* Defines tests for role based access in routes.
*