Classes, traits, and interfaces - 8.9.x - drupal

Primary tabs

Introduction to classes

A lot of the PHP code in Drupal is object oriented (OO), making use of PHP classes, interfaces, and traits. See the Objected-oriented programming conventions for more information.

See also

Objected-oriented programming conventions

File

core/core.api.php, line 1511

Name Deprecated Object type Namespace File name Summary Direct uses Use statements Strings
JsonEncoder class Drupal\hal\Encoder core/modules/hal/src/Encoder/JsonEncoder.php Encodes HAL data in JSON. 1 2
JsonEncoderTest class Drupal\Tests\serialization\Unit\Encoder core/modules/serialization/tests/src/Unit/Encoder/JsonEncoderTest.php @coversDefaultClass \Drupal\serialization\Encoder\JsonEncoder @group serialization
JsonRenderer class Drupal\common_test\Render\MainContent core/modules/system/tests/modules/common_test/src/Render/MainContent/JsonRenderer.php Default main content renderer for JSON requests. 2
JsonTest class Drupal\Tests\Component\Serialization core/tests/Drupal/Tests/Component/Serialization/JsonTest.php @coversDefaultClass \Drupal\Component\Serialization\Json @group Serialization
JsOptimizer class Drupal\Core\Asset core/lib/Drupal/Core/Asset/JsOptimizer.php Optimizes a JavaScript asset. 1 2
JsOptimizerUnitTest class Drupal\Tests\Core\Asset core/tests/Drupal/Tests/Core/Asset/JsOptimizerUnitTest.php Tests the JS asset optimizer.
JSWebAssert class Drupal\FunctionalJavascriptTests core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php Defines a class with methods for asserting presence of elements during tests. 1
JSWebAssertTest class Drupal\FunctionalJavascriptTests\Tests core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php Tests for the JSWebAssert class. 1
JsWebAssertTestForm class Drupal\js_webassert_test\Form core/modules/system/tests/modules/js_webassert_test/src/Form/JsWebAssertTestForm.php Test form for JSWebAssert JavaScriptTestBase. 1
JSWebWithWebDriverAssertTest class Drupal\FunctionalJavascriptTests\Tests core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebWithWebDriverAssertTest.php Tests for the JSWebAssert class using webdriver.
JUnitConverter class Drupal\Core\Test core/lib/Drupal/Core/Test/JUnitConverter.php Converts JUnit XML to Drupal's {simpletest} schema. 2
JUnitConverterTest class Drupal\Tests\Core\Test core/tests/Drupal/Tests/Core/Test/JUnitConverterTest.php Tests Drupal\Core\Test\JUnitConverter.
Kale class Drupal\plugin_test\Plugin\plugin_test\fruit core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/fruit/Kale.php Plugin annotation @Plugin( id = "kale", label = "Kale", color = "green" )
KernelAssertLegacyTraitTest class Drupal\Tests\Core\Assert core/tests/Drupal/Tests/Core/Assert/KernelAssertLegacyTraitTest.php @coversDefaultClass \Drupal\KernelTests\AssertLegacyTrait @group Assert @group legacy
KernelDestructionSubscriber class Drupal\Core\EventSubscriber core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php Destructs services that are initiated and tagged with "needs_destruction". 2
KernelMissingDependentModuleMethodTest class Drupal\KernelTests core/tests/fixtures/KernelMissingDependentModuleMethodTest.php A fixture test class with requires annotation.
KernelMissingDependentModuleTest class Drupal\KernelTests core/tests/fixtures/KernelMissingDependentModuleTest.php A fixture test class with requires annotation.
KernelPreHandle class Drupal\Core\StackMiddleware core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php Prepares the environment after page caching ran. 2
KernelTestBase abstract class Drupal\KernelTests core/tests/Drupal/KernelTests/KernelTestBase.php Base class for functional integration tests. 539 543
KernelTestBase

in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\KernelTests\KernelTestBase instead.

