Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/donquixote/drupal-entity2
Inspiration for the future of the Entity API module.
https://github.com/donquixote/drupal-entity2
Last synced: 7 days ago
JSON representation
Inspiration for the future of the Entity API module.
- Host: GitHub
- URL: https://github.com/donquixote/drupal-entity2
- Owner: donquixote
- Created: 2014-02-02T22:27:20.000Z (almost 11 years ago)
- Default Branch: 7.x-1.x
- Last Pushed: 2014-12-20T12:08:02.000Z (almost 10 years ago)
- Last Synced: 2023-03-10T21:12:59.513Z (over 1 year ago)
- Language: PHP
- Size: 191 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Entity2
==============Alternative to the EntityMetatadaWrapper API of the well-known [entity module](https://drupal.org/project/entity) for Drupal 7.
Unlike entity module, entity2 has very explicit interfaces and method signatures. This is generally more robust, and makes it look nice in an IDE such as PhpStorm.
E.g. the original entity module had methods like ->get() and ->value(), where the return value was very hard to predict. E.g. the value() method could return an id, an entity, a string value, etc, depending on the object or the field type.
With entity2, you need to explicitly call getFieldItems(), getFieldItem(), getFieldValue() etc, which all have clearly defined return types.
## Usage
For usage examples, you should look into the tests/src directory.## PHPUnit
To run PHPUnit tests, simply run `composer install` and then `phpunit`, in the module directory. The Drupal environment is totally mocked out.## Status / To do
The module is not finished.
* We want more useful methods like `->getReferencedEntities($fieldName)`. On the other hand, the implementations of stuff like this should ideally live in separate classes.
* We want to make better use of the info in `hook_property_info()` from entity module.
* Support for properties that behave like entity references. E.g. `$nodeWrapper->getReferencedEntity('author')`.
* Improve language handling. E.g. set a language for the entity wrapper, instead of passing it as an argument to each field method.