Classes, traits, and interfaces - main - 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 1529

Name Deprecated Object type Namespace File name Summary Direct uses Use statements Strings
ToolbarTestThemeHooks class Drupal\toolbar_test\Hook core/modules/toolbar/tests/modules/toolbar_test/src/Hook/ToolbarTestThemeHooks.php Hook implementations for toolbar_test.
ToolbarThemeHooks class Drupal\toolbar\Hook core/modules/toolbar/src/Hook/ToolbarThemeHooks.php Hook implementations for toolbar.
ToolkitGdTest class Drupal\KernelTests\Core\Image core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php Tests for the GD image toolkit.
ToolkitSetupFormTest class Drupal\FunctionalTests\Image core/tests/Drupal/FunctionalTests/Image/ToolkitSetupFormTest.php Tests image toolkit setup form.
ToolkitTest class Drupal\KernelTests\Core\Image core/tests/Drupal/KernelTests/Core/Image/ToolkitTest.php Tests the image toolkit.
ToolkitTestTrait trait Drupal\Tests\Traits\Core\Image core/tests/Drupal/Tests/Traits/Core/Image/ToolkitTestTrait.php Provides common methods for image toolkit kernel tests. 2
TopBar class Drupal\navigation\Element core/modules/navigation/src/Element/TopBar.php Provides a render element for the default Drupal toolbar.
TopBarItem final class Drupal\navigation\Attribute core/modules/navigation/src/Attribute/TopBarItem.php The top bar item attribute. 8
TopBarItemBase abstract class Drupal\navigation core/modules/navigation/src/TopBarItemBase.php Base class for top bar item plugins. 7 8
TopBarItemBaseTest class Drupal\Tests\navigation\Unit core/modules/navigation/tests/src/Unit/TopBarItemBaseTest.php Tests Drupal\navigation\TopBarItemBase.
TopBarItemHigh class Drupal\navigation_test\Plugin\TopBarItem core/modules/navigation/tests/navigation_test/src/Plugin/TopBarItem/TopBarItemHigh.php Provides a top bar item plugin for testing the top bar item weight.
TopBarItemInstantiation class Drupal\navigation_test\Plugin\TopBarItem core/modules/navigation/tests/navigation_test/src/Plugin/TopBarItem/TopBarItemInstantiation.php Provides a top bar item plugin for testing the top bar. 1
TopBarItemLinkAttribute class Drupal\navigation_test_top_bar\Plugin\TopBarItem core/modules/navigation/tests/navigation_test_top_bar/src/Plugin/TopBarItem/TopBarItemLinkAttribute.php Provides a top bar item plugin for testing link attributes in the top bar.
TopBarItemLow class Drupal\navigation_test\Plugin\TopBarItem core/modules/navigation/tests/navigation_test/src/Plugin/TopBarItem/TopBarItemLow.php Provides a top bar item plugin for testing the top bar item weight.
TopBarItemManager final class Drupal\navigation core/modules/navigation/src/TopBarItemManager.php Top bar item plugin manager. 1 2
TopBarItemManagerInterface interface Drupal\navigation core/modules/navigation/src/TopBarItemManagerInterface.php Top bar item plugin manager. 1 3
TopBarItemManagerTest class Drupal\Tests\navigation\Unit core/modules/navigation/tests/src/Unit/TopBarItemManagerTest.php Tests Drupal\navigation\TopBarItemManager.
TopBarItemPluginInterface interface Drupal\navigation core/modules/navigation/src/TopBarItemPluginInterface.php Interface for top bar plugins. 1
TopBarItemZero class Drupal\navigation_test\Plugin\TopBarItem core/modules/navigation/tests/navigation_test/src/Plugin/TopBarItem/TopBarItemZero.php Provides a top bar item plugin for testing the top bar item weight.
TopLevelDataInterface interface Drupal\jsonapi\JsonApiResource core/modules/jsonapi/src/JsonApiResource/TopLevelDataInterface.php Interface for objects that can appear as top-level object data. 2 1
ToStringTrait

in drupal:11.4.0 and is removed from drupal:13.0.0. Implement the __toString() method directly, exception handling is no longer required.

