kanshin/CakeEntity — pull request #8 by josegonzalez (2013-12-26 09:27:21+00:00)
Title: 3 0 compatibility

This pull request implements partial compatibility with the CakePHP 3.0 Entity specification.

- Entity classes now are not wholly tied to the Model class, and have no reference to them
- `Model` class is now treated as the `Table` class. Subsequently, missing `Table` methods have been added, where appropriate
- Removal of helper methods - such as `save` and `updateAll` - from the Entity classes. This is because they belong in the Table class (which implements a sort of session) not in the Entity class.
- Added the notion of `allowed` methods. This follows the `isAllowed` feature of CakeEntity from the 1.x series. This might be removed as it adds complexity and is not implemented in CakePHP 3.0.
- Entity class is now `JsonSerializable`. Woot
- `entity->toArray()` returns a nested data structure, as opposed to top-level as in 3.x. For example, 3.x has `['name' => 'Jose', 'email' => 'mark@example.com']`, whereas CakeEntity will have `['User' => ['name' => 'Jose', 'email' => 'mark@example.com']]`. This is to deal with data saving - we will leave the 2.x saving largely untouched so that the entities can be easily used in the FormHelpers for instance.
- PHP 5.4+ required.

Todo:

- [ ] Write tests for data saving
- [ ] Implement `EntityModel::alias()`
- [ ] Implement `EntityModel::connection()`
- [ ] Implement `EntityModel::association()`
- [ ] Implement `EntityModel::associations()`
- [ ] Implement `Entity::validate()`