Generic Field API for PHP7. This library handles only the metadata about entities and fields related to them.
I'll keep this todo list on top until the library is usable.
- Validate and force field data structure. Now they are just arrays of anything. (IN PROGRESS)
- In that structure, try to separate general, form and display related data.
- Implementation example (own repo) e.g. application which uses fields api, mongodb storage and zf2 classes
Create API and set storage:
$api = new \BackTo95\Fields\Api();
$storage = new \BackTo95\Fields\Storage\FileStorage('data/entities');
$api->setStorage($storage);
Create EntityConfiguration with fields:
$track_configuration = new \BackTo95\Fields\Entity\EntityConfiguration([
'name' => 'track',
'description' => 'Track represents musical track made with tracker software',
'fields' => [
'title' => [...],
'description' => [...],
],
]);
Store the created EntityConfiguration:
$api->storeEntityConfiguration($track_configuration);
Get stored EntityConfiguration by name:
$api->getEntityConfiguration('track');
Example entity: track (as in music)
[
'name' => 'track',
'description' => 'Track represents musical track made with tracker software',
'fields' => [
'artist' => [
'name' => 'artist',
'form' => [
'widget' => 'text',
'filters' => ['trim'],
],
'required' => 1,
],
'title' => [
'name' => 'title',
'form' => [
'widget' => 'text',
],
'required' => 1,
],
'description' => [
'name' => 'description',
'form' => [
'widget' => 'editor',
],
],
'cover' => [
'name' => 'cover',
'form' => [
'widget' => 'image',
],
],
'genre' => [
'name' => 'genre',
'form' => [
'widget' => 'tags',
'validators' => [
'min' => 1
],
],
'multivalue' => 1,
'required' => 1,
],
]
],
Notes: widget name can be anything, the implementing library will decide what the widgets are finally. E.g. widget "editor" can be CKeditor, TinyMCE or something else.
This library should just return entities and their field configurations which can be then used by some other component to store, render, validate etc.
Rendering is not responsibility of this class.
UI is not part of this library. It should be another library which requires and uses this library.
Storing this configuration is not part of this library e.g. https://github.com/back-2-95/fields-mongodb
This library provides interface for Storage adapters and file based solution as an example.
By default this adapter uses path data/entities
for storing configurations.