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
ContextInterface interface Drupal\Component\Plugin\Context core/lib/Drupal/Component/Plugin/Context/ContextInterface.php Provides data and definitions for plugins during runtime and administration. 2 8
ContextPluginTest class Drupal\KernelTests\Core\Plugin core/tests/Drupal/KernelTests/Core/Plugin/ContextPluginTest.php Tests that contexts are properly set and working within plugins.
ContextProviderInterface interface Drupal\Core\Plugin\Context core/lib/Drupal/Core/Plugin/Context/ContextProviderInterface.php Defines an interface for providing plugin contexts. 7 7
ContextProvidersPass

in drupal:10.2.0 and is removed from drupal:11.0.0. The context.repository service uses the service_id_collector pattern instead so this is no longer needed.

class Drupal\Core\DependencyInjection\Compiler core/lib/Drupal/Core/DependencyInjection/Compiler/ContextProvidersPass.php Adds the context provider service IDs to the context manager.
ContextRepositoryInterface interface Drupal\Core\Plugin\Context core/lib/Drupal/Core/Plugin/Context/ContextRepositoryInterface.php Offers a global context repository. 1 6
ContextTest class Drupal\Tests\Core\Plugin\Context core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php @coversDefaultClass \Drupal\Core\Plugin\Context\Context @group Plugin
ContextTest class Drupal\Tests\Component\Plugin\Context core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php @coversDefaultClass \Drupal\Component\Plugin\Context\Context @group Plugin
ContextTypedDataTest class Drupal\KernelTests\Core\Plugin core/tests/Drupal/KernelTests/Core/Plugin/ContextTypedDataTest.php Tests that contexts work properly with the typed data manager.
ContextualController class Drupal\contextual core/modules/contextual/src/ContextualController.php Returns responses for Contextual module routes.
ContextualDynamicContextTest class Drupal\Tests\contextual\Functional core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php Tests contextual link display on the front page based on permissions.
ContextualFiltersBlockContextTest class Drupal\Tests\views\Functional\Plugin core/modules/views/tests/src/Functional/Plugin/ContextualFiltersBlockContextTest.php A test for contextual filters exposed as block context.
ContextualFiltersStringTest class Drupal\Tests\views\Functional\Plugin core/modules/views/tests/src/Functional/Plugin/ContextualFiltersStringTest.php Test contextual filters with 'allow multiple values' setting for user roles.
ContextualFilterTest class Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/ContextualFilterTest.php Tests the contextual filter handler UI.
ContextualLinkClickTrait trait Drupal\Tests\contextual\FunctionalJavascript core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinkClickTrait.php Functions for testing contextual links. 11
ContextualLinkDefault class Drupal\Core\Menu core/lib/Drupal/Core/Menu/ContextualLinkDefault.php Provides a common base implementation of a contextual link. 2 4
ContextualLinkDefaultTest class Drupal\Tests\Core\Menu core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php @group Menu @coversDefaultClass \Drupal\Core\Menu\ContextualLinkDefault
ContextualLinkInterface interface Drupal\Core\Menu core/lib/Drupal/Core/Menu/ContextualLinkInterface.php Defines a contextual link plugin. 1
ContextualLinkManager class Drupal\Core\Menu core/lib/Drupal/Core/Menu/ContextualLinkManager.php Defines a contextual link plugin manager to deal with contextual links. 1 2
ContextualLinkManagerInterface interface Drupal\Core\Menu core/lib/Drupal/Core/Menu/ContextualLinkManagerInterface.php Provides an object which returns the available contextual links. 1
ContextualLinkManagerTest class Drupal\Tests\Core\Menu core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php @coversDefaultClass \Drupal\Core\Menu\ContextualLinkManager @group Menu
ContextualLinks class Drupal\contextual\Element core/modules/contextual/src/Element/ContextualLinks.php Provides a contextual_links element.
ContextualLinks class Drupal\contextual\Plugin\views\field core/modules/contextual/src/Plugin/views/field/ContextualLinks.php Provides a handler that adds contextual links.
ContextualLinksPlaceholder class Drupal\contextual\Element core/modules/contextual/src/Element/ContextualLinksPlaceholder.php Provides a contextual_links_placeholder element.
ContextualLinksTest class Drupal\Tests\contextual\FunctionalJavascript core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php Tests the UI for correct contextual links.
ContextualLinksTest class Drupal\Tests\layout_builder\FunctionalJavascript core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php Test contextual links compatibility with the Layout Builder.
ContextualLinksTest class Drupal\Tests\node\FunctionalJavascript core/modules/node/tests/src/FunctionalJavascript/ContextualLinksTest.php Create a node with revisions and test contextual links.
ContextualUnitTest class Drupal\Tests\contextual\Kernel core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php Tests edge cases for converting between contextual links and IDs.
ContextualValidatorInterface interface Drupal\Core\TypedData\Validation core/lib/Drupal/Core/TypedData/Validation/ContextualValidatorInterface.php Extends the contextual validator validate method by a new parameter. 1
Contrib class Drupal\ckeditor5\Plugin\CKEditor4To5Upgrade core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Contrib.php Provides the CKEditor 4 to 5 upgrade path for contrib plugins now in core.
ControllerBase abstract class Drupal\Core\Controller core/lib/Drupal/Core/Controller/ControllerBase.php Utility base class for thin controllers. 93 94
ControllerBaseTest class Drupal\KernelTests\Core\Controller core/tests/Drupal/KernelTests/Core/Controller/ControllerBaseTest.php Tests \Drupal\Core\Controller\ControllerBase.
ControllerBaseTest class Drupal\Tests\Core\Controller core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php Tests that the base controller class.
ControllerResolver class Drupal\Core\Controller core/lib/Drupal/Core/Controller/ControllerResolver.php ControllerResolver to enhance controllers beyond Symfony's basic handling. 1 2
ControllerResolverInterface interface Drupal\Core\Controller core/lib/Drupal/Core/Controller/ControllerResolverInterface.php Extends the ControllerResolverInterface from symfony. 1 7
ControllerResolverTest class Drupal\Tests\Core\Controller core/tests/Drupal/Tests/Core/Controller/ControllerResolverTest.php @coversDefaultClass \Drupal\Core\Controller\ControllerResolver @group Controller
Convert class Drupal\system\Plugin\ImageToolkit\Operation\gd core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Convert.php Defines GD2 convert operation.
ConvertImageEffect class Drupal\image\Plugin\ImageEffect core/modules/image/src/Plugin/ImageEffect/ConvertImageEffect.php Converts an image resource.
ConvertTest class Drupal\Tests\image\Functional\ImageEffect core/modules/image/tests/src/Functional/ImageEffect/ConvertTest.php Tests for the Convert image effect.
ConvertTokens class Drupal\user\Plugin\migrate\process core/modules/user/src/Plugin/migrate/process/ConvertTokens.php Plugin to replace !tokens with [tokens]. 1
ConvertTokensTest class Drupal\Tests\user\Unit\Plugin\migrate\process core/modules/user/tests/src/Unit/Plugin/migrate/process/ConvertTokensTest.php Tests the ConvertTokens plugin.
Cookie class Drupal\user\Authentication\Provider core/modules/user/src/Authentication/Provider/Cookie.php Cookie based authentication provider. 1 2
CookieCacheContextTest class Drupal\Tests\Core\Cache\Context core/tests/Drupal/Tests/Core/Cache/Context/CookieCacheContextTest.php @coversDefaultClass \Drupal\Core\Cache\Context\CookiesCacheContext @group Cache
CookieResourceTestTrait trait Drupal\Tests\rest\Functional core/modules/rest/tests/src/Functional/CookieResourceTestTrait.php Trait for ResourceTestBase subclasses testing $auth=cookie. 103
CookiesCacheContext class Drupal\Core\Cache\Context core/lib/Drupal/Core/Cache/Context/CookiesCacheContext.php Defines the CookiesCacheContext service, for "per cookie" caching. 1 2
CopyFieldValueTest class Drupal\Tests\system\FunctionalJavascript core/modules/system/tests/src/FunctionalJavascript/CopyFieldValueTest.php Tests copy field value functionality.
CopyFieldValueTestForm class Drupal\system_test\Form core/modules/system/tests/modules/system_test/src/Form/CopyFieldValueTestForm.php Provides a form to test Drupal.behaviors.copyFieldValue. 1
CopyTest class Drupal\Tests\file\Kernel core/modules/file/tests/src/Kernel/CopyTest.php Tests the file copy function.
Core class Drupal\ckeditor5\Plugin\CKEditor4To5Upgrade core/modules/ckeditor5/src/Plugin/CKEditor4To5Upgrade/Core.php Provides the CKEditor 4 to 5 upgrade for Drupal core's CKEditor plugins.
CoreRecipesTest class Drupal\FunctionalTests\Core\Recipe core/tests/Drupal/FunctionalTests/Core/Recipe/CoreRecipesTest.php Tests applying all core-provided recipes on top of the Empty profile.
CoreServiceProvider class Drupal\Core core/lib/Drupal/Core/CoreServiceProvider.php ServiceProvider class for mandatory core services.

Other projects


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