PHP Class ZF\Apigility\Admin\Model\RestServiceModel

Inheritance: implements Zend\EventManager\EventManagerAwareInterface
Show file Open project: zfcampus/zf-apigility-admin Class Usage Examples

Protected Properties

Property Type Description
$configResource ZF\Configuration\ConfigResource
$events Zend\EventManager\EventManagerInterface
$module string
$moduleEntity ModuleEntity
$modulePath string
$modules ModulePathSpec
$renderer Zend\View\Renderer\PhpRenderer
$restArrayUpdateOptions array Allowed REST update options that are arrays
$restScalarUpdateOptions array Allowed REST update options that are scalars
$routeNameFilter Zend\Filter\FilterChain

Public Methods

Method Description
__construct ( ModuleEntity $moduleEntity, ModulePathSpec $modules, ZF\Configuration\ConfigResource $config )
__get ( string $name ) : mixed Allow read-only access to properties
createCollectionClass ( string $serviceName ) : string Create a collection class for the resource
createContentNegotiationConfig ( RestServiceEntity $details, string $controllerService ) Create content negotiation configuration based on payload and discovered controller service name
createControllerServiceName ( string $serviceName ) : string Generate the controller service name from the module and service name
createEntityClass ( string $serviceName, string $template = 'entity', RestServiceEntity $details = null ) : string Create an entity class for the resource
createFactoryClass ( $serviceName )
createHalConfig ( RestServiceEntity $details, string $entityClass, string $collectionClass, string $routeName ) Create HAL configuration
createMediaType ( ) : string Create the mediatype for this
createResourceClass ( string $serviceName ) : string Creates a new resource class based on the specified service name
createRestConfig ( RestServiceEntity $details, string $controllerService, string $resourceClass, string $routeName ) Creates REST configuration
createRoute ( string $serviceName, string $route, string $routeIdentifier, string $controllerService ) : string Create the route configuration
createService ( RestServiceEntity $details ) : RestServiceEntity Create a new service using the details provided
deleteAuthorizationConfig ( RestServiceEntity $entity ) Delete any authorization configuration for a service
deleteContentNegotiationConfig ( RestServiceEntity $entity ) Delete content-negotiation configuration associated with a service
deleteContentValidationConfig ( RestServiceEntity $entity ) Delete content-validation configuration associated with a service
deleteHalConfig ( RestServiceEntity $entity ) Delete HAL configuration for the service
deleteRestConfig ( RestServiceEntity $entity ) Delete the REST configuration associated with the given service
deleteRoute ( RestServiceEntity $entity ) Delete the route associated with the given service
deleteService ( string $controllerService, boolean $recursive = false ) : true Delete a named service
deleteServiceManagerConfig ( RestServiceEntity $entity ) Delete any service manager configuration for the resource
deleteVersioningConfig ( RestServiceEntity $entity ) Delete versioning configuration for a service
fetch ( string $controllerService, boolean $isAFetchOperation = true ) : RestServiceEntity | false
fetchAll ( integer $version = null ) : RestServiceEntity[] Fetch all services
getEventManager ( ) : Zend\EventManager\EventManagerInterface Retrieve the EventManager instance
setEventManager ( Zend\EventManager\EventManagerInterface $events ) Set the EventManager instance
updateContentNegotiationConfig ( RestServiceEntity $original, RestServiceEntity $update ) Update the content negotiation configuration for the service
updateHalConfig ( RestServiceEntity $original, RestServiceEntity $update ) Update HAL configuration
updateRestConfig ( RestServiceEntity $original, RestServiceEntity $update ) Update REST configuration
updateRoute ( RestServiceEntity $original, RestServiceEntity $update ) Update the route for an existing service
updateService ( RestServiceEntity $update ) : RestServiceEntity Update an existing service

Protected Methods

Method Description
createClassFile ( Zend\View\Model\ViewModel $model, string $type, string $classPath ) : boolean Create a class file
deriveCollectionClass ( string $controllerServiceName, RestServiceEntity $metadata, array $config ) : string Derive the name of the collection class from the controller service name
deriveEntityClass ( string $controllerServiceName, RestServiceEntity $metadata, array $config ) : string Derive the name of the entity class from the controller service name
getConfigForSubkey ( string $subKey, array | mixed $default = [] ) : mixed Traverse an array for a subkey
getRenderer ( ) : Zend\View\Renderer\PhpRenderer Get a renderer instance
getRouteInfo ( RestServiceEntity $metadata, array $config ) Retrieve route information for a given service based on the configuration available
getRouteNameFilter ( ) : Zend\Filter\FilterChain Retrieve the filter chain for generating the route name
getSourcePath ( string $serviceName ) : string Get the source path for the module
injectResolver ( Zend\View\Renderer\PhpRenderer $renderer, string $type ) : string Inject the renderer with a resolver
mergeContentNegotiationConfig ( string $controllerServiceName, RestServiceEntity $metadata, array $config ) Merge the content negotiation configuration for the given controller service into the REST metadata
mergeHalConfig ( string $controllerServiceName, RestServiceEntity $metadata, array $config ) Merge entity and collection class into metadata, if found
routeAlreadyExist ( string $route, string $excludeRouteName = null ) : boolean Check if a route already exist in the configuration