abstract class Drupal\simpletest core/modules/simpletest/src/KernelTestBase.php Base class for functional integration tests. 4 4
KernelTestBaseShutdownTest class Drupal\KernelTests core/tests/Drupal/KernelTests/KernelTestBaseShutdownTest.php @coversDefaultClass \Drupal\KernelTests\KernelTestBase
KernelTestBaseTest class Drupal\KernelTests core/tests/Drupal/KernelTests/KernelTestBaseTest.php @coversDefaultClass \Drupal\KernelTests\KernelTestBase 1
KernelTestBaseTest class Drupal\Tests\Core\Test core/tests/Drupal/Tests/Core/Test/KernelTestBaseTest.php @group Test @group legacy
KernelTestBaseTest class Drupal\simpletest\Tests core/modules/simpletest/src/Tests/KernelTestBaseTest.php Tests KernelTestBase functionality.
KernelTestSuite class Drupal\Tests\TestSuites core/tests/TestSuites/KernelTestSuite.php Discovers tests for the kernel test suite.
KeyValueContentEntityStorage class Drupal\Core\Entity\KeyValueStore core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueContentEntityStorage.php Provides a key value backend for content entities.
KeyValueContentEntityStorageTest class Drupal\KernelTests\Core\KeyValueStore core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php Tests KeyValueEntityStorage for content entities.
KeyValueDatabaseExpirableFactory class Drupal\Core\KeyValueStore core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php Defines the key/value store factory for the database backend. 1 2
KeyValueDatabaseFactory class Drupal\Core\KeyValueStore core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseFactory.php Defines the key/value store factory for the database backend. 2
KeyValueEntityStorage class Drupal\Core\Entity\KeyValueStore core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php Provides a key value backend for entities. 1 1
KeyValueEntityStorageTest class Drupal\Tests\Core\Entity\KeyValueStore core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php @coversDefaultClass \Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage @group Entity
KeyValueExpirableFactory class Drupal\Core\KeyValueStore core/lib/Drupal/Core/KeyValueStore/KeyValueExpirableFactory.php Defines the key/value store factory. 2 2
KeyValueExpirableFactoryInterface interface Drupal\Core\KeyValueStore core/lib/Drupal/Core/KeyValueStore/KeyValueExpirableFactoryInterface.php Defines the expirable key/value store factory interface. 3 4
KeyValueFactory class Drupal\Core\KeyValueStore core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php Defines the key/value store factory. 1 3 2
KeyValueFactoryInterface interface Drupal\Core\KeyValueStore core/lib/Drupal/Core/KeyValueStore/KeyValueFactoryInterface.php Defines the key/value store factory interface. 3 17
KeyValueMemoryFactory class Drupal\Core\KeyValueStore core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php Defines the key/value store factory for the memory backend. 5
KeyValueNullExpirableFactory class Drupal\Core\KeyValueStore core/lib/Drupal/Core/KeyValueStore/KeyValueNullExpirableFactory.php Defines the key/value store factory for the null backend.
KeyValueStoreExpirableInterface interface Drupal\Core\KeyValueStore core/lib/Drupal/Core/KeyValueStore/KeyValueStoreExpirableInterface.php Defines the interface for expiring data in a key/value store. 2 6
KeyValueStoreInterface interface Drupal\Core\KeyValueStore core/lib/Drupal/Core/KeyValueStore/KeyValueStoreInterface.php Defines the interface for key/value store implementations. 2 8
KillSwitch class Drupal\Core\PageCache\ResponsePolicy core/lib/Drupal/Core/PageCache/ResponsePolicy/KillSwitch.php A policy evaluating to static::DENY when the kill switch was triggered. 1 2
Label class Drupal\Core\Render\Element core/lib/Drupal/Core/Render/Element/Label.php Provides a render element for displaying the label for a form element.
LabelOnlyResourceObject final class Drupal\jsonapi\JsonApiResource core/modules/jsonapi/src/JsonApiResource/LabelOnlyResourceObject.php Value object decorating a ResourceObject; only its label is available. 2
LangcodeToAsciiUpdateFilledTest class Drupal\Tests\system\Functional\Entity\Update core/modules/system/tests/src/Functional/Entity/Update/LangcodeToAsciiUpdateFilledTest.php Runs LangcodeToAsciiUpdateTest with a dump filled with content.
LangcodeToAsciiUpdateTest class Drupal\Tests\system\Functional\Entity\Update core/modules/system/tests/src/Functional/Entity/Update/LangcodeToAsciiUpdateTest.php Tests that the entity langcode fields have been updated to varchar_ascii. 1
Language class Drupal\ckeditor\Plugin\CKEditorPlugin core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php Defines the "language" plugin. 1
Language class Drupal\Core\TypedData\Plugin\DataType core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php Defines the 'language' data type.
Language class Drupal\Core\Language core/lib/Drupal/Core/Language/Language.php An object containing the information for an interface language. 58
Language class Drupal\language\Plugin\migrate\source core/modules/language/src/Plugin/migrate/source/Language.php Plugin annotation @MigrateSource( id = "language", source_module = "locale" )
Language class Drupal\language\Plugin\Condition core/modules/language/src/Plugin/Condition/Language.php Provides a 'Language' condition.
LanguageAccessControlHandler class Drupal\language core/modules/language/src/LanguageAccessControlHandler.php Defines the access control handler for the language entity type.

Other projects


Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.