aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--conf/general.yml-example8
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm15
-rw-r--r--t/cobrand/features.t16
4 files changed, 40 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cbaabf68f..38aeb4ad9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
- Fix bug going between report/new pages client side
- Development improvements:
- Upgrade the underlying framework and a number of other packages.
+ - Add feature cobrand helper function.
* v2.6 (3rd May 2019)
- New features:
diff --git a/conf/general.yml-example b/conf/general.yml-example
index 8dd4d0a2f..71e994dc0 100644
--- a/conf/general.yml-example
+++ b/conf/general.yml-example
@@ -192,6 +192,14 @@ ALLOWED_COBRANDS:
# the admin interface. Defaults to BASE_URL with "/admin" on the end.
ADMIN_BASE_URL: ''
+# If your site has many cobrands, you may want to have per-cobrand settings. To
+# do this, make a hash of feature keys, each of which is a hash of monikers, eg
+# COBRAND_FEATURES:
+# suggest_duplicates:
+# buckinghamshire: 1
+# oxfordshire: 1
+COBRAND_FEATURES: ''
+
# How many items are returned in the GeoRSS and Open311 feeds by default
RSS_LIMIT: '20'
OPEN311_LIMIT: 1000
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index a8146128e..a08a8dff7 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -59,6 +59,21 @@ sub path_to_email_templates {
return $paths;
}
+=item feature
+
+A helper utility to let you provide per-cobrand hooks for configuration.
+Mostly useful if running a site with multiple cobrands.
+
+=cut
+
+sub feature {
+ my ($self, $feature) = @_;
+ my $features = FixMyStreet->config('COBRAND_FEATURES');
+ return unless $features && ref $features eq 'HASH';
+ return unless $features->{$feature} && ref $features->{$feature} eq 'HASH';
+ return $features->{$feature}->{$self->moniker};
+}
+
=item password_minimum_length
Returns the minimum length a password can be set to.
diff --git a/t/cobrand/features.t b/t/cobrand/features.t
new file mode 100644
index 000000000..4b9190d55
--- /dev/null
+++ b/t/cobrand/features.t
@@ -0,0 +1,16 @@
+use FixMyStreet::Test;
+use FixMyStreet::Cobrand;
+
+FixMyStreet::override_config {
+ COBRAND_FEATURES => {
+ foo => { tester => 1 },
+ bar => { default => 1 }
+ }
+}, sub {
+ my $cobrand = FixMyStreet::Cobrand->get_class_for_moniker('default')->new;
+
+ is $cobrand->feature('foo'), undef;
+ is $cobrand->feature('bar'), 1;
+};
+
+done_testing();