src/Admin/Model/DoctrineRestServiceModel.php
/**
     * Determine if the given entity is doctrine-connected, and, if so, recast to a DoctrineRestServiceEntity
     *
     * @param \Zend\EventManager\EventInterface $event
     * @return null|DoctrineRestServiceEntity
     */
Determine if the given entity is doctrine-connected, and, if so, recast to a DoctrineRestServiceEntity
@param \Zend\EventManager\EventInterface $event
@return null|DoctrineRestServiceEntity
Determine if the given entity is doctrine - connected and if so recast to a DoctrineRestServiceEntity @param \ Zend \ EventManager \ EventInterface $event @return null|DoctrineRestServiceEntity
public static function onFetch($event)
    {
        $entity = $event->getParam('entity', false);
        if (! $entity) {
            return;
        }
        $config = $event->getParam('config', []);
        if (! isset($config['zf-apigility']['doctrine-connected'][$entity->resourceClass])) {
            return;
        }
                $configResource = $config['zf-apigility']['doctrine-connected'][$entity->resourceClass];
        if (isset($config['doctrine-hydrator']) && isset($config['doctrine-hydrator'][$configResource['hydrator']])) {
            $configHydrator = $config['doctrine-hydrator'][$configResource['hydrator']];
            $config = array_merge($configResource, $configHydrator);
        } else {
            $config = $configResource;
        }
        $doctrineEntity = new DoctrineRestServiceEntity();
        $doctrineEntity->exchangeArray(array_merge($entity->getArrayCopy(), $config));
        return $doctrineEntity;
    }
public static function onFetch ( $ event ) { $ entity = $ event -> getParam ( 'entity' , false ) ; if ( ! $ entity ) { return ; } $ config = $ event -> getParam ( 'config' , [ ] ) ; if ( ! isset ( $ config [ 'zf-apigility' ] [ 'doctrine-connected' ] [ $ entity -> resourceClass ] ) ) { return ; } $ configResource = $ config [ 'zf-apigility' ] [ 'doctrine-connected' ] [ $ entity -> resourceClass ] ; if ( isset ( $ config [ 'doctrine-hydrator' ] ) && isset ( $ config [ 'doctrine-hydrator' ] [ $ configResource [ 'hydrator' ] ] ) ) { $ configHydrator = $ config [ 'doctrine-hydrator' ] [ $ configResource [ 'hydrator' ] ] ; $ config = array_merge ( $ configResource , $ configHydrator ) ; } else { $ config = $ configResource ; } $ doctrineEntity = new DoctrineRestServiceEntity ( ) ; $ doctrineEntity -> exchangeArray ( array_merge ( $ entity -> getArrayCopy ( ) , $ config ) ) ; return $ doctrineEntity ; }
Determine if the given entity is doctrine-connected, and, if so, recast to a DoctrineRestServiceEntity
 @param \Zend\EventManager\EventInterface $event
 @return null|DoctrineRestServiceEntity
Determine if the given entity is doctrine - connected and if so recast to a DoctrineRestServiceEntity @param \ Zend \ EventManager \ EventInterface $event @return null|DoctrineRestServiceEntity
// No entity; nothing to do // No DB-connected configuration for this service; nothing to do // TODO : Move hydrators handling into separate model ?
