PHP Class ZF\Apigility\DbConnectedResourceAbstractFactory

Inheritance: implements Zend\ServiceManager\AbstractFactoryInterface
显示文件 Open project: zfcampus/zf-apigility

Public Methods

Method Description
__invoke ( Interop\Container\ContainerInterface $container, string $requestedName, array $options = null ) : ZF\Rest\Resource Create and return the database-connected resource.
canCreate ( Interop\Container\ContainerInterface $container, string $requestedName ) : boolean Can this factory create the requested service?
canCreateServiceWithName ( Zend\ServiceManager\ServiceLocatorInterface $container, string $name, string $requestedName ) : boolean Can this factory create the requested service? (v2)
createServiceWithName ( Zend\ServiceManager\ServiceLocatorInterface $container, string $name, string $requestedName ) : ZF\Rest\Resource Create and return the database-connected resource (v2).

Protected Methods

Method Description
getCollectionFromConfig ( array $config, string $requestedName ) : string Retrieve the collection class based on the provided configuration.
getIdentifierFromConfig ( array $config ) : string Retrieve the table identifier field from the provided configuration.
getResourceClassFromConfig ( array $config, string $requestedName ) : string Retrieve the resource class based on the provided configuration.
getTableGatewayFromConfig ( array $config, string $requestedName, Interop\Container\ContainerInterface $container ) : Zend\Db\TableGateway\TableGatewayInterface Retrieve a table gateway instance based on provided configuration.
isValidConfig ( array $config, string $requestedName, Interop\Container\ContainerInterface $container ) : boolean Tests if the configuration is valid

Method Details

__invoke() public method

Create and return the database-connected resource.
public __invoke ( Interop\Container\ContainerInterface $container, string $requestedName, array $options = null ) : ZF\Rest\Resource
$container Interop\Container\ContainerInterface
$requestedName string
$options array
return ZF\Rest\Resource

canCreate() public method

Can this factory create the requested service?
public canCreate ( Interop\Container\ContainerInterface $container, string $requestedName ) : boolean
$container Interop\Container\ContainerInterface
$requestedName string
return boolean

canCreateServiceWithName() public method

Provided for backwards compatiblity; proxies to canCreate().
public canCreateServiceWithName ( Zend\ServiceManager\ServiceLocatorInterface $container, string $name, string $requestedName ) : boolean
$container Zend\ServiceManager\ServiceLocatorInterface
$name string
$requestedName string
return boolean

createServiceWithName() public method

Provided for backwards compatibility; proxies to __invoke().
public createServiceWithName ( Zend\ServiceManager\ServiceLocatorInterface $container, string $name, string $requestedName ) : ZF\Rest\Resource
$container Zend\ServiceManager\ServiceLocatorInterface
$name string
$requestedName string
return ZF\Rest\Resource

getCollectionFromConfig() protected method

Defaults to Zend\Paginator\Paginator.
protected getCollectionFromConfig ( array $config, string $requestedName ) : string
$config array
$requestedName string
return string

getIdentifierFromConfig() protected method

Defaults to 'id' if none is found.
protected getIdentifierFromConfig ( array $config ) : string
$config array
return string

getResourceClassFromConfig() protected method

Defaults to ZF\Apigility\DbConnectedResource.
protected getResourceClassFromConfig ( array $config, string $requestedName ) : string
$config array
$requestedName string
return string

getTableGatewayFromConfig() protected method

Retrieve a table gateway instance based on provided configuration.
protected getTableGatewayFromConfig ( array $config, string $requestedName, Interop\Container\ContainerInterface $container ) : Zend\Db\TableGateway\TableGatewayInterface
$config array
$requestedName string
$container Interop\Container\ContainerInterface
return Zend\Db\TableGateway\TableGatewayInterface

isValidConfig() protected method

If the configuration has a "table_service" key, and that service exists, then the configuration is valid. Otherwise, it checks if the service $requestedName\Table exists.
protected isValidConfig ( array $config, string $requestedName, Interop\Container\ContainerInterface $container ) : boolean
$config array
$requestedName string
$container Interop\Container\ContainerInterface
return boolean