Skip to content

Commit

Permalink
Implemented Policy provider
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioBlazek committed Jan 24, 2020
1 parent 3ed7a2b commit e32fb0f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
7 changes: 7 additions & 0 deletions bundle/NetgenInformationCollectionBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Netgen\Bundle\InformationCollectionBundle;

use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\EzPublishCoreExtension;
use Netgen\Bundle\InformationCollectionBundle\PolicyProvider\InformationCollectionPolicyProvider;
use Netgen\Bundle\InformationCollectionBundle\DependencyInjection\Compiler\ActionsPass;
use Netgen\Bundle\InformationCollectionBundle\DependencyInjection\Compiler\CustomFieldHandlersPass;
use Netgen\Bundle\InformationCollectionBundle\DependencyInjection\Compiler\FieldAnonymizerVisitorPass;
Expand All @@ -20,5 +22,10 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new ActionsPass());
$container->addCompilerPass(new CustomFieldHandlersPass());
$container->addCompilerPass(new FieldAnonymizerVisitorPass());

$eZExtension = $container->getExtension('ezpublish');
if ($eZExtension instanceof EzPublishCoreExtension) {
$eZExtension->addPolicyProvider(new InformationCollectionPolicyProvider());
}
}
}
28 changes: 28 additions & 0 deletions bundle/PolicyProvider/InformationCollectionPolicyProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Netgen\Bundle\InformationCollectionBundle\PolicyProvider;

use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigBuilderInterface;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Security\PolicyProvider\PolicyProviderInterface;

class InformationCollectionPolicyProvider implements PolicyProviderInterface
{
/**
* @param \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigBuilderInterface $configBuilder
*
* @return array
*/
public function addPolicies(ConfigBuilderInterface $configBuilder)
{
$configBuilder->addConfig([
'infocollector' => [
'read' => [],
'delete' => [],
'anonymize' => [],
'export' => [],
],
]);

return [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ netgen_information_collection_admin_collection_no_collections_results: "Displayi

netgen_information_collection_admin_view_title: 'Collection #%collection_id% for %content_name%'
netgen_information_collection_admin_view_subtitle: 'Last modified: %date%, %user_name%'
netgen_information_collection_admin_view_download: 'Download link'
netgen_information_collection_admin_view_delete: 'Delete'
netgen_information_collection_admin_view_anonymize: 'Anonymize'
netgen_information_collection_admin_view_delete_field: 'Delete selected fields'
Expand Down
6 changes: 5 additions & 1 deletion bundle/Resources/views/admin/view.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
{{ ez_field_name(content, attribute.field.identifier) }}:
</span>
<span class="attribute-value">
{{ attribute.entity.value }}
{% if attribute.field.fieldTypeIdentifier == 'enhancedezbinaryfile' %}
<a href="{{ path('netgen_enhancedezbinaryfile.route.download_binary_file', { 'infocollectionAttributeId': attribute.entity.id }) }}">{{ 'netgen_information_collection_admin_view_download'|trans }}: {{ attribute.field.identifier }}</a>
{% else %}
{{ attribute.entity.value }}
{% endif %}
</span>
</label>
</div>
Expand Down
5 changes: 5 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.7.0] - 2020-01-24
### Added
- Implemented Information collection policy provider
- Enabled download controller for enhanced binary file

## [1.6.8] - 2019-04-26
### Added
- A bit more looser coupling to `doctrine/orm` version
Expand Down

0 comments on commit e32fb0f

Please sign in to comment.