Classes, traits, and interfaces - 9.5.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 1523

Name Deprecated Object type Namespace File name Summary Direct uses Use statements Strings
ClassFinderTest class Drupal\Tests\Component\ClassFinder core/tests/Drupal/Tests/Component/ClassFinder/ClassFinderTest.php @coversDefaultClass \Drupal\Component\ClassFinder\ClassFinder @group ClassFinder
ClassLoaderTest class Drupal\Tests\system\Functional\Module core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php Tests class loading for modules.
ClassRequiresAvailable class Drupal\BuildTests\Framework\Tests core/tests/Drupal/BuildTests/Framework/Tests/ExternalCommandRequirementTest.php @requires externalCommand available_command
ClassRequiresUnavailable class Drupal\BuildTests\Framework\Tests core/tests/Drupal/BuildTests/Framework/Tests/ExternalCommandRequirementTest.php @requires externalCommand unavailable_command
ClassResolver class Drupal\Core\DependencyInjection core/lib/Drupal/Core/DependencyInjection/ClassResolver.php Implements the class resolver interface supporting class names and services. 2 2
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 20
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");
ClassWriter final class Drupal\TestTools\PhpUnitCompatibility\PhpUnit8 core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit8/ClassWriter.php Helper class to rewrite PHPUnit's TestCase class. 2
ClassyPreprocessUnchangedTest class Drupal\Tests\Core\Theme core/tests/Drupal/Tests/Core/Theme/ClassyPreprocessUnchangedTest.php Confirms that classy.theme has not added new functionality.
ClassyTemplatesIdenticalToStableTest class Drupal\Tests\Core\Theme core/tests/Drupal/Tests/Core/Theme/ClassyTemplatesIdenticalToStableTest.php Confirms that certain Classy templates have identical equivalents in Stable.
ClassyTest class Drupal\Tests\classy\Kernel core/themes/classy/tests/src/Kernel/ClassyTest.php Tests the Classy theme.
ClassyTest class Drupal\Tests\classy\Functional core/themes/classy/tests/src/Functional/ClassyTest.php Tests the classy theme.
ClassyUninstallUpdateTest class Drupal\Tests\system\Functional\Update core/modules/system/tests/src/Functional/Update/ClassyUninstallUpdateTest.php Ensures that update hook uninstalls Classy when it's no longer needed.
ClearTest class Drupal\Tests\system\Functional\Cache core/modules/system/tests/src/Functional/Cache/ClearTest.php
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. 2 2
ClientFactoryTest class Drupal\Tests\Core\Http core/tests/Drupal/Tests/Core/Http/ClientFactoryTest.php @coversDefaultClass \Drupal\Core\Http\ClientFactory @group Http
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. 5
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.
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. 7
Color class Drupal\color\Plugin\migrate\destination core/modules/color/src/Plugin/migrate/destination/Color.php Persist color data to the config system. 1
Color class Drupal\color\Plugin\migrate\source\d7 core/modules/color/src/Plugin/migrate/source/d7/Color.php Drupal 7 color source from database.
ColorConfigCacheInvalidator class Drupal\color\EventSubscriber core/modules/color/src/EventSubscriber/ColorConfigCacheInvalidator.php A subscriber invalidating cache tags when color config objects are saved. 2
ColorConfigSchemaTest class Drupal\Tests\color\Functional core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php Ensures the color config schema is correct.
ColorSafePreviewTest class Drupal\Tests\color\Functional core/modules/color/tests/src/Functional/ColorSafePreviewTest.php Tests sanitizing color preview loaded from theme.
ColorSystemBrandingBlockAlter class Drupal\color core/modules/color/src/ColorSystemBrandingBlockAlter.php Provides a trusted callback to alter the system branding block. 1
ColorTest class Drupal\Tests\color\Kernel\Plugin\migrate\source\d7 core/modules/color/tests/src/Kernel/Plugin/migrate/source/d7/ColorTest.php Tests D7 color source plugin.
ColorTest class Drupal\Tests\color\Functional core/modules/color/tests/src/Functional/ColorTest.php Modify theme colors and make sure the changes are reflected on the frontend.
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 11
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. 2
CommandLineOrUnsafeMethodTest class Drupal\Tests\Core\PageCache core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php @coversDefaultClass \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod @group PageCache
CommandProvider class Drupal\Composer\Plugin\Scaffold composer/Plugin/Scaffold/CommandProvider.php List of all commands provided by this package. 1
CommandsTest class Drupal\KernelTests\Core\Ajax core/tests/Drupal/KernelTests/Core/Ajax/CommandsTest.php Performs tests on AJAX framework commands.
CommandsTest class Drupal\FunctionalJavascriptTests\Ajax core/tests/Drupal/FunctionalJavascriptTests/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. 4
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. 57
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. 1 1

Other projects


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