Newscoop\Service\Resource\ResourceRepository::configureService PHP Method

configureService() protected method

This configurations works as folows: - if in the repository properties there is a property that has the format [simple class name].[field name] it will automatically assigne the value found to the service field. - the [simple class name] represents the service implementation simple class name (ex: 'ThemeServiceLocalFileSystem') - the [field name] represents the field name inside the instance that will be assigned the value for that property. ex: ThemeServiceLocalFileSystem.path=\usr\local This will configure the field path in the service instance with the provided value.
protected configureService ( mixed $service ) : mixed
$service mixed The service to be configured, not null.
return mixed The configured service instance.
    protected function configureService($service)
    {
        $prefix = 'config.' . $this->extractSimpleClassName(get_class($service)) . '.';
        $length = strlen($prefix);
        $properties = $this->getRepositoryProperties();
        foreach ($properties as $key => $val) {
            if (strncmp($key, $prefix, $length) == 0) {
                $fieldName = substr($key, $length);
                $service->{$fieldName} = $val;
            }
        }
        return $service;
    }