跳转到主要内容
rat 提交于 24 September 2014

原文地址: 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.

rat 提交于 24 September 2014

原文地址: 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:

  1. Configurable entity can be exported using the new CMI system.
  2. Configurable entity don't have field due to the way they stored in the DB
  3. Configurable entity defined a schema file unlike content entities which defined by hook_schema()
yplam 提交于 24 September 2014

原文链接: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 内容:

yplam 提交于 24 September 2014

原文地址:https://www.drupal.org/node/2026959

服务容器具有多个优点,因为每个服务都可以通过一个字符串键来访问/实例化,并且拥有一个已定义的接口,它可以用其他实现来替换。如果需要修改一个已有的服务,只需要实现一个ServiceProviderBase的子类并且编写alter()方法。

如:在my_module中定义my_module/src/MyModuleServiceProvider.php

订阅