2017 © Pedro Peláez
 

zf-module zf-smartcrud

Module for creating smartcrud with the ZF2 MVC layer.

image

phpro/zf-smartcrud

Module for creating smartcrud with the ZF2 MVC layer.

  • Tuesday, January 19, 2016
  • by phpro
  • Repository
  • 3 Watchers
  • 4 Stars
  • 908 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 10 Open issues
  • 8 Versions
  • 5 % Grown

The README.md

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., (*1)

SmartCrud for Zend Framework

Master: Build Status Dev-Master: Build Status, (*2)

Module providing a SmartCrud for working with the Zend Framework 2 MVC layer., (*3)

Installation

Installation of this module uses composer. For composer documentation, please refer to getcomposer.org., (*4)

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., (*5)

Installation without composer is not officially supported and requires you to manually install all dependencies that are listed in composer.json, (*6)

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:, (*7)

  • 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., (*8)

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., (*9)

'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., (*10)

Paginator, (*11)

'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, (*12)

A query provider implements the QueryProviderInterface. It is possible to add your own query provider to a List Service:, (*13)

'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., (*14)

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'], (*15)

'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!, (*16)

The Versions