2017 © Pedro Peláez
 

library entity

Generic entity API and entity revision control.

image

kapitchi/entity

Generic entity API and entity revision control.

  • Friday, November 14, 2014
  • by kapitchi
  • Repository
  • 4 Watchers
  • 3 Stars
  • 232 Installations
  • PHP
  • 17 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Zend Framework 2 - Kapitchi Entity module

Version: 0.1-dev
Website: http://kapitchi.com
Demo: http://kapitchi.com/showcase
Copyright: (c) 2012-2013 Kapitchi Open Source Team, (*1)

README.md status: INCOMPLETE, (*2)

License

LGPLv3
The GNU Lesser General Public License, version 3.0, (*3)

Introduction

Set of common classes/interfaces to provide generic entity API and event triggering - services, mappers, controllers and helpers to work and manage entities. Entity is defined as POPO implementing one method getId() and having empty constructor., (*4)

Installation

TODO, (*5)

Basic Usage

Find entity/entities

Find by entity ID, (*6)

    $entity = $service->find(1); //returns entity object or null if not found
    //OR
    $entity = $service->get(1); //throws exception if not found

Get entity paginator by multiple criteria, (*7)

    $paginator = $service->getPaginator(array(
        'displayName' => 'kapitchi'
    ), array(
        'created' => 'ASC' //order by created ascending
    ));

    $entities = $paginator->getCurrentItems();

Persist entity

Persist entity object. Note that new entity is inserted when getId() is not 'empty' value otherwise a mapper performs update, (*8)

    $entity = $service->createEntityFromArray(array( //creates entity from array
        'displayName' => 'kapitchi'
    ));
    $persistEvent = $service->persist($entity);
    //$entity->getId() is populated now

Persist entity from array, (*9)

    $persistEvent = $service->persist(array(
        'displayName' => 'kapitchi'
    ));

Remove entity

$service->remove($entity);

Events

Example presumes using MyModule\Service\MyEntity service class name., (*10)

$service->persist($entity)

Event: MyModule\Service\MyEntity:persist Params: - entity - entity object - data - when entity is persisted from array - origEntity - when persisting/updating an existing entity we load from mapper original entity first, (*11)

TODO, (*12)

Service manager configuration

Entity service with Zend\Db mapper

    'MyModule\Service\MyEntity' => function ($sm) {
        $s = new Service\MyEntity(
            $sm->get('MyModule\Mapper\MyEntity'),
            $sm->get('MyModule\Entity\MyEntity'),
            $sm->get('MyModule\Entity\MyEntityHydrator')
        );
        return $s;
    },
    'MyModule\Mapper\MyEntityDbAdapter' => function ($sm) {
        return new \KapitchiEntity\Mapper\MyEntityDbAdapter(
            $sm->get('Zend\Db\Adapter\Adapter'),
            new EntityDbAdapterMapperOptions(array(
                'tableName' => 'identity_auth_credential',
                'primaryKey' => 'id',
                'hydrator' => $sm->get('MyModule\Entity\MyEntityHydrator'),
                'entityPrototype' => $sm->get('MyModule\Entity\MyEntity'),
            ))
        );
    },
    'MyModule\Entity\MyEntityHydrator' => function ($sm) {
        //needed here because hydrator tranforms camelcase to underscore
        return new \Zend\Stdlib\Hydrator\ClassMethods(false);
    },

Entity service with Doctrine mapper

TODO, (*13)

The Versions

14/11 2014

0.1.x-dev

0.1.9999999.9999999-dev http://kapitchi.com

Generic entity API and entity revision control.

  Sources   Download

The Requires

 

zf2 entity kapitchi

01/08 2013

dev-master

9999999-dev http://kapitchi.com

Generic entity API and entity revision control.

  Sources   Download

LGPL-3.0

The Requires

 

zf2 entity kapitchi