EntityTypeInterface.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  1. <?php
  2. namespace Drupal\Core\Entity;
  3. use Drupal\Component\Plugin\Definition\PluginDefinitionInterface;
  4. /**
  5. * Provides an interface for an entity type and its metadata.
  6. *
  7. * Entity type classes can provide docblock annotations. The entity type manager
  8. * will use these annotations to populate the entity type object with
  9. * properties.
  10. *
  11. * Additional properties can be defined by module implementations of
  12. * hook_entity_type_build(). Existing data can be altered in implementations of
  13. * hook_entity_type_alter(), which can also be used to fill in defaults.
  14. * Module-specific properties should be documented in the hook implementations
  15. * defining them.
  16. *
  17. * @see \Drupal\Core\Entity\EntityTypeManagerInterface
  18. * @see hook_entity_type_build()
  19. * @see hook_entity_type_alter()
  20. */
  21. interface EntityTypeInterface extends PluginDefinitionInterface {
  22. /**
  23. * The maximum length of ID, in characters.
  24. */
  25. const ID_MAX_LENGTH = 32;
  26. /**
  27. * The maximum length of bundle name, in characters.
  28. */
  29. const BUNDLE_MAX_LENGTH = 32;
  30. /**
  31. * Gets any arbitrary property.
  32. *
  33. * @param string $property
  34. * The property to retrieve.
  35. *
  36. * @return mixed
  37. * The value for that property, or NULL if the property does not exist.
  38. */
  39. public function get($property);
  40. /**
  41. * Sets a value to an arbitrary property.
  42. *
  43. * @param string $property
  44. * The property to use for the value.
  45. * @param mixed $value
  46. * The value to set.
  47. *
  48. * @return $this
  49. */
  50. public function set($property, $value);
  51. /**
  52. * Gets the name of the original entity type class.
  53. *
  54. * In case the class name was changed with setClass(), this will return
  55. * the initial value. Useful when trying to identify the entity type ID based
  56. * on the class.
  57. *
  58. * @return string
  59. * The name of the original entity type class.
  60. */
  61. public function getOriginalClass();
  62. /**
  63. * Gets an array of entity keys.
  64. *
  65. * @return array
  66. * An array describing how the Field API can extract certain information
  67. * from objects of this entity type:
  68. * - id: The name of the property that contains the primary ID of the
  69. * entity. Every entity object passed to the Field API must have this
  70. * property and its value must be numeric.
  71. * - revision: (optional) The name of the property that contains the
  72. * revision ID of the entity. The Field API assumes that all revision IDs
  73. * are unique across all entities of a type. If this entry is omitted
  74. * the entities of this type are not revisionable.
  75. * - bundle: (optional) The name of the property that contains the bundle
  76. * name for the entity. The bundle name defines which set of fields are
  77. * attached to the entity (e.g. what nodes call "content type"). This
  78. * entry can be omitted if this entity type exposes a single bundle (such
  79. * that all entities have the same collection of fields). The name of this
  80. * single bundle will be the same as the entity type.
  81. * - label: (optional) The name of the property that contains the entity
  82. * label. For example, if the entity's label is located in
  83. * $entity->subject, then 'subject' should be specified here. If complex
  84. * logic is required to build the label,
  85. * \Drupal\Core\Entity\EntityInterface::label() should be used.
  86. * - langcode: (optional) The name of the property that contains the
  87. * language code. For instance, if the entity's language is located in
  88. * $entity->langcode, then 'langcode' should be specified here.
  89. * - uuid: (optional) The name of the property that contains the universally
  90. * unique identifier of the entity, which is used to distinctly identify
  91. * an entity across different systems.
  92. */
  93. public function getKeys();
  94. /**
  95. * Gets a specific entity key.
  96. *
  97. * @param string $key
  98. * The name of the entity key to return.
  99. *
  100. * @return string|bool
  101. * The entity key, or FALSE if it does not exist.
  102. *
  103. * @see self::getKeys()
  104. */
  105. public function getKey($key);
  106. /**
  107. * Indicates if a given entity key exists.
  108. *
  109. * @param string $key
  110. * The name of the entity key to check.
  111. *
  112. * @return bool
  113. * TRUE if a given entity key exists, FALSE otherwise.
  114. */
  115. public function hasKey($key);
  116. /**
  117. * Indicates whether entities should be statically cached.
  118. *
  119. * @return bool
  120. * TRUE if static caching should be used; FALSE otherwise.
  121. */
  122. public function isStaticallyCacheable();
  123. /**
  124. * Indicates whether the rendered output of entities should be cached.
  125. *
  126. * @return bool
  127. */
  128. public function isRenderCacheable();
  129. /**
  130. * Indicates if the persistent cache of field data should be used.
  131. *
  132. * @todo Used by ContentEntityStorageBase only.
  133. *
  134. * The persistent cache should usually only be disabled if a higher level
  135. * persistent cache is available for the entity type.
  136. *
  137. * @return bool
  138. */
  139. public function isPersistentlyCacheable();
  140. /**
  141. * Determines if there is a handler for a given type.
  142. *
  143. * @param string $handler_type
  144. * The type of handler to check.
  145. * @param bool $nested
  146. * (optional) If this handler has a nested definition. Defaults to FALSE.
  147. *
  148. * @return bool
  149. * TRUE if a handler of this type exists, FALSE otherwise.
  150. */
  151. public function hasHandlerClass($handler_type, $nested = FALSE);
  152. /**
  153. * @param string $handler_type
  154. * The handler type to get.
  155. *
  156. * @return array|string|null
  157. * The handlers for a given type, or NULL if none exist.
  158. */
  159. public function getHandlerClass($handler_type);
  160. /**
  161. * Gets an array of handlers.
  162. *
  163. * @return array
  164. * An associative array where the keys are the names of different handler
  165. * types (listed below) and the values are the names of the classes that
  166. * implement that handler:
  167. * - storage: The name of the class used to load the objects. The class must
  168. * implement \Drupal\Core\Entity\EntityStorageInterface.
  169. * - form: An associative array where the keys are the names of the
  170. * different form operations (such as 'create', 'edit', or 'delete') and
  171. * the values are the names of the handler classes for those
  172. * operations. The name of the operation is passed also to the form
  173. * handler's constructor, so that one class can be used for multiple
  174. * entity forms when the forms are similar. The classes must implement
  175. * \Drupal\Core\Entity\EntityFormInterface.
  176. * - list: The name of the class that provides listings of the entities. The
  177. * class must implement \Drupal\Core\Entity\EntityListBuilderInterface.
  178. * - render: The name of the class that is used to render the entities. The
  179. * class must implement \Drupal\Core\Entity\EntityViewBuilderInterface.
  180. * - access: The name of the class that is used for access checks. The class
  181. * must implement \Drupal\Core\Entity\EntityAccessControlHandlerInterface.
  182. * Defaults to \Drupal\Core\Entity\EntityAccessControlHandler.
  183. * - route_provider: (optional) A list of class names, keyed by a group
  184. * string, which will be used to define routes related to this entity
  185. * type. These classes must implement
  186. * \Drupal\Core\Entity\Routing\EntityRouteProviderInterface.
  187. */
  188. public function getHandlerClasses();
  189. /**
  190. * Gets the storage class.
  191. *
  192. * @return string
  193. * The class for this entity type's storage.
  194. */
  195. public function getStorageClass();
  196. /**
  197. * Sets the storage class.
  198. *
  199. * @param string $class
  200. * The class for this entity type's storage.
  201. *
  202. * @return $this
  203. */
  204. public function setStorageClass($class);
  205. /**
  206. * Gets the form class for a specific operation.
  207. *
  208. * @param string $operation
  209. * The name of the operation to use, e.g., 'default'.
  210. *
  211. * @return string
  212. * The class for this operation's form for this entity type.
  213. *
  214. * @see \Drupal\Core\Entity\EntityFormBuilderInterface
  215. */
  216. public function getFormClass($operation);
  217. /**
  218. * Sets a form class for a specific operation.
  219. *
  220. * @param string $operation
  221. * The operation to use this form class for.
  222. * @param string $class
  223. * The form class implementing
  224. * \Drupal\Core\Entity\EntityFormInterface.
  225. *
  226. * @return $this
  227. *
  228. * @see \Drupal\Core\Entity\EntityFormBuilderInterface
  229. */
  230. public function setFormClass($operation, $class);
  231. /**
  232. * Indicates if this entity type has any forms.
  233. *
  234. * @return bool
  235. * TRUE if there are any forms for this entity type, FALSE otherwise.
  236. */
  237. public function hasFormClasses();
  238. /**
  239. * Indicates if this entity type has any route provider.
  240. *
  241. * @return bool
  242. */
  243. public function hasRouteProviders();
  244. /**
  245. * Gets all the route provide handlers.
  246. *
  247. * Much like forms you can define multiple route provider handlers.
  248. *
  249. * @return string[]
  250. */
  251. public function getRouteProviderClasses();
  252. /**
  253. * Gets the list class.
  254. *
  255. * @return string
  256. * The class for this entity type's list.
  257. */
  258. public function getListBuilderClass();
  259. /**
  260. * Sets the list class.
  261. *
  262. * @param string $class
  263. * The list class to use for the operation.
  264. *
  265. * @return $this
  266. */
  267. public function setListBuilderClass($class);
  268. /**
  269. * Indicates if this entity type has a list class.
  270. *
  271. * @return bool
  272. * TRUE if there is a list for this entity type, FALSE otherwise.
  273. */
  274. public function hasListBuilderClass();
  275. /**
  276. * Gets the view builder class.
  277. *
  278. * @return string
  279. * The class for this entity type's view builder.
  280. */
  281. public function getViewBuilderClass();
  282. /**
  283. * Gets the view builder class.
  284. *
  285. * @param string $class
  286. * The class for this entity type's view builder.
  287. *
  288. * @return $this
  289. */
  290. public function setViewBuilderClass($class);
  291. /**
  292. * Indicates if this entity type has a view builder.
  293. *
  294. * @return bool
  295. * TRUE if there is a view builder for this entity type, FALSE otherwise.
  296. */
  297. public function hasViewBuilderClass();
  298. /**
  299. * Gets the access control class.
  300. *
  301. * @return string
  302. * The class for this entity type's access control.
  303. */
  304. public function getAccessControlClass();
  305. /**
  306. * Sets the access control handler class.
  307. *
  308. * @param string $class
  309. * The class for this entity type's access control handler.
  310. *
  311. * @return $this
  312. */
  313. public function setAccessClass($class);
  314. /**
  315. * Indicates if the entity type class implements the given interface.
  316. *
  317. * @param string $interface
  318. * The class or interface to check.
  319. *
  320. * @return bool
  321. * TRUE if the entity type class implements the given interface.
  322. */
  323. public function entityClassImplements($interface);
  324. /**
  325. * Indicates if the entity type is a subclass of the given class or interface.
  326. *
  327. * @param string $class
  328. * The class or interface to check.
  329. *
  330. * @return bool
  331. * TRUE if the entity type is a subclass of the class or interface.
  332. *
  333. * @deprecated in Drupal 8.3.0 and will be removed before Drupal 9.0.0.
  334. * Use Drupal\Core\Entity\EntityTypeInterface::entityClassImplements()
  335. * instead.
  336. */
  337. public function isSubclassOf($class);
  338. /**
  339. * Sets the handlers for a given type.
  340. *
  341. * @param string $handler_type
  342. * The type of handler to set.
  343. * @param array|string $value
  344. * The value for a handler type.
  345. *
  346. * @return $this
  347. */
  348. public function setHandlerClass($handler_type, $value);
  349. /**
  350. * Gets the name of the default administrative permission.
  351. *
  352. * The default \Drupal\Core\Entity\EntityAccessControlHandler class checks this
  353. * permission for all operations in its checkAccess() method. Entities with
  354. * more complex permissions can extend this class to do their own access
  355. * checks.
  356. *
  357. * @return string|bool
  358. */
  359. public function getAdminPermission();
  360. /**
  361. * Gets the permission granularity level.
  362. *
  363. * The allowed values are respectively "entity_type" or "bundle".
  364. *
  365. * @return string
  366. * Whether a module exposing permissions for the current entity type
  367. * should use entity-type level granularity or bundle level granularity.
  368. */
  369. public function getPermissionGranularity();
  370. /**
  371. * Gets the link templates using the URI template syntax.
  372. *
  373. * Links are an array of standard link relations to the URI template that
  374. * should be used for them. Where possible, link relationships should use
  375. * established IANA relationships rather than custom relationships.
  376. *
  377. * Every entity type should, at minimum, define "canonical", which is the
  378. * pattern for URIs to that entity. Even if the entity will have no HTML page
  379. * exposed to users it should still have a canonical URI in order to be
  380. * compatible with web services. Entities that will be user-editable via an
  381. * HTML page must also define an "edit-form" relationship.
  382. *
  383. * By default, the following placeholders are supported:
  384. * - [entityType]: The entity type itself will also be a valid token for the
  385. * ID of the entity. For instance, a placeholder of {node} used on the Node
  386. * class.
  387. * - [bundleEntityType]: The bundle machine name itself. For instance, a
  388. * placeholder of {node_type} used on the Node class.
  389. *
  390. * Specific entity types may also expand upon this list by overriding the
  391. * Entity::urlRouteParameters() method.
  392. *
  393. * @link http://www.iana.org/assignments/link-relations/link-relations.xml @endlink
  394. * @link http://tools.ietf.org/html/rfc6570 @endlink
  395. *
  396. * @return array
  397. */
  398. public function getLinkTemplates();
  399. /**
  400. * Gets the link template for a given key.
  401. *
  402. * @param string $key
  403. * The link type.
  404. *
  405. * @return string|bool
  406. * The path for this link, or FALSE if it doesn't exist.
  407. */
  408. public function getLinkTemplate($key);
  409. /**
  410. * Indicates if a link template exists for a given key.
  411. *
  412. * @param string $key
  413. * The link type.
  414. *
  415. * @return bool
  416. * TRUE if the link template exists, FALSE otherwise.
  417. */
  418. public function hasLinkTemplate($key);
  419. /**
  420. * Sets a single link template.
  421. *
  422. * @param string $key
  423. * The name of a link.
  424. * @param string $path
  425. * The route path to use for the link.
  426. *
  427. * @return $this
  428. *
  429. * @throws \InvalidArgumentException
  430. * Thrown when the path does not start with a leading slash.
  431. */
  432. public function setLinkTemplate($key, $path);
  433. /**
  434. * Gets the callback for the label of the entity.
  435. *
  436. * The function takes an entity and returns the label of the entity. Use
  437. * language() on the entity to get information on the requested language. The
  438. * entity label is the main string associated with an entity; for example, the
  439. * title of a node or the subject of a comment. If there is an entity object
  440. * property that defines the label, use the 'label' element of the
  441. * 'entity_keys' return value component to provide this information. If more
  442. * complex logic is needed to determine the label of an entity, you can
  443. * instead specify a callback function here, which will be called to determine
  444. * the entity label.
  445. *
  446. * @return callable|null
  447. * The callback, or NULL if none exists.
  448. *
  449. * @deprecated in Drupal 8.0.x-dev and will be removed before Drupal 9.0.0.
  450. * Use Drupal\Core\Entity\EntityInterface::label() for complex label
  451. * generation as needed.
  452. *
  453. * @see \Drupal\Core\Entity\EntityInterface::label()
  454. * @see \Drupal\Core\Entity\EntityTypeInterface::setLabelCallback()
  455. * @see \Drupal\Core\Entity\EntityTypeInterface::hasLabelCallback()
  456. *
  457. * @todo Remove usages of label_callback https://www.drupal.org/node/2450793.
  458. */
  459. public function getLabelCallback();
  460. /**
  461. * Sets the label callback.
  462. *
  463. * @param callable $callback
  464. * A callable that returns the label of the entity.
  465. *
  466. * @return $this
  467. *
  468. * @deprecated in Drupal 8.0.x-dev and will be removed before Drupal 9.0.0.
  469. * Use EntityInterface::label() for complex label generation as needed.
  470. *
  471. * @see \Drupal\Core\Entity\EntityInterface::label()
  472. * @see \Drupal\Core\Entity\EntityTypeInterface::getLabelCallback()
  473. * @see \Drupal\Core\Entity\EntityTypeInterface::hasLabelCallback()
  474. */
  475. public function setLabelCallback($callback);
  476. /**
  477. * Indicates if a label callback exists.
  478. *
  479. * @return bool
  480. *
  481. * @deprecated in Drupal 8.0.x-dev and will be removed before Drupal 9.0.0.
  482. * Use EntityInterface::label() for complex label generation as needed.
  483. *
  484. * @see \Drupal\Core\Entity\EntityInterface::label()
  485. * @see \Drupal\Core\Entity\EntityTypeInterface::getLabelCallback()
  486. * @see \Drupal\Core\Entity\EntityTypeInterface::setLabelCallback()
  487. */
  488. public function hasLabelCallback();
  489. /**
  490. * Gets the name of the entity type which provides bundles.
  491. *
  492. * @return string|null
  493. * The name of the entity type which provides bundles, or NULL if the entity
  494. * type does not have a bundle entity type.
  495. */
  496. public function getBundleEntityType();
  497. /**
  498. * Gets the entity type for which this entity provides bundles.
  499. *
  500. * It can be used by other modules to act accordingly; for example,
  501. * the Field UI module uses it to add operation links to manage fields and
  502. * displays.
  503. *
  504. * @return string|null
  505. * The entity type for which this entity provides bundles, or NULL if does
  506. * not provide bundles for another entity type.
  507. */
  508. public function getBundleOf();
  509. /**
  510. * Gets the label for the bundle.
  511. *
  512. * @return string
  513. * The bundle label.
  514. */
  515. public function getBundleLabel();
  516. /**
  517. * Gets the name of the entity's base table.
  518. *
  519. * @todo Used by SqlContentEntityStorage only.
  520. *
  521. * @return string|null
  522. * The name of the entity's base table, or NULL if none exists.
  523. */
  524. public function getBaseTable();
  525. /**
  526. * Indicates whether the entity data is internal.
  527. *
  528. * This can be used in a scenario when it is not desirable to expose data of
  529. * this entity type to an external system.
  530. *
  531. * The implications of this method are left to the discretion of the caller.
  532. * For example, a module providing an HTTP API may not expose entities of
  533. * this type or a custom entity reference field settings form may deprioritize
  534. * entities of this type in a select list.
  535. *
  536. * @return bool
  537. * TRUE if the entity data is internal, FALSE otherwise.
  538. *
  539. * @see \Drupal\Core\TypedData\DataDefinitionInterface::isInternal()
  540. */
  541. public function isInternal();
  542. /**
  543. * Indicates whether entities of this type have multilingual support.
  544. *
  545. * At an entity level, this indicates language support and at a bundle level
  546. * this indicates translation support.
  547. *
  548. * @return bool
  549. */
  550. public function isTranslatable();
  551. /**
  552. * Indicates whether the revision form fields should be added to the form.
  553. *
  554. * @return bool
  555. * TRUE if the form field should be added, FALSE otherwise.
  556. */
  557. public function showRevisionUi();
  558. /**
  559. * Indicates whether entities of this type have revision support.
  560. *
  561. * @return bool
  562. */
  563. public function isRevisionable();
  564. /**
  565. * Gets the name of the entity's revision data table.
  566. *
  567. * @todo Used by SqlContentEntityStorage only.
  568. *
  569. * @return string|null
  570. * The name of the entity type's revision data table, or NULL if none
  571. * exists.
  572. */
  573. public function getRevisionDataTable();
  574. /**
  575. * Gets the name of the entity's revision table.
  576. *
  577. * @todo Used by SqlContentEntityStorage only.
  578. *
  579. * @return string|null
  580. * The name of the entity type's revision table, or NULL if none exists.
  581. */
  582. public function getRevisionTable();
  583. /**
  584. * Gets the name of the entity's data table.
  585. *
  586. * @todo Used by SqlContentEntityStorage only.
  587. *
  588. * @return string|null
  589. * The name of the entity type's data table, or NULL if none exists.
  590. */
  591. public function getDataTable();
  592. /**
  593. * Gets the human-readable name of the entity type.
  594. *
  595. * This label should be used to present a human-readable name of the
  596. * entity type.
  597. *
  598. * @return string
  599. * The human-readable name of the entity type.
  600. */
  601. public function getLabel();
  602. /**
  603. * Gets the lowercase form of the human-readable entity type name.
  604. *
  605. * @return string
  606. * The lowercase form of the human-readable entity type name.
  607. *
  608. * @see \Drupal\Core\Entity\EntityTypeInterface::getLabel()
  609. */
  610. public function getLowercaseLabel();
  611. /**
  612. * Gets the uppercase plural form of the name of the entity type.
  613. *
  614. * This should return a human-readable version of the name that can refer
  615. * to all the entities of the given type, collectively. An example usage of
  616. * this is the page title of a page devoted to a collection of entities such
  617. * as "Workflows" (instead of "Workflow entities").
  618. *
  619. * @return string
  620. * The collection label.
  621. */
  622. public function getCollectionLabel();
  623. /**
  624. * Gets the indefinite singular form of the name of the entity type.
  625. *
  626. * This should return the human-readable name for a single instance of
  627. * the entity type. For example: "opportunity" (with the plural as
  628. * "opportunities"), "child" (with the plural as "children"), or "content
  629. * item" (with the plural as "content items").
  630. *
  631. * @return string
  632. * The singular label.
  633. */
  634. public function getSingularLabel();
  635. /**
  636. * Gets the indefinite plural form of the name of the entity type.
  637. *
  638. * This should return the human-readable name for more than one instance of
  639. * the entity type. For example: "opportunities" (with the singular as
  640. * "opportunity"), "children" (with the singular as "child"), or "content
  641. * items" (with the singular as "content item").
  642. *
  643. * @return string
  644. * The plural label.
  645. */
  646. public function getPluralLabel();
  647. /**
  648. * Gets the label's definite article form for use with a count of entities.
  649. *
  650. * This label should be used when the quantity of entities is provided. The
  651. * name should be returned in a form usable with a count of the
  652. * entities. For example: "1 opportunity", "5 opportunities", "1 child",
  653. * "6 children", "1 content item", "25 content items".
  654. *
  655. * @param int $count
  656. * The item count to display if the plural form was requested.
  657. *
  658. * @return string
  659. * The count label.
  660. */
  661. public function getCountLabel($count);
  662. /**
  663. * Gets a callable that can be used to provide the entity URI.
  664. *
  665. * This is only called if there is no matching link template for the link
  666. * relationship type, and there is no bundle-specific callback provided.
  667. *
  668. * @return callable|null
  669. * A valid callback that is passed the entity or NULL if none is specified.
  670. */
  671. public function getUriCallback();
  672. /**
  673. * Sets a callable to use to provide the entity URI.
  674. *
  675. * @param callable $callback
  676. * A callback to use to provide a URI for the entity.
  677. *
  678. * @return $this
  679. */
  680. public function setUriCallback($callback);
  681. /**
  682. * Gets the machine name of the entity type group.
  683. *
  684. * @return string
  685. */
  686. public function getGroup();
  687. /**
  688. * Gets the human-readable name of the entity type group.
  689. *
  690. * @return string
  691. */
  692. public function getGroupLabel();
  693. /**
  694. * The list cache contexts associated with this entity type.
  695. *
  696. * Enables code listing entities of this type to ensure that rendered listings
  697. * are varied as necessary, typically to ensure users of role A see other
  698. * entities listed than users of role B.
  699. *
  700. * @return string[]
  701. */
  702. public function getListCacheContexts();
  703. /**
  704. * The list cache tags associated with this entity type.
  705. *
  706. * Enables code listing entities of this type to ensure that newly created
  707. * entities show up immediately.
  708. *
  709. * @return string[]
  710. */
  711. public function getListCacheTags();
  712. /**
  713. * Gets the key that is used to store configuration dependencies.
  714. *
  715. * @return string
  716. * The key to be used in configuration dependencies when storing
  717. * dependencies on entities of this type.
  718. */
  719. public function getConfigDependencyKey();
  720. /**
  721. * Indicates whether this entity type is commonly used as a reference target.
  722. *
  723. * @return bool
  724. * TRUE if the entity type is a common reference; FALSE otherwise.
  725. */
  726. public function isCommonReferenceTarget();
  727. /**
  728. * Gets an array of validation constraints.
  729. *
  730. * See \Drupal\Core\TypedData\DataDefinitionInterface::getConstraints() for
  731. * details on how constraints are defined.
  732. *
  733. * @return array[]
  734. * An array of validation constraint definitions, keyed by constraint name.
  735. * Each constraint definition can be used for instantiating
  736. * \Symfony\Component\Validator\Constraint objects.
  737. *
  738. * @see \Symfony\Component\Validator\Constraint
  739. */
  740. public function getConstraints();
  741. /**
  742. * Sets the array of validation constraints for the FieldItemList.
  743. *
  744. * NOTE: This will overwrite any previously set constraints. In most cases
  745. * ContentEntityTypeInterface::addConstraint() should be used instead.
  746. * See \Drupal\Core\TypedData\DataDefinitionInterface::getConstraints() for
  747. * details on how constraints are defined.
  748. *
  749. * @param array $constraints
  750. * An array of validation constraint definitions, keyed by constraint name.
  751. * Each constraint definition can be used for instantiating
  752. * \Symfony\Component\Validator\Constraint objects.
  753. *
  754. * @return $this
  755. *
  756. * @see \Symfony\Component\Validator\Constraint
  757. */
  758. public function setConstraints(array $constraints);
  759. /**
  760. * Adds a validation constraint.
  761. *
  762. * See \Drupal\Core\TypedData\DataDefinitionInterface::getConstraints() for
  763. * details on how constraints are defined.
  764. *
  765. * @param string $constraint_name
  766. * The name of the constraint to add, i.e. its plugin id.
  767. * @param array|null $options
  768. * The constraint options as required by the constraint plugin, or NULL.
  769. *
  770. * @return $this
  771. */
  772. public function addConstraint($constraint_name, $options = NULL);
  773. /**
  774. * Gets the config dependency info for this entity, if any exists.
  775. *
  776. * @param string $bundle
  777. * The bundle name.
  778. *
  779. * @return array
  780. * An associative array containing the following keys:
  781. * - 'type': The config dependency type (e.g. 'module', 'config').
  782. * - 'name': The name of the config dependency.
  783. */
  784. public function getBundleConfigDependency($bundle);
  785. }