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 1531

Name Deprecated Object type Namespace File name Summary Direct uses Use statements Strings
ContactSettings class Drupal\contact\Plugin\migrate\source core/modules/contact/src/Plugin/migrate/source/ContactSettings.php Drupal 6/7 contact settings source from database. 1
ContactSettingsTest class Drupal\Tests\contact\Kernel\Plugin\migrate\source\d6 core/modules/contact/tests/src/Kernel/Plugin/migrate/source/d6/ContactSettingsTest.php Tests D6 contact settings source plugin.
ContactSitewideTest class Drupal\Tests\contact\Functional core/modules/contact/tests/src/Functional/ContactSitewideTest.php Tests site-wide contact form functionality. 1
ContactStorageTest class Drupal\Tests\contact\Functional core/modules/contact/tests/src/Functional/ContactStorageTest.php Tests storing contact messages.
ContactStorageTestHooks class Drupal\contact_storage_test\Hook core/modules/contact/tests/modules/contact_storage_test/src/Hook/ContactStorageTestHooks.php Hook implementations for contact_storage_test.
ContactTest class Drupal\Tests\contact\Unit core/modules/contact/tests/src/Unit/ContactTest.php Tests for Contact hooks.
ContactViewsHooks class Drupal\contact\Hook core/modules/contact/src/Hook/ContactViewsHooks.php Hook implementations for contact.
Container class Drupal\Core\Render\Element core/lib/Drupal/Core/Render/Element/Container.php Provides a render element that wraps child elements in a container. 1
Container class Drupal\Component\DependencyInjection core/lib/Drupal/Component/DependencyInjection/Container.php Provides a container optimized for Drupal's needs. 2 3
Container class Drupal\Core\DependencyInjection core/lib/Drupal/Core/DependencyInjection/Container.php Extends the container to prevent serialization. 2 17
ContainerBuilder class Drupal\Core\DependencyInjection core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php Drupal's dependency injection container builder. 192
ContainerBuilderTest class Drupal\Tests\Core\DependencyInjection core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php Tests Drupal\Core\DependencyInjection\ContainerBuilder.
ContainerDerivativeDiscoveryDecorator class Drupal\Core\Plugin\Discovery core/lib/Drupal/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecorator.php Injects dependencies into derivers if they use ContainerDeriverInterface. 15
ContainerDerivativeDiscoveryDecoratorTest class Drupal\Tests\Core\Plugin\Discovery core/tests/Drupal/Tests/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecoratorTest.php Tests Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator.
ContainerDeriverInterface interface Drupal\Core\Plugin\Discovery core/lib/Drupal/Core/Plugin/Discovery/ContainerDeriverInterface.php Creates additional plugin definitions. 48 48
ContainerFactory class Drupal\Core\Plugin\Factory core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php Plugin factory which passes a container to a create method. 1 11
ContainerFactoryPluginInterface interface Drupal\Core\Plugin core/lib/Drupal/Core/Plugin/ContainerFactoryPluginInterface.php Defines an interface for pulling plugin dependencies from the container. 150 153
ContainerInjectionInterface interface Drupal\Core\DependencyInjection core/lib/Drupal/Core/DependencyInjection/ContainerInjectionInterface.php Defines a common interface for dependency container injection. 110 110
ContainerInterface interface Drupal\Component\DependencyInjection core/lib/Drupal/Component/DependencyInjection/ContainerInterface.php The interface for Drupal service container classes. 2 3
ContainerNotInitializedException class Drupal\Core\DependencyInjection core/lib/Drupal/Core/DependencyInjection/ContainerNotInitializedException.php Exception, thrown when a method is called on a non-initialized container. 2
ContainerRebuildTestServiceProvider class Drupal\container_rebuild_test core/modules/system/tests/modules/container_rebuild_test/src/ContainerRebuildTestServiceProvider.php The service provider for testing container rebuilds.
ContainerRebuildWebTest class Drupal\Tests\system\Functional\DrupalKernel core/modules/system/tests/src/Functional/DrupalKernel/ContainerRebuildWebTest.php Ensures that the container rebuild works as expected.
ContainerResetWebTest class Drupal\Tests\system\Functional\DrupalKernel core/modules/system/tests/src/Functional/DrupalKernel/ContainerResetWebTest.php Ensures that the container rebuild works as expected.
ContainerTest class Drupal\Tests\Component\DependencyInjection core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php Tests Drupal\Component\DependencyInjection\Container. 1
ContainerTest class Drupal\Tests\Core\DependencyInjection core/tests/Drupal/Tests/Core/DependencyInjection/ContainerTest.php Tests Drupal\Core\DependencyInjection\Container.
ContentDispositionFilenameParser final class Drupal\file\Upload core/modules/file/src/Upload/ContentDispositionFilenameParser.php Parses the content-disposition header to extract the client filename. 3
ContentDispositionFilenameParserTest class Drupal\Tests\file\Unit\Upload core/modules/file/tests/src/Unit/Upload/ContentDispositionFilenameParserTest.php Tests the ContentDispositionFilenameParser class.
ContentEntity

