eZ\Publish\Core\Base\Container\ApiLoader\RepositoryFactory::buildService PHP Method

buildService() public method

Returns a service based on a name string (content => contentService, etc).
public buildService ( eZ\Publish\API\Repository\Repository $repository, string $serviceName ) : mixed
$repository eZ\Publish\API\Repository\Repository
$serviceName string
return mixed
    public function buildService(Repository $repository, $serviceName)
    {
        $methodName = 'get' . $serviceName . 'Service';
        if (!method_exists($repository, $methodName)) {
            throw new InvalidArgumentException($serviceName, 'No such service');
        }
        return $repository->{$methodName}();
    }