Skip to content

Instantly share code, notes, and snippets.

@lolautruche
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lolautruche/2f5aeca15332bcd5220b to your computer and use it in GitHub Desktop.
Save lolautruche/2f5aeca15332bcd5220b to your computer and use it in GitHub Desktop.
Dynamic settings injection 4/4, as of eZ 5.4 / 2014.09 - 3rd party parameters
parameters:
acme_test.my_service.class: Acme\TestBundle\MyServiceClass
# "acme" is our parameter namespace.
# Null is the default value.
acme.default.some_parameter: ~
acme.ezdemo_site.some_parameter: foo
acme.ezdemo_site_admin.some_parameter: bar
services:
acme_test.my_service:
class: %acme_test.my_service.class%
# The following argument will automatically resolve to the right value, depending on the current SiteAccess.
# We specify "acme" as the namespace we want to use for parameter resolving.
calls:
- [setSomeParameter, ["$some_parameter;acme$"]]
<?php
namespace Acme\TestBundle;
class MyServiceClass
{
private $myParameter;
public function setSomeParameter( $myParameter = null )
{
// Will be "foo" for ezdemo_site, "bar" for ezdemo_site_admin, or null if another SiteAccess.
$this->myParameter = $myParameter;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment