原文地址: https://www.drupal.org/node/2207559
原文版本: August 25, 2014.
Entity types, both configuration and content entity are defined using annotation in the entity class.
The Example entity is defined in Drupal\example\Entity\Example.php
(assumes the module name is "example"):
原文地址: https://www.drupal.org/node/2143497
原文版本: November 25, 2013.
(原文未成)
* Final name not yet defined, see #1976158: Rename entity storage/list/form/render "controllers" to handlers
While entities represent a piece of data, controllers are responsible for acting on and with them. The basic concept was introduced in Drupal 7, where the controller provided the API to load entities. That class was then extended in the entity.module to provide full CRUD support and other types of controllers were created.
原文地址: https://www.drupal.org/node/2143503
原文版本: June 26, 2014.
(原文未成)
(Stub)
Content entities examples
- node
- comment
- user
- 阅读更多 关于 内容型实体 (翻译中)
- 登录或注册以发表评论
原文地址: https://www.drupal.org/node/2143501
原文版本: May 9, 2014.
Configuration entities using the new entity API in Drupal 8 in order to keep configuration into the DB. The difference between the config entities to content entites:
- Configurable entity can be exported using the new CMI system.
- Configurable entity don't have field due to the way they stored in the DB
- Configurable entity defined a schema file unlike content entities which defined by hook_schema()
- 阅读更多 关于 配置型实体 (翻译中)
- 登录或注册以发表评论
原文地址: https://www.drupal.org/node/2143499
原文未成
- 阅读更多 关于 梱束 (翻译中)
- 登录或注册以发表评论
原文地址: https://www.drupal.org/node/2124403
原文版本: May 28, 2014.
This covers the generic entity API, configuration entity and content entity specific API's will be covered in specific chapters. TODO: Link once created.
Check
原文链接:https://www.drupal.org/node/2203931
依赖于Drupal服务或者自定义服务的表单应该通过依赖注入来访问该服务。
如一个表单(与Form API in Drupal 8 中的类似)使用'current_user'服务来获取当前用户的uid。假设模块名的modules/example,那么文件 /modules/example/lib/Drupal/example/Form/ExampleForm.php 内容:
- 阅读更多 关于 在表单上应用依赖注入
- 登录或注册以发表评论
原文地址:https://www.drupal.org/node/2026959
服务容器具有多个优点,因为每个服务都可以通过一个字符串键来访问/实例化,并且拥有一个已定义的接口,它可以用其他实现来替换。如果需要修改一个已有的服务,只需要实现一个ServiceProviderBase的子类并且编写alter()方法。
如:在my_module中定义my_module/src/MyModuleServiceProvider.php