Skip to content

Commit

Permalink
We do not need config resolver any more, configuration injected directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Blazek committed Jan 19, 2017
1 parent 14d0f42 commit 79604ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions bundle/Factory/EmailDataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
class EmailDataFactory
{
/**
* @var ConfigResolverInterface
* @var array
*/
protected $configResolver;
protected $config;

/**
* @var TranslationHelper
Expand All @@ -34,19 +34,19 @@ class EmailDataFactory
/**
* EmailDataFactory constructor.
*
* @param ConfigResolverInterface $configResolver
* @param array $config
* @param TranslationHelper $translationHelper
* @param FieldHelper $fieldHelper
* @param ContentTypeService $contentTypeService
*/
public function __construct(
ConfigResolverInterface $configResolver,
array $config,
TranslationHelper $translationHelper,
FieldHelper $fieldHelper,
ContentTypeService $contentTypeService
) {

$this->configResolver = $configResolver;
$this->config = $config;
$this->translationHelper = $translationHelper;
$this->fieldHelper = $fieldHelper;
$this->contentTypeService = $contentTypeService;
Expand Down Expand Up @@ -87,7 +87,7 @@ protected function resolve(Content $content, $field, $property = 'text')

return $fieldValue->value->$property;
} else {
return $this->configResolver->getParameter('information_collection.email.' . $field, 'netgen');
return $this->config['default_variables'][$field];
}
}

Expand All @@ -104,10 +104,12 @@ protected function resolveTemplate($content)

$contentTypeIdentifier = $contentType->identifier;

if ($this->configResolver->hasParameter('information_collection.email.' . $contentTypeIdentifier, 'netgen')) {
return $this->configResolver->getParameter('information_collection.email.' . $contentTypeIdentifier, 'netgen');
if (array_key_exists($contentTypeIdentifier, $this->config['templates'])) {

return $this->config['templates'][$contentTypeIdentifier];

}

return $this->configResolver->getParameter('information_collection.email.default', 'netgen');
return $this->config['templates']['default'];
}
}
2 changes: 1 addition & 1 deletion bundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ services:
netgen_information_collection.factory.email_data:
class: '%netgen_information_collection.factory.email_data.class%'
arguments:
- '@ezpublish.config.resolver'
- "$action_config.email;netgen_information_collection$"
- '@ezpublish.translation_helper'
- '@ezpublish.field_helper'
- '@ezpublish.api.service.content_type'
Expand Down

0 comments on commit 79604ee

Please sign in to comment.