Classes, traits, and interfaces - main - 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 1529

Name Deprecated Object type Namespace File name Summary Direct uses Use statements Strings
TestAttributesBlock class Drupal\layout_builder_test\Plugin\Block core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/TestAttributesBlock.php Provides a 'TestAttributes' block.
TestAuth class Drupal\rest_test\Authentication\Provider core/modules/rest/tests/modules/rest_test/src/Authentication/Provider/TestAuth.php Authentication provider for testing purposes. 2
TestAuthenticationProvider class Drupal\Tests\Core\Authentication core/tests/Drupal/Tests/Core/Authentication/AuthenticationCollectorTest.php A simple provider for unit testing AuthenticationCollector.
TestAuthenticationProviderInterface interface Drupal\Tests\Core\Authentication core/tests/Drupal/Tests/Core/Authentication/AuthenticationManagerTest.php Helper interface to mock two interfaces at once.
TestAuthGlobal class Drupal\rest_test\Authentication\Provider core/modules/rest/tests/modules/rest_test/src/Authentication/Provider/TestAuthGlobal.php Global authentication provider for testing purposes. 2
TestBaseFieldDefinitionInterface interface Drupal\Tests\Core\Field core/tests/Drupal/Tests/Core/Field/TestBaseFieldDefinitionInterface.php Defines a test interface to mock entity base field definitions. 3
TestBaseInterface interface Drupal\Tests\Component\ProxyBuilder core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php Test base interface. 1
TestBaseThemeHooks class Drupal\test_base_theme\Hook core/modules/system/tests/themes/test_base_theme/src/Hook/TestBaseThemeHooks.php Hook implementations for test_base_theme.
TestBlockInstantiation class Drupal\block_test\Plugin\Block core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php Provides a basic block for testing block instantiation and configuration. 1
TestBlockPluginWithRefinableDependentAccessInterface interface Drupal\Tests\layout_builder\Unit core/modules/layout_builder/tests/src/Unit/BlockComponentRenderArrayTest.php Test interface for dependent access block plugins.
TestCacheableDependency class Drupal\Tests\Core\Render core/tests/Drupal/Tests/Core/Render/TestCacheableDependency.php Cacheable dependency object for use in tests. 2
TestCacheBlock class Drupal\block_test\Plugin\Block core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php Provides a block to test caching.
TestCacheOptionalBlock class Drupal\block_test\Plugin\Block core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheOptionalBlock.php Provides a block implementing CacheOptionalInterface to test its caching.
TestCallables class Drupal\Tests\Core\Render core/tests/Drupal/Tests/Core/Render/RendererTest.php Mock callable for testing the pre_render callback.
TestChildInterface interface Drupal\Tests\Component\ProxyBuilder core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php Test child interface. 1
TestClass class Drupal\Tests\Core\Plugin core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php Stub class for testing PluginWithFormsTrait.
TestClass class Drupal\Tests\Component\Utility core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php Provides a test class.
TestClass class Drupal\Tests\layout_builder\Unit core/modules/layout_builder/tests/src/Unit/LayoutEntityHelperTraitTest.php Test class using the trait.
TestClass class Drupal\service_provider_test core/modules/system/tests/modules/service_provider_test/src/TestClass.php Handles kernel events for request and response. 2
TestClassAttribute class Drupal\router_test\Controller core/modules/system/tests/modules/router_test_directory/src/Controller/TestClassAttribute.php Test controller for class-level Route attribute with method-level merging. 1
TestClassClassMetadata final class Drupal\PHPStan\Rules core/tests/PHPStan/Rules/TestClassClassMetadata.php Rules class-level PHPUnit test metadata in test classes. 1
TestClassClassMetadataTest class Drupal\PHPStan\Tests core/tests/PHPStan/tests/TestClassClassMetadataTest.php Tests TestClassClassMetadata rule.
TestClassMethodMetadata final class Drupal\PHPStan\Rules core/tests/PHPStan/Rules/TestClassMethodMetadata.php Validates method-level PHPUnit test metadata in test classes. 1
TestClassMethodMetadataTest class Drupal\PHPStan\Tests core/tests/PHPStan/tests/TestClassMethodMetadataTest.php Tests TestClassMethodMetadata rule.
TestClosureHttpMiddlewareClass class Drupal\Tests\Core\DependencyInjection\Fixture core/tests/Drupal/Tests/Core/DependencyInjection/Fixture/TestClosureHttpMiddlewareClass.php Stub of http_middleware class taking a service closure for the inner kernel. 1
TestCompatClosureHttpMiddlewareClass class Drupal\Tests\Core\DependencyInjection\Fixture core/tests/Drupal/Tests/Core/DependencyInjection/Fixture/TestCompatClosureHttpMiddlewareClass.php Stub of http_middleware class taking a service closure with bc. 1
TestCompatibilityTrait trait Drupal\TestTools\PhpUnitCompatibility\PhpUnit11 core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit11/TestCompatibilityTrait.php Drupal's forward compatibility layer with multiple versions of PHPUnit.
TestCompatibilityTrait trait Drupal\TestTools\PhpUnitCompatibility\PhpUnit12 core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit12/TestCompatibilityTrait.php Drupal's forward compatibility layer with multiple versions of PHPUnit. 1
TestConcat class Drupal\Tests\migrate\Unit\process core/modules/migrate/tests/src/Unit/process/ConcatTest.php Mock class for the concat process plugin.
TestConditionAccessResolverTrait class Drupal\Tests\Core\Condition core/tests/Drupal/Tests/Core/Condition/ConditionAccessResolverTraitTest.php Stub class for testing trait.
TestConfigEntityWithPluginCollections class Drupal\Tests\Core\Config\Entity core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php Stub class for testing.
TestConfigFactoryOverrideBase class Drupal\Tests\Core\Config core/tests/Drupal/Tests/Core/Config/ConfigFactoryOverrideBaseTest.php Stub class for testing ConfigFactoryOverrideBase.
TestConfigNamesMapper class Drupal\Tests\config_translation\Unit core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php Defines a test mapper class.
TestConfigType class Drupal\module_installer_config_test\Entity core/modules/system/tests/modules/module_installer_config_test/src/Entity/TestConfigType.php Defines a configuration-based entity type used for testing.
TestConfigurableContextAwarePluginInterface interface Drupal\Tests\Core\Plugin core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php Test interface used for creating mock classes in tests.
TestConfigurablePlugin class Drupal\Tests\Core\Plugin\Fixtures core/tests/Drupal/Tests/Core/Plugin/Fixtures/TestConfigurablePlugin.php A configurable plugin implementation used for testing. 3
TestContainerDerivativeDiscovery class Drupal\Tests\Core\Plugin\Discovery core/tests/Drupal/Tests/Core/Plugin/Discovery/TestContainerDerivativeDiscovery.php Defines container test derivative discovery.
TestContent class Drupal\router_test core/modules/system/tests/modules/router_test_directory/src/TestContent.php Test controllers that are intended to be wrapped in a main controller.
TestContextAwareBlock class Drupal\block_test\Plugin\Block core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php Provides a context-aware block.
TestContextAwareLayout class Drupal\layout_builder_test\Plugin\Layout core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Layout/TestContextAwareLayout.php The TestContextAwareLayout Class.
TestContextAwareNoValidContextOptionsBlock class Drupal\block_test\Plugin\Block core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareNoValidContextOptionsBlock.php Provides a context-aware block that uses a not-passed, non-required context.
TestContextAwarePlugin class Drupal\KernelTests\Core\Plugin core/tests/Drupal/KernelTests/Core/Plugin/ContextHandlerTest.php Provides a test implementation of a context-aware plugin.
TestContextAwarePlugin class Drupal\KernelTests\Core\Plugin\Context core/tests/Drupal/KernelTests/Core/Plugin/Context/ContextAwarePluginTraitTest.php Context aware plugin test class.
TestContextAwarePluginDefinition class Drupal\KernelTests\Core\Plugin\Context core/tests/Drupal/KernelTests/Core/Plugin/Context/ContextAwarePluginTraitTest.php A plugin definition test class.
TestContextAwareUnsatisfiedBlock class Drupal\block_test\Plugin\Block core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareUnsatisfiedBlock.php Provides a context-aware block.
TestContextualLink class Drupal\menu_test\Plugin\Menu\ContextualLink core/modules/system/tests/modules/menu_test/src/Plugin/Menu/ContextualLink/TestContextualLink.php Defines a contextual link plugin with a dynamic title from user input. 1
TestController class Drupal\token_test\Controller core/modules/system/tests/modules/token_test/src/Controller/TestController.php Provides a test controller for token replacement.
TestController class Drupal\container_rebuild_test core/modules/system/tests/modules/container_rebuild_test/src/TestController.php Controller for testing module information and container reset functionality.
TestController class Drupal\path_changed_helper_test\Controller core/modules/system/tests/modules/path_changed_helper_test/src/Controller/TestController.php Controller for testing the PathChangedHelper class.
TestController class Drupal\csrf_race_test\Controller core/modules/system/tests/modules/csrf_race_test/src/Controller/TestController.php Controller to test concurrent CSRF token generation.

Other projects


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