in drupal:11.2.0 and is removed from drupal:12.0.0. Use \Drupal\migrate\Plugin\migrate\source\ContentEntity instead.

This plugin uses the Entity API to export entity data. If the source entity type has custom field storage fields or computed fields, this class will need to be extended and the new class will need to load/calculate the values for those fields.

Available configuration keys:

  • entity_type: The entity type ID of the entities being exported. This is calculated dynamically by the deriver so it is only needed if the deriver is not utilized, i.e., a custom source plugin.
  • bundle: (optional) If the entity type is bundleable, only return entities of this bundle.
  • include_translations: (optional) Indicates if the entity translations should be included, defaults to TRUE.
  • add_revision_id: (optional) Indicates if the revision key is added to the source IDs, defaults to TRUE.

Examples:

This will return the default revision for all nodes, from every bundle and every translation. The revision key is added to the source IDs.

class Drupal\migrate_drupal\Plugin\migrate\source core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php Source plugin to get content entities from the current version of Drupal. 1
ContentEntity class Drupal\migrate\Plugin\migrate\source core/modules/migrate/src/Plugin/migrate/source/ContentEntity.php Source plugin to get content entities from the current version of Drupal. 1
ContentEntityBase abstract class Drupal\Core\Entity core/lib/Drupal/Core/Entity/ContentEntityBase.php Implements Entity Field API specific enhancements to the Entity class. 17 18
ContentEntityBaseMockableClass class Drupal\Tests\Core\Entity core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseMockableClass.php A class extending ContentEntityBase for mocking purposes. 6
ContentEntityBaseUnitTest class Drupal\Tests\Core\Entity core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php Tests Drupal\Core\Entity\ContentEntityBase.
ContentEntityChangedTest class Drupal\KernelTests\Core\Entity core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php Tests basic EntityChangedInterface functionality.
ContentEntityCloneTest class Drupal\KernelTests\Core\Entity core/tests/Drupal/KernelTests/Core/Entity/ContentEntityCloneTest.php Tests proper cloning of content entities.
ContentEntityConfirmFormBase abstract class Drupal\Core\Entity core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php Provides a generic base class for an entity-based confirmation form. 2 1
ContentEntityConstructorTest class Drupal\Tests\migrate\Kernel\Plugin\source core/modules/migrate/tests/src/Kernel/Plugin/source/ContentEntityConstructorTest.php Tests the constructor of the entity content source plugin.
ContentEntityConstructorTest class Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityConstructorTest.php Tests the constructor of the entity content source plugin.
ContentEntityDeleteForm class Drupal\Core\Entity core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php Provides a generic base class for a content entity deletion form. 9 12
ContentEntityDenormalizer final class Drupal\jsonapi\Normalizer core/modules/jsonapi/src/Normalizer/ContentEntityDenormalizer.php Converts a JSON:API array structure into a Drupal entity object. 2
ContentEntityDeriver

in drupal:11.2.0 and is removed from drupal:12.0.0. Use \Drupal\migrate\Plugin\migrate\source\ContentEntityDeriver instead.

class Drupal\migrate_drupal\Plugin\migrate\source core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntityDeriver.php Deriver for content entity source plugins.
ContentEntityDeriver class Drupal\migrate\Plugin\migrate\source core/modules/migrate/src/Plugin/migrate/source/ContentEntityDeriver.php Deriver for content entity source plugins.
ContentEntityFieldMethodInvocationOrderTest class Drupal\KernelTests\Core\Entity core/tests/Drupal/KernelTests/Core/Entity/ContentEntityFieldMethodInvocationOrderTest.php Tests correct field method invocation order.
ContentEntityForm class Drupal\Core\Entity core/lib/Drupal/Core/Entity/ContentEntityForm.php Entity form variant for content entity types. 14 17
ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest class Drupal\FunctionalTests\Entity core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php Tests the correct mapping of user input on the correct field delta elements.
ContentEntityFormFieldValidationFilteringTest class Drupal\FunctionalTests\Entity core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormFieldValidationFilteringTest.php Tests field validation filtering on content entity forms.
ContentEntityFormInterface interface Drupal\Core\Entity core/lib/Drupal/Core/Entity/ContentEntityFormInterface.php Defines a common interface for content entity form classes. 1 4
ContentEntityHasChangesTest class Drupal\KernelTests\Core\Entity core/tests/Drupal/KernelTests/Core/Entity/ContentEntityHasChangesTest.php Tests ContentEntityBase::hasTranslationChanges().
ContentEntityInterface interface Drupal\Core\Entity core/lib/Drupal/Core/Entity/ContentEntityInterface.php Defines a common interface for all content entity objects. 15 81 2
ContentEntityNonRevisionableFieldTest class Drupal\KernelTests\Core\Entity core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php Tests non-revisionable fields on revisionable (and translatable) entities.
ContentEntityNormalizer class Drupal\serialization\Normalizer core/modules/serialization/src/Normalizer/ContentEntityNormalizer.php Normalizes/denormalizes Drupal content entities into an array structure. 1 2

Other projects


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