phpro / zf-smartcrud
Module for creating smartcrud with the ZF2 MVC layer.
Installs: 1 138
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 6
Forks: 4
Open Issues: 0
Type:zf-module
Requires
- php: >=5.3.3
- symfony/console: 2.*
- zendframework/zend-config: 2.*
- zendframework/zend-eventmanager: 2.*
- zendframework/zend-form: 2.*
- zendframework/zend-http: 2.*
- zendframework/zend-modulemanager: 2.*
- zendframework/zend-mvc: 2.*
- zendframework/zend-servicemanager: 2.*
- zendframework/zend-session: 2.*
- zendframework/zend-stdlib: 2.*
- zendframework/zend-version: 2.*
- zendframework/zend-view: 2.*
Requires (Dev)
- bjyoungblood/bjy-authorize: 1.3.*
- doctrine/doctrine-mongo-odm-module: 0.8.*
- doctrine/doctrine-orm-module: 0.8.*
- fabpot/php-cs-fixer: ~1.5.0
- phpspec/phpspec: ~2.0.1
- rwoverdijk/assetmanager: ~1.3.5
- zendframework/zend-db: 2.*
- zendframework/zend-permissions-acl: 2.*
Suggests
- doctrine/doctrine-mongo-odm-module: If you want to use the Doctrine ODM Gateway
- doctrine/doctrine-orm-module: If you want to use the Doctrine ORM Gateway
- rwoverdijk/assetmanager: ~1.3.5
- zendframework/zend-db: If you want to use the Zend DB Gateway
README
Repository abandoned 2020-11-27
This repository has been archived since we are not using it anymore internally. Feel free to use it AS-IS, we won't be providing any support anymore.
SmartCrud for Zend Framework
Module providing a SmartCrud for working with the Zend Framework 2 MVC layer.
Installation
Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.
php composer.phar require phpro/zf-smartcrud
# (When asked for a version, type `dev-master`)
Then add Phpro\SmartCrud
to your config/application.config.php
.
Installation without composer is not officially supported and requires you to manually install all dependencies
that are listed in composer.json
Documentation
Configuration
It is possible to configure the smartcrud services on multiple places. e.g. For the list service, the configuration will be merged as followed:
- phpro-smartcrud-service['default']
- phpro-smartcrud-service['default-list']
- service_manager['my-custom-smartcrud-service']['default']
- service_manager['my-custom-smartcrud-service']['list']
This means it is possible to specify some default configuration and overwrite it for custom services.
SmartCrud Configuration
Gateways
It is possible to configure multiple data-source gateways. Those gateways are being used by the services to load and save the data.
'phpro-smartcrud-gateway' => array( 'smartcrud.gateway.doctrine.default' => array( 'type' => 'PhproSmartCrud\Gateway\DoctrineCrudGateway', 'options' => array( 'object_manager' => 'doctrine.documentmanager.odm_default', ), ) ),
Services
'phpro-smartcrud-service' => array( 'SmartCrudServiceKey' => array( 'default' => array( 'gateway' => 'smartcrud.gateway.doctrine.default', 'entity-class' => 'entity-key', 'form' => 'form-key', 'listeners' => [] ), ), ),
List Service
The list service has some extra configurable options. It is required to specify a paginator and it is optional to add a query provider to filter / sort lists.
Paginator
'phpro-smartcrud-service' => array( 'default-list' => array( 'options' => array( 'paginator' => array( 'adapter_class' => '\Zend\Paginator\Adapter\ArrayAdapter', 'page_size' => 50, 'page_key' => 'page', ), ) ) ),
Query Provider
A query provider implements the QueryProviderInterface
.
It is possible to add your own query provider to a List Service:
'phpro-smartcrud-service' => array( 'default-list' => array( 'options' => array( 'query-provider' => 'servicemanager.key.my-custom-query-provider', ), ) ),
listeners:
Array of service manager keys, which return EventListenerAggregateInterface. These listeners can be used listen to SmartCrud events on entities.
Available SmartCrud events:
CrudEvent::BEFORE_LIST CrudEvent::AFTER_LIST CrudEvent::BEFORE_DATA_VALIDATION CrudEvent::BEFORE_CREATE CrudEvent::AFTER_CREATE CrudEvent::INVALID_CREATE CrudEvent::BEFORE_READ CrudEvent::AFTER_READ CrudEvent::BEFORE_UPDATE CrudEvent::AFTER_UPDATE CrudEvent::INVALID_UPDATE CrudEvent::BEFORE_DELETE CrudEvent::AFTER_DELETE CrudEvent::INVALID_DELETE CrudEvent::BEFORE_VALIDATE CrudEvent::AFTER_VALIDATE CrudEvent::FORM_READY
Controllers
It is possible to specify some default controller configuration and overwrite it for custom controllers. The configuration will be merged as followed:
- phpro-smartcrud-controller['default']
- phpro-smartcrud-controller['my-custom-smartcrud-controller']
'phpro-smartcrud-controller' => array( 'default' => array( 'view-builder' => 'Phpro\SmartCrud\View\Model\ViewModelBuilder', ) 'SmartCrudControllerKey' => array( 'controller' => 'Phpro\SmartCrud\Controller\CrudController', 'identifier-name' => 'identifier', 'smart-service' => 'SmartCrudServiceKey', 'view-builder' => 'Phpro\SmartCrud\View\Model\ViewModelBuilder', 'view-path' => 'path', ), ),
More coming soon!