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 1519

Name Deprecated Object type Namespace File name Summary Direct uses Use statements Strings
ClassResolverConstraintValidator class Drupal\Core\Validation\Plugin\Validation\Constraint core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ClassResolverConstraintValidator.php Validates if a method on a service or instantiated object returns true.
ClassResolverConstraintValidatorTest class Drupal\KernelTests\Core\TypedData core/tests/Drupal/KernelTests/Core/TypedData/ClassResolverConstraintValidatorTest.php Tests ClassResolver validation constraint with both valid and invalid values.
ClassResolverInterface interface Drupal\Core\DependencyInjection core/lib/Drupal/Core/DependencyInjection/ClassResolverInterface.php Provides interface to get an instance of a class with dependency injection. 1 23
ClassWithConstants class Drupal\Tests\Component\Annotation\Doctrine\Fixtures core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithConstants.php 1
ClassWithInvalidAnnotationTargetAtClass class Drupal\Tests\Component\Annotation\Doctrine\Fixtures core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithInvalidAnnotationTargetAtClass.php Plugin annotation @AnnotationTargetPropertyMethod("Some data");
ClassWithInvalidAnnotationTargetAtMethod class Drupal\Tests\Component\Annotation\Doctrine\Fixtures core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithInvalidAnnotationTargetAtMethod.php Plugin annotation @AnnotationTargetClass("Some data");
ClassWithInvalidAnnotationTargetAtProperty class Drupal\Tests\Component\Annotation\Doctrine\Fixtures core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithInvalidAnnotationTargetAtProperty.php Plugin annotation @AnnotationTargetClass("Some data");
ClassWithValidAnnotationTarget class Drupal\Tests\Component\Annotation\Doctrine\Fixtures core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/ClassWithValidAnnotationTarget.php Plugin annotation @AnnotationTargetClass("Some data");
Cleaner final class Drupal\package_manager\Plugin\QueueWorker core/modules/package_manager/src/Plugin/QueueWorker/Cleaner.php Processes a queue of defunct stage directories, deleting them.
ClearCacheBlock class Drupal\system\Plugin\Block core/modules/system/src/Plugin/Block/ClearCacheBlock.php Provides a block to display 'Clear cache' elements.
ClearCacheBlockTest class Drupal\Tests\system\Functional\Block core/modules/system/tests/src/Functional/Block/ClearCacheBlockTest.php Tests clear cache block behavior.
ClearCacheForm class Drupal\system\Form core/modules/system/src/Form/ClearCacheForm.php Clear caches for this site. 2
ClearTest class Drupal\Tests\system\Functional\Cache core/modules/system/tests/src/Functional/Cache/ClearTest.php Tests our clearing is done the proper way.
ClickSortingAJAXTest class Drupal\Tests\views\FunctionalJavascript core/modules/views/tests/src/FunctionalJavascript/ClickSortingAJAXTest.php Tests the click sorting AJAX functionality of Views exposed forms.
ClientErrorResponseSubscriber class Drupal\Core\EventSubscriber core/lib/Drupal/Core/EventSubscriber/ClientErrorResponseSubscriber.php Response subscriber to set the '4xx-response' cache tag on 4xx responses. 2
ClientFactory class Drupal\Core\Http core/lib/Drupal/Core/Http/ClientFactory.php Helper class to construct a HTTP client with Drupal specific config. 1 2
ClientFactoryTest class Drupal\Tests\Core\Http core/tests/Drupal/Tests/Core/Http/ClientFactoryTest.php Tests Drupal\Core\Http\ClientFactory.
CloseDialogCommand class Drupal\Core\Ajax core/lib/Drupal/Core/Ajax/CloseDialogCommand.php Defines an AJAX command that closes the current active dialog. 1 6
CloseModalDialogCommand class Drupal\Core\Ajax core/lib/Drupal/Core/Ajax/CloseModalDialogCommand.php Defines an AJAX command that closes the currently visible modal dialog. 2
CodeBlock class Drupal\ckeditor5\Plugin\CKEditor5Plugin core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/CodeBlock.php CKEditor 5 Code Block plugin configuration. 1
CollapsedSummariesTest class Drupal\Tests\node\FunctionalJavascript core/modules/node/tests/src/FunctionalJavascript/CollapsedSummariesTest.php Tests that outlines of node meta values are displayed in summaries and tabs.
CollectPathsToExcludeEvent final class Drupal\package_manager\Event core/modules/package_manager/src/Event/CollectPathsToExcludeEvent.php Defines an event that collects paths to exclude. 18
CollectPathsToExcludeFailValidator class Drupal\package_manager_test_validation core/modules/package_manager/tests/modules/package_manager_test_validation/src/CollectPathsToExcludeFailValidator.php Allows to test an excluder which fails on CollectPathsToExcludeEvent. 2
CollectRelationshipMetaEvent final class Drupal\jsonapi\Events core/modules/jsonapi/src/Events/CollectRelationshipMetaEvent.php Event for collecting the relationship metadata of a JSON:API resource object. 3
CollectResourceObjectMetaEvent final class Drupal\jsonapi\Events core/modules/jsonapi/src/Events/CollectResourceObjectMetaEvent.php Event for collecting resource object metadata of a JSON:API resource types. 2
CollectRoutesTest class Drupal\Tests\rest\Unit core/modules/rest/tests/src/Unit/CollectRoutesTest.php Tests the REST export view plugin.
Color class Drupal\Core\Render\Element core/lib/Drupal/Core/Render/Element/Color.php Provides a form element for choosing a color.
Color class Drupal\Component\Utility core/lib/Drupal/Component/Utility/Color.php Performs color conversions. 6
ColorTest class Drupal\Tests\Component\Utility core/tests/Drupal/Tests/Component/Utility/ColorTest.php Tests Color utility class conversions.
Com class Drupal\Component\Uuid core/lib/Drupal/Component/Uuid/Com.php Generates a UUID using the Windows internal GUID extension. 1
Combine class Drupal\views\Plugin\views\filter core/modules/views/src/Plugin/views/filter/Combine.php Filter handler which allows to search on multiple fields.
CommandInterface interface Drupal\Core\Ajax core/lib/Drupal/Core/Ajax/CommandInterface.php AJAX command interface. 31 9
CommandLineOrUnsafeMethod class Drupal\Core\PageCache\RequestPolicy core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php Reject when running from the command line or when HTTP method is not safe. 3
CommandLineOrUnsafeMethodTest class Drupal\Tests\Core\PageCache core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php Tests Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod.
CommandProvider class Drupal\Composer\Plugin\Scaffold composer/Plugin/Scaffold/CommandProvider.php List of all commands provided by this package. 1
CommandProvider final class Drupal\Composer\Plugin\RecipeUnpack composer/Plugin/RecipeUnpack/CommandProvider.php List of all commands provided by this package. 1
CommandsTest class Drupal\FunctionalJavascriptTests\Ajax core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php Performs tests on AJAX framework commands.
CommandsTest class Drupal\KernelTests\Core\Ajax core/tests/Drupal/KernelTests/Core/Ajax/CommandsTest.php Performs tests on AJAX framework commands.
CommandWithAttachedAssetsInterface interface Drupal\Core\Ajax core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsInterface.php Interface for Ajax commands that render content and attach assets. 5
CommandWithAttachedAssetsTrait trait Drupal\Core\Ajax core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php Trait for Ajax commands that render content and attach assets.
Comment class Drupal\comment\Entity core/modules/comment/src/Entity/Comment.php Defines the comment entity class. 52
Comment class Drupal\comment\Plugin\views\wizard core/modules/comment/src/Plugin/views/wizard/Comment.php Tests creating comment views with the wizard.
Comment class Drupal\comment\Plugin\migrate\source\d6 core/modules/comment/src/Plugin/migrate/source/d6/Comment.php Drupal 6 comment source from database.
Comment class Drupal\comment\Plugin\migrate\source\d7 core/modules/comment/src/Plugin/migrate/source/d7/Comment.php Drupal 7 comment source from database.
CommentAccessControlHandler class Drupal\comment core/modules/comment/src/CommentAccessControlHandler.php Defines the access control handler for the comment entity type. 1
CommentAccessTest class Drupal\Tests\comment\Functional core/modules/comment/tests/src/Functional/CommentAccessTest.php Tests comment administration and preview access.
CommentAdminOverview class Drupal\comment\Form core/modules/comment/src/Form/CommentAdminOverview.php Provides the comments overview administration form. 1
CommentAdminTest class Drupal\Tests\comment\Functional core/modules/comment/tests/src/Functional/CommentAdminTest.php Tests comment approval functionality.
CommentAdminTest class Drupal\Tests\comment\Functional\Views core/modules/comment/tests/src/Functional/Views/CommentAdminTest.php Tests comment approval functionality.
CommentAdminViewTest class Drupal\Tests\comment\Kernel\Views core/modules/comment/tests/src/Kernel/Views/CommentAdminViewTest.php Tests comment admin view filters.

Other projects


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