trait Drupal\Component\Utility core/lib/Drupal/Component/Utility/ToStringTrait.php Wraps __toString in a trait to avoid some fatal errors.
TrackChangesTest class Drupal\Tests\migrate\Kernel core/modules/migrate/tests/src/Kernel/TrackChangesTest.php Tests migration track changes property.
TrackChangesTest class Drupal\migrate_track_changes_test\Plugin\migrate\source core/modules/migrate/tests/modules/migrate_track_changes_test/src/Plugin/migrate/source/TrackChangesTest.php Source plugin for migration track changes tests.
TraitAccessTest class Drupal\Tests\system\Unit core/modules/system/tests/src/Unit/TraitAccessTest.php Test whether traits are autoloaded during PHPUnit discovery time.
Transaction class Drupal\core_fake\Driver\Database\CoreFakeWithAllCustomClasses core/tests/fixtures/database_drivers/module/core_fake/src/Driver/Database/CoreFakeWithAllCustomClasses/Transaction.php CoreFakeWithAllCustomClasses implementation of \Drupal\Core\Database\Transaction.
Transaction class Drupal\Core\Database core/lib/Drupal/Core/Database/Transaction.php A wrapper class for creating and managing database transactions. 1 6
TransactionCommitFailedException class Drupal\Core\Database core/lib/Drupal/Core/Database/TransactionCommitFailedException.php Exception thrown when a commit() function fails. 1
TransactionException class Drupal\Core\Database core/lib/Drupal/Core/Database/TransactionException.php Exception thrown by an error in a database transaction. 5
TransactionExplicitCommitNotAllowedException class Drupal\Core\Database core/lib/Drupal/Core/Database/TransactionExplicitCommitNotAllowedException.php Exception to deny attempts to explicitly manage transactions.
TransactionManager class Drupal\mysql\Driver\Database\mysql core/modules/mysql/src/Driver/Database/mysql/TransactionManager.php MySql implementation of TransactionManagerInterface.
TransactionManager class Drupal\sqlite\Driver\Database\sqlite core/modules/sqlite/src/Driver/Database/sqlite/TransactionManager.php SQLite implementation of TransactionManagerInterface.
TransactionManager class Drupal\mysqli\Driver\Database\mysqli core/modules/mysqli/src/Driver/Database/mysqli/TransactionManager.php MySqli implementation of TransactionManagerInterface.
TransactionManager class Drupal\pgsql\Driver\Database\pgsql core/modules/pgsql/src/Driver/Database/pgsql/TransactionManager.php PostgreSql implementation of TransactionManagerInterface.
TransactionManagerBase abstract class Drupal\Core\Database\Transaction core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php The database transaction manager base class. 4 6
TransactionManagerInterface interface Drupal\Core\Database\Transaction core/lib/Drupal/Core/Database/Transaction/TransactionManagerInterface.php Interface for the database transaction manager classes. 1 5
TransactionNameNonUniqueException class Drupal\Core\Database core/lib/Drupal/Core/Database/TransactionNameNonUniqueException.php Exception thrown when a savepoint or transaction name occurs twice. 3
TransactionNoActiveException class Drupal\Core\Database core/lib/Drupal/Core/Database/TransactionNoActiveException.php Exception for when popTransaction() is called with no active transaction.
TransactionOutOfOrderException class Drupal\Core\Database core/lib/Drupal/Core/Database/TransactionOutOfOrderException.php Exception thrown transactions are out of order. 4
TransactionTest class Drupal\Tests\pgsql\Kernel\pgsql core/modules/pgsql/tests/src/Kernel/pgsql/TransactionTest.php Tests transaction for the PostgreSQL driver.
TransactionTest class Drupal\Tests\mysqli\Kernel\mysqli core/modules/mysqli/tests/src/Kernel/mysqli/TransactionTest.php Tests transaction for the MySQLi driver.
TransactionTest class Drupal\KernelTests\Core\Database core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php Tests the transactions, using the explicit ::commitOrRelease method.
TransactionTest class Drupal\Tests\sqlite\Kernel\sqlite core/modules/sqlite/tests/src/Kernel/sqlite/TransactionTest.php Tests transaction for the SQLite driver.
TransactionTest class Drupal\Tests\mysql\Kernel\mysql core/modules/mysql/tests/src/Kernel/mysql/TransactionTest.php Tests transaction for the MySQL driver.
TransformedConfigExportImportUITest class Drupal\Tests\config\Functional core/modules/config/tests/src/Functional/TransformedConfigExportImportUITest.php Tests the user interface for importing/exporting transformed configuration.
Transition class Drupal\workflows core/modules/workflows/src/Transition.php A transition value object that describes the transition between states. 5
TransitionInterface interface Drupal\workflows core/modules/workflows/src/TransitionInterface.php A transition value object that describes the transition between two states. 1 3
TransitionTest class Drupal\Tests\workflows\Unit core/modules/workflows/tests/src/Unit/TransitionTest.php Tests Drupal\workflows\Transition.
TranslatableFieldTest class Drupal\Tests\layout_builder\Kernel core/modules/layout_builder/tests/src/Kernel/TranslatableFieldTest.php Tests Layout Builder with a translatable layout field.
TranslatableInterface interface Drupal\Core\TypedData core/lib/Drupal/Core/TypedData/TranslatableInterface.php Interface for translatable data. 1 13
TranslatableInterface interface Drupal\Core\Entity core/lib/Drupal/Core/Entity/TranslatableInterface.php Provides methods for an entity to support translation. 1 5

Other projects


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