Private Methods

Method Description
moduleNameToRegex ( ) : string Converts a module name (which could include namespace separators) into a string that can be used in regex matches. Use-cases: - Acme\Account => Acme\\Account - Acme\\Account (ideally it should never happen) => Acme\\Account - Acme => Acme

Method Details

__construct() public method

public __construct ( ModuleEntity $moduleEntity, ModulePathSpec $modules, ZF\Configuration\ConfigResource $config )
$moduleEntity ModuleEntity
$modules ModulePathSpec
$config ZF\Configuration\ConfigResource

__get() public method

Allow read-only access to properties
public __get ( string $name ) : mixed
$name string
return mixed

createClassFile() protected method

Creates a class file based on the view model passed, the type of resource, and writes it to the path provided.
protected createClassFile ( Zend\View\Model\ViewModel $model, string $type, string $classPath ) : boolean
$model Zend\View\Model\ViewModel
$type string
$classPath string
return boolean

createCollectionClass() public method

Create a collection class for the resource
public createCollectionClass ( string $serviceName ) : string
$serviceName string
return string The name of the newly created collection class

createContentNegotiationConfig() public method

Create content negotiation configuration based on payload and discovered controller service name
public createContentNegotiationConfig ( RestServiceEntity $details, string $controllerService )
$details RestServiceEntity
$controllerService string

createControllerServiceName() public method

Generate the controller service name from the module and service name
public createControllerServiceName ( string $serviceName ) : string
$serviceName string
return string

createEntityClass() public method

Create an entity class for the resource
public createEntityClass ( string $serviceName, string $template = 'entity', RestServiceEntity $details = null ) : string
$serviceName string
$template string Which template to use; defaults to 'entity'
$details RestServiceEntity
return string The name of the newly created entity class

createFactoryClass() public method

public createFactoryClass ( $serviceName )

createHalConfig() public method

Create HAL configuration
public createHalConfig ( RestServiceEntity $details, string $entityClass, string $collectionClass, string $routeName )
$details RestServiceEntity
$entityClass string
$collectionClass string
$routeName string

createMediaType() public method

Based on the module and the latest module version.
public createMediaType ( ) : string
return string

createResourceClass() public method

Creates a new resource class based on the specified service name
public createResourceClass ( string $serviceName ) : string
$serviceName string
return string The name of the newly created class

createRestConfig() public method

Creates REST configuration
public createRestConfig ( RestServiceEntity $details, string $controllerService, string $resourceClass, string $routeName )
$details RestServiceEntity
$controllerService string
$resourceClass string
$routeName string

createRoute() public method

Create the route configuration
public createRoute ( string $serviceName, string $route, string $routeIdentifier, string $controllerService ) : string
$serviceName string
$route string
$routeIdentifier string
$controllerService string
return string

createService() public method

Create a new service using the details provided
public createService ( RestServiceEntity $details ) : RestServiceEntity
$details RestServiceEntity
return RestServiceEntity

deleteAuthorizationConfig() public method

Delete any authorization configuration for a service
public deleteAuthorizationConfig ( RestServiceEntity $entity )
$entity RestServiceEntity

deleteContentNegotiationConfig() public method

Delete content-negotiation configuration associated with a service
public deleteContentNegotiationConfig ( RestServiceEntity $entity )
$entity RestServiceEntity

deleteContentValidationConfig() public method

Delete content-validation configuration associated with a service
public deleteContentValidationConfig ( RestServiceEntity $entity )
$entity RestServiceEntity

deleteHalConfig() public method

Delete HAL configuration for the service
public deleteHalConfig ( RestServiceEntity $entity )
$entity RestServiceEntity

deleteRestConfig() public method

Delete the REST configuration associated with the given service
public deleteRestConfig ( RestServiceEntity $entity )
$entity RestServiceEntity

deleteRoute() public method

Delete the route associated with the given service
public deleteRoute ( RestServiceEntity $entity )
$entity RestServiceEntity

deleteService() public method

Delete a named service
public deleteService ( string $controllerService, boolean $recursive = false ) : true
$controllerService string
$recursive boolean
return true

deleteServiceManagerConfig() public method

Delete any service manager configuration for the resource
public deleteServiceManagerConfig ( RestServiceEntity $entity )
$entity RestServiceEntity

deleteVersioningConfig() public method

Removes the route name from zf-versioning.
public deleteVersioningConfig ( RestServiceEntity $entity )
$entity RestServiceEntity

deriveCollectionClass() protected method

Derive the name of the collection class from the controller service name
protected deriveCollectionClass ( string $controllerServiceName, RestServiceEntity $metadata, array $config ) : string
$controllerServiceName string
$metadata RestServiceEntity
$config array
return string

deriveEntityClass() protected method

