Classes, traits, and interfaces - 10.3.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
ComponentElement class Drupal\Core\Render\Element core/lib/Drupal/Core/Render/Element/ComponentElement.php Provides a Single-Directory Component render element.
ComponentEntityDisplayBase abstract class Drupal\migrate\Plugin\migrate\destination core/modules/migrate/src/Plugin/migrate/destination/ComponentEntityDisplayBase.php Provides a destination plugin for migrating entity display components. 3 2
ComponentGenerator class Drupal\Composer\Generator composer/Generator/ComponentGenerator.php Reconciles Drupal component dependencies with core. 1
ComponentInvalidReplacementTest class Drupal\KernelTests\Components core/tests/Drupal/KernelTests/Components/ComponentInvalidReplacementTest.php Tests invalid render options for components.
ComponentKernelTestBase abstract class Drupal\Tests\Core\Theme\Component core/tests/Drupal/Tests/Core/Theme/Component/ComponentKernelTestBase.php Defines a base class for component kernel tests. 6 4
ComponentLoader class Drupal\Core\Template\Loader core/lib/Drupal/Core/Template/Loader/ComponentLoader.php Lets you load templates using the component ID. 1
ComponentMetadata class Drupal\Core\Theme\Component core/lib/Drupal/Core/Theme/Component/ComponentMetadata.php Component metadata. 2
ComponentMetadataTest class Drupal\Tests\Core\Theme\Component core/tests/Drupal/Tests/Core/Theme/Component/ComponentMetadataTest.php Unit tests for the component metadata class.
ComponentNegotiator class Drupal\Core\Theme core/lib/Drupal/Core/Theme/ComponentNegotiator.php Determines which component should be used. 1 1
ComponentNegotiatorTest class Drupal\Tests\Core\Theme\Component core/tests/Drupal/Tests/Core/Theme/Component/ComponentNegotiatorTest.php Tests the component negotiator.
ComponentNodeVisitor class Drupal\Core\Template core/lib/Drupal/Core/Template/ComponentNodeVisitor.php Provides a ComponentNodeVisitor to change the generated parse-tree.
ComponentNodeVisitorTest class Drupal\KernelTests\Components core/tests/Drupal/KernelTests/Components/ComponentNodeVisitorTest.php Tests the node visitor.
ComponentNotFoundException class Drupal\Core\Render\Component\Exception core/lib/Drupal/Core/Render/Component/Exception/ComponentNotFoundException.php Raised when a component cannot be found. 5
ComponentPluginManager class Drupal\Core\Theme core/lib/Drupal/Core/Theme/ComponentPluginManager.php Defines a plugin manager to deal with components. 8 2
ComponentPluginManagerTest class Drupal\Tests\Core\Theme\Component core/tests/Drupal/Tests/Core/Theme/Component/ComponentPluginManagerTest.php Tests the component plugin manager.
ComponentRenderInvalidTest class Drupal\KernelTests\Components core/tests/Drupal/KernelTests/Components/ComponentRenderInvalidTest.php Tests invalid render options for components.
ComponentRenderTest class Drupal\KernelTests\Components core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php Tests the correct rendering of components.
ComponentRenderTest class Drupal\FunctionalTests\Components core/tests/Drupal/FunctionalTests/Components/ComponentRenderTest.php Tests the correct rendering of components.
ComponentRenderTest class Drupal\FunctionalJavascriptTests\Components core/tests/Drupal/FunctionalJavascriptTests/Components/ComponentRenderTest.php Tests the correct rendering of components.
ComponentsIsolatedBuildTest class Drupal\BuildTests\Composer\Component core/tests/Drupal/BuildTests/Composer/Component/ComponentsIsolatedBuildTest.php Try to install dependencies per component, using Composer.
ComponentsTaggedReleaseTest class Drupal\BuildTests\Composer\Component core/tests/Drupal/BuildTests/Composer/Component/ComponentsTaggedReleaseTest.php Demonstrate that the Component generator responds to release tagging.
ComponentsTwigExtension final class Drupal\Core\Template core/lib/Drupal/Core/Template/ComponentsTwigExtension.php The twig extension so Drupal can recognize the new code. 1
ComponentValidator class Drupal\Core\Theme\Component core/lib/Drupal/Core/Theme/Component/ComponentValidator.php Validates a component based on its definition and the component schema. 3 1
ComponentValidatorTest class Drupal\Tests\Core\Theme\Component core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php Unit tests for the component validation.
Composer class Drupal\Core\Composer core/lib/Drupal/Core/Composer/Composer.php Provides static functions for composer script events.
Composer class Drupal\Composer composer/Composer.php Provides static functions for composer script events. 8
ComposerBuildTestBase abstract class Drupal\BuildTests\Composer core/tests/Drupal/BuildTests/Composer/ComposerBuildTestBase.php Base class for Composer build tests. 3 3
ComposerHookTest class Drupal\Tests\Composer\Plugin\Scaffold\Functional core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ComposerHookTest.php Tests Composer Hooks that run scaffold operations.
ComposerIntegrationTest class Drupal\Tests core/tests/Drupal/Tests/ComposerIntegrationTest.php Tests Composer integration.
ComposerIntegrationTrait trait Drupal\Tests\Composer core/tests/Drupal/Tests/Composer/ComposerIntegrationTrait.php Some utility functions for testing the Composer integration. 2
ComposerPluginImplementsScaffoldEvents class Drupal\Tests\fixture\Composer\Plugin core/tests/Drupal/Tests/Composer/Plugin/Scaffold/fixtures/composer-plugin-implements-scaffold-events/src/ComposerPluginImplementsScaffoldEvents.php A fixture composer plugin implement Drupal scaffold events.
ComposerProjectTemplatesTest class Drupal\BuildTests\Composer\Template core/tests/Drupal/BuildTests/Composer/Template/ComposerProjectTemplatesTest.php Demonstrate that Composer project templates can be built as patched.
ComposerScaffoldCommand class Drupal\Composer\Plugin\Scaffold composer/Plugin/Scaffold/ComposerScaffoldCommand.php The "drupal:scaffold" command class.
ComposerTest class Drupal\Tests\Composer core/tests/Drupal/Tests/Composer/ComposerTest.php @coversDefaultClass \Drupal\Composer\Composer[[api-linebreak]] @group Composer
ComposerValidateTest class Drupal\BuildTests\Composer core/tests/Drupal/BuildTests/Composer/ComposerValidateTest.php @group Composer
CompositeConstraintBase abstract class Drupal\Core\Entity\Plugin\Validation\Constraint core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/CompositeConstraintBase.php Provides a base class for constraints validating multiple fields. 4 6
CompositeFormElementTrait trait Drupal\Core\Render\Element core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php Provides a trait for radios, checkboxes, and similar composite form elements.
ComputedBundleFieldTest class Drupal\Tests\views\Kernel\Handler core/modules/views/tests/src/Kernel/Handler/ComputedBundleFieldTest.php Provides some integration tests for computed bundle fields.
ComputedFieldTest class Drupal\Tests\views\Kernel\Handler core/modules/views/tests/src/Kernel/Handler/ComputedFieldTest.php Provides some integration tests for the Field handler.
ComputedFileUrl class Drupal\file core/modules/file/src/ComputedFileUrl.php Computed file URL property class. 2
ComputedFileUrlTest class Drupal\Tests\file\Kernel core/modules/file/tests/src/Kernel/ComputedFileUrlTest.php @coversDefaultClass \Drupal\file\ComputedFileUrl[[api-linebreak]]
ComputedItemListTrait trait Drupal\Core\TypedData core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php Provides common functionality for computed item lists. 7
ComputedReferenceTestFieldItemList class Drupal\entity_test\Plugin\Field core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedReferenceTestFieldItemList.php A computed entity reference field item list. 2
ComputedString class Drupal\entity_test\TypedData core/modules/system/tests/modules/entity_test/src/TypedData/ComputedString.php A computed property for test strings. 2
ComputedTestBundleFieldItemList class Drupal\entity_test\Plugin\Field core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedTestBundleFieldItemList.php A computed field item list for a bundle field. 1
ComputedTestCacheableIntegerItemList class Drupal\entity_test\Plugin\Field core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedTestCacheableIntegerItemList.php Item list class for computed cacheable string field. 1
ComputedTestCacheableString class Drupal\entity_test\Plugin\DataType core/modules/system/tests/modules/entity_test/src/Plugin/DataType/ComputedTestCacheableString.php The string data type with cacheability metadata.
ComputedTestCacheableStringItem class Drupal\entity_test\Plugin\Field\FieldType core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ComputedTestCacheableStringItem.php Defines the 'string' entity field type with cacheability metadata.
ComputedTestCacheableStringItemList class Drupal\entity_test\Plugin\Field core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedTestCacheableStringItemList.php Item list class for computed cacheable string field. 2
ComputedTestFieldItemList class Drupal\entity_test\Plugin\Field core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedTestFieldItemList.php A computed field item list. 2

Other projects


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