Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extensions to customize the siteaccess configuration #1937

Merged
merged 1 commit into from Apr 4, 2017

Conversation

bdunogier
Copy link
Member

@bdunogier bdunogier commented Mar 16, 2017

EZP-27115

Allows bundles to add a SiteAccessConfigurationFilter, that gets to filter the siteaccess configuration array before it is applied:

// MyBundle.php
$extension = $container->getExtension('ezpublish');
$extension->addSiteAccessConfigurationFilter(new MyFilter());

// MyFilter.php
function filter($configuration)
{
  $configuration['list'][] = 'foo';
  $configuration['groups']['site_group'][] = 'foo';

  return $configuration;
}

Use-cases

Dynamically create admin siteaccess(es) for the Hybrid UI.

Architecture

The SiteAccessConfigurationFilter, added by 3rd party bundles to the ezpublish extension, are provided to the CoreBundle's Configuration. They are iterated on in the beforeNormalization() method of the siteaccess configuration node.

Tasks

  • JIRA Story with description of user (developer) benefit
  • Unit test additions to EzPublishCoreExtension.
  • Add PhpDoc to the CoreExtension public method and to the Filter interface.
  • Document the feature (doc/specifications/siteaccess/siteaccess_aware_configuration.md)

@bdunogier bdunogier force-pushed the siteaccess_configuration_filter branch from 262eeb0 to 13533c2 Compare March 16, 2017 18:25

namespace eZ\Bundle\EzPublishCoreBundle\SiteAccess;

interface SiteAccessConfigurationFilter
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpdoc

@bdunogier bdunogier force-pushed the siteaccess_configuration_filter branch 3 times, most recently from d5734cd to 80ed9af Compare March 17, 2017 11:47
@bdunogier bdunogier changed the title Added SiteAccessConfigurationFilters to Core Extension Allow extensions to customize the siteaccess configuration Mar 27, 2017
@bdunogier
Copy link
Member Author

bdunogier commented Mar 28, 2017

After discussing with @lolautruche there are better ways to do this (in the TreeBuilder, using beforeNormalize(). Closing for now, I'll reopen it when the new implementation is done.

@bdunogier bdunogier closed this Mar 28, 2017
@bdunogier bdunogier reopened this Mar 29, 2017
@bdunogier bdunogier force-pushed the siteaccess_configuration_filter branch 4 times, most recently from b7de9df to 335f869 Compare March 29, 2017 07:55
Copy link
Contributor

@lolautruche lolautruche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides nitpick, looks good! 👍

@@ -142,7 +148,10 @@ public function load(array $configs, ContainerBuilder $container)
*/
public function getConfiguration(array $config, ContainerBuilder $container)
{
return new Configuration($this->getMainConfigParser(), $this->suggestionCollector);
$configuration = new Configuration($this->getMainConfigParser(), $this->suggestionCollector);
$configuration->setSiteAccessConfigurationFilters($this->siteaccessConfigurationFilters);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not pass those via constructor instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's actually what I started with. But since they actually have a default value, I chose to do it that way instead.

Are there advantages to a ctor argument ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in this context not really.
More generally, it's just that setter injection is optional, so you can't be sure that what's supposed to be injected is really here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is what I did guess, indeed. In that particular case, since we iterate over the property, and it is initialized as an array, I think we're good, and I'd rather leave it as it is.

@andrerom
Copy link
Contributor

andrerom commented Apr 4, 2017

@bdunogier 5ae654e Might not belong here ;) (feel free to delete this when no longer relevant)

@bdunogier
Copy link
Member Author

Oops, mispushed a little bit yesterday evening. Thank you @andrerom :)

Allows one to filter the siteaccess config before it is applied:

  // MyBundle.php
  $extension = $container->getExtension('ezpublish');
  $extension->addSiteAccessConfigurationFilter(new MyFilter());

  // MyFilter.php
  function filter(array $configuration)
  {
    $configuration['list'][] = 'foo';
    $configuration['groups']['site_group'][] = 'foo';

    return $configuration;
  }
@bdunogier bdunogier force-pushed the siteaccess_configuration_filter branch from 5ae654e to 1752adf Compare April 4, 2017 07:38
@bdunogier
Copy link
Member Author

Removed the misplaced commit, and squashed the whole thing.

@bdunogier bdunogier merged commit 7bb34e0 into master Apr 4, 2017
@bdunogier bdunogier deleted the siteaccess_configuration_filter branch April 4, 2017 08:33
@lolautruche
Copy link
Contributor

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants