Classes, traits, and interfaces - 11.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 1518

Name Deprecated Object type Namespace File name Summary Direct uses Use statements Strings
ArrayBuild class Drupal\migrate\Plugin\migrate\process core/modules/migrate/src/Plugin/migrate/process/ArrayBuild.php Builds an array based on the key and value configuration. 1 2
ArrayBuildTest class Drupal\Tests\migrate\Unit\process core/modules/migrate/tests/src/Unit/process/ArrayBuildTest.php @coversDefaultClass \Drupal\migrate\Plugin\migrate\process\ArrayBuild @group migrate
ArrayElement abstract class Drupal\Core\Config\Schema core/lib/Drupal/Core/Config/Schema/ArrayElement.php Defines a generic configuration element that contains multiple properties. 2 1
AssertBlockAppearsTrait trait Drupal\Tests\block\Functional core/modules/block/tests/src/Functional/AssertBlockAppearsTrait.php Provides test assertions for testing block appearance. 2
AssertBreadcrumbTrait trait Drupal\Tests\system\Functional\Menu core/modules/system/tests/src/Functional/Menu/AssertBreadcrumbTrait.php Provides test assertions for verifying breadcrumbs. 9
AssertConfigEntityImportTrait trait Drupal\Tests\config\Traits core/modules/config/tests/src/Traits/AssertConfigEntityImportTrait.php Provides test assertions for testing config entity synchronization. 1
AssertConfigTrait trait Drupal\KernelTests core/tests/Drupal/KernelTests/AssertConfigTrait.php Trait to help with diffing config. 4
AssertContentTrait trait Drupal\KernelTests core/tests/Drupal/KernelTests/AssertContentTrait.php Provides test methods to assert content. 1
AssertContentTraitTest class Drupal\Tests\Core\Test core/tests/Drupal/Tests/Core/Test/AssertContentTraitTest.php @coversDefaultClass \Drupal\KernelTests\AssertContentTrait @group Test
AssertMailTrait trait Drupal\Core\Test core/lib/Drupal/Core/Test/AssertMailTrait.php Provides methods for testing emails sent during test runs. 15
AssertMailTraitTest class Drupal\KernelTests\Core\Test core/tests/Drupal/KernelTests/Core/Test/AssertMailTraitTest.php Tests \Drupal\Core\Test\AssertMailTrait works.
AssertMenuActiveTrailTrait trait Drupal\Tests\system\Functional\Menu core/modules/system/tests/src/Functional/Menu/AssertMenuActiveTrailTrait.php Provides test assertions for verifying the active menu trail.
AssertPageCacheContextsAndTagsTrait trait Drupal\Tests\system\Functional\Cache core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php Provides test assertions for testing page-level cache contexts & tags. 44
AssertPreconditionsTrait trait Drupal\Tests\package_manager\Traits core/modules/package_manager/tests/src/Traits/AssertPreconditionsTrait.php Asserts preconditions for tests to function properly. 4
AssertUtilsTrait trait Drupal\Tests\Composer\Plugin\Scaffold core/tests/Drupal/Tests/Composer/Plugin/Scaffold/AssertUtilsTrait.php Convenience class for creating fixtures. 4
AssertViewsCacheTagsTrait trait Drupal\views\Tests core/modules/views/src/Tests/AssertViewsCacheTagsTrait.php 3
AssetAggregationAcrossPagesTest class Drupal\Tests\demo_umami\FunctionalJavascript core/profiles/demo_umami/tests/src/FunctionalJavascript/AssetAggregationAcrossPagesTest.php Tests demo_umami profile performance.
AssetCollectionGrouperInterface interface Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetCollectionGrouperInterface.php Interface defining a service that logically groups a collection of assets. 2 2
AssetCollectionGroupOptimizerInterface interface Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetCollectionGroupOptimizerInterface.php Interface defining a service that optimizes a collection of assets. 2
AssetCollectionOptimizerInterface interface Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetCollectionOptimizerInterface.php Interface defining a service that optimizes a collection of assets. 1 3
AssetCollectionRendererInterface interface Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetCollectionRendererInterface.php Interface defining a service that generates a render array to render assets. 2 4
AssetControllerBase abstract class Drupal\system\Controller core/modules/system/src/Controller/AssetControllerBase.php Defines a controller to serve asset aggregates. 2
AssetDumper class Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetDumper.php Dumps a CSS or JavaScript asset.
AssetDumperInterface interface Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetDumperInterface.php Interface defining a service that dumps an (optimized) asset. 1
AssetDumperUriInterface interface Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetDumperUriInterface.php Interface defining a service that dumps an asset to a specified location. 1 1
AssetGroupSetHashTrait trait Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetGroupSetHashTrait.php Provides a method to generate a normalized hash of a given asset group set. 3
AssetOptimizationTest class Drupal\FunctionalTests\Asset core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTest.php Tests asset aggregation. 1
AssetOptimizationTestUmami class Drupal\FunctionalTests\Asset core/tests/Drupal/FunctionalTests/Asset/AssetOptimizationTestUmami.php Tests asset aggregation with the Umami install profile.
AssetOptimizerInterface interface Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetOptimizerInterface.php Interface defining a service that optimizes an asset. 2 1
AssetQueryString class Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetQueryString.php Stores a cache busting query string service for asset URLs. 1
AssetQueryStringInterface interface Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetQueryStringInterface.php Provides a cache busting query string service for asset URLs. 1 2
AssetQueryStringTest class Drupal\KernelTests\Core\Asset core/tests/Drupal/KernelTests/Core/Asset/AssetQueryStringTest.php Tests the asset query string functionality.
AssetResolver class Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetResolver.php The default asset resolver. 1
AssetResolverInterface interface Drupal\Core\Asset core/lib/Drupal/Core/Asset/AssetResolverInterface.php Resolves asset libraries into concrete CSS and JavaScript assets. 1 5
AssetResolverTest class Drupal\Tests\Core\Asset core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php @coversDefaultClass \Drupal\Core\Asset\AssetResolver @group Asset
AssetRoutes class Drupal\system\Routing core/modules/system/src/Routing/AssetRoutes.php Defines a routes' callback to register a URL for serving assets.
AssetsStream class Drupal\Core\StreamWrapper core/lib/Drupal/Core/StreamWrapper/AssetsStream.php Defines a Drupal stream wrapper class for optimized assets (assets://). 1
AssignOwnerNode class Drupal\node\Plugin\Action core/modules/node/src/Plugin/Action/AssignOwnerNode.php Assigns ownership of a node to a user.
AttachedAssets class Drupal\Core\Asset core/lib/Drupal/Core/Asset/AttachedAssets.php The default attached assets collection. 12
AttachedAssetsInterface interface Drupal\Core\Asset core/lib/Drupal/Core/Asset/AttachedAssetsInterface.php The attached assets collection for the current response. 1 12
AttachedAssetsTest class Drupal\KernelTests\Core\Asset core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php Tests #attached assets: attached asset libraries and JavaScript settings.
AttachedRenderingBlock class Drupal\render_attached_test\Plugin\Block core/modules/system/tests/modules/render_attached_test/src/Plugin/Block/AttachedRenderingBlock.php A block we can use to test caching of #attached headers.
Attachment class Drupal\views\Plugin\views\display core/modules/views/src/Plugin/views/display/Attachment.php The plugin that handles an attachment display.
AttachmentsInterface interface Drupal\Core\Render core/lib/Drupal/Core/Render/AttachmentsInterface.php The attached metadata collection for a renderable element. 5 10
AttachmentsResponseProcessorInterface interface Drupal\Core\Render core/lib/Drupal/Core/Render/AttachmentsResponseProcessorInterface.php Defines an interface for processing attachments of responses that have them. 2 4
AttachmentsTestDomainObject class Drupal\early_rendering_controller_test core/modules/system/tests/modules/early_rendering_controller_test/src/AttachmentsTestDomainObject.php
AttachmentsTestResponse class Drupal\early_rendering_controller_test core/modules/system/tests/modules/early_rendering_controller_test/src/AttachmentsTestResponse.php
AttachmentsTrait trait Drupal\Core\Render core/lib/Drupal/Core/Render/AttachmentsTrait.php Provides an implementation of AttachmentsInterface. 3
AttachmentTestFormatter class Drupal\views_test_formatter\Plugin\Field\FieldFormatter core/modules/views/tests/modules/views_test_formatter/src/Plugin/Field/FieldFormatter/AttachmentTestFormatter.php Plugin implementation of the 'number_unformatted_with_attachment' formatter.
Attribute class Drupal\Core\Template core/lib/Drupal/Core/Template/Attribute.php Collects, sanitizes, and renders HTML attributes. 1 40 12

Other projects


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