Derive the name of the entity class from the controller service name
protected deriveEntityClass ( string $controllerServiceName, RestServiceEntity $metadata, array $config ) : string
$controllerServiceName string
$metadata RestServiceEntity
$config array
return string

fetch() public method

public fetch ( string $controllerService, boolean $isAFetchOperation = true ) : RestServiceEntity | false
$controllerService string
$isAFetchOperation boolean If this is for a non-fetch operation, pass boolean false; allows listeners to include additional data necessary for clean updates.
return RestServiceEntity | false

fetchAll() public method

Fetch all services
public fetchAll ( integer $version = null ) : RestServiceEntity[]
$version integer
return RestServiceEntity[]

getConfigForSubkey() protected method

Subkey is given in "." notation, which is then split, and the configuration is traversed until no more keys are available, or a corresponding entry is not found; in the latter case, the $default will be provided.
protected getConfigForSubkey ( string $subKey, array | mixed $default = [] ) : mixed
$subKey string
$default array | mixed
return mixed

getEventManager() public method

Lazy instantiates one if none currently registered
public getEventManager ( ) : Zend\EventManager\EventManagerInterface
return Zend\EventManager\EventManagerInterface

getRenderer() protected method

Get a renderer instance
protected getRenderer ( ) : Zend\View\Renderer\PhpRenderer
return Zend\View\Renderer\PhpRenderer

getRouteInfo() protected method

Retrieve route information for a given service based on the configuration available
protected getRouteInfo ( RestServiceEntity $metadata, array $config )
$metadata RestServiceEntity
$config array

getRouteNameFilter() protected method

Retrieve the filter chain for generating the route name
protected getRouteNameFilter ( ) : Zend\Filter\FilterChain
return Zend\Filter\FilterChain

getSourcePath() protected method

Get the source path for the module
protected getSourcePath ( string $serviceName ) : string
$serviceName string
return string

injectResolver() protected method

Seed the resolver with a template name and path based on the $type passed, and inject it into the renderer.
protected injectResolver ( Zend\View\Renderer\PhpRenderer $renderer, string $type ) : string
$renderer Zend\View\Renderer\PhpRenderer
$type string
return string Template name

mergeContentNegotiationConfig() protected method

Merge the content negotiation configuration for the given controller service into the REST metadata
protected mergeContentNegotiationConfig ( string $controllerServiceName, RestServiceEntity $metadata, array $config )
$controllerServiceName string
$metadata RestServiceEntity
$config array

mergeHalConfig() protected method

Merge entity and collection class into metadata, if found
protected mergeHalConfig ( string $controllerServiceName, RestServiceEntity $metadata, array $config )
$controllerServiceName string
$metadata RestServiceEntity
$config array

routeAlreadyExist() protected method

Check if a route already exist in the configuration
protected routeAlreadyExist ( string $route, string $excludeRouteName = null ) : boolean
$route string
$excludeRouteName string
return boolean

setEventManager() public method

Set the EventManager instance
public setEventManager ( Zend\EventManager\EventManagerInterface $events )
$events Zend\EventManager\EventManagerInterface

updateContentNegotiationConfig() public method

Update the content negotiation configuration for the service
public updateContentNegotiationConfig ( RestServiceEntity $original, RestServiceEntity $update )
$original RestServiceEntity
$update RestServiceEntity

updateHalConfig() public method

Update HAL configuration
public updateHalConfig ( RestServiceEntity $original, RestServiceEntity $update )
$original RestServiceEntity
$update RestServiceEntity

updateRestConfig() public method

Update REST configuration
public updateRestConfig ( RestServiceEntity $original, RestServiceEntity $update )
$original RestServiceEntity
$update RestServiceEntity

updateRoute() public method

Update the route for an existing service
public updateRoute ( RestServiceEntity $original, RestServiceEntity $update )
$original RestServiceEntity
$update RestServiceEntity

updateService() public method

Update an existing service
public updateService ( RestServiceEntity $update ) : RestServiceEntity
$update RestServiceEntity
return RestServiceEntity

Property Details

$configResource protected property

protected ConfigResource,ZF\Configuration $configResource
return ZF\Configuration\ConfigResource

$events protected property

protected EventManagerInterface,Zend\EventManager $events
return Zend\EventManager\EventManagerInterface

$module protected property

protected string $module
return string

$moduleEntity protected property

protected ModuleEntity,ZF\Apigility\Admin\Model $moduleEntity
return ModuleEntity

$modulePath protected property

protected string $modulePath
return string

$modules protected property

protected ModulePathSpec,ZF\Apigility\Admin\Model $modules
return ModulePathSpec

$renderer protected property

protected PhpRenderer,Zend\View\Renderer $renderer
return Zend\View\Renderer\PhpRenderer

$restArrayUpdateOptions protected property

Allowed REST update options that are arrays
protected array $restArrayUpdateOptions
return array

$restScalarUpdateOptions protected property

Allowed REST update options that are scalars
protected array $restScalarUpdateOptions
return array

$routeNameFilter protected property

protected FilterChain,Zend\Filter $routeNameFilter
return Zend\Filter\FilterChain