aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-08-22 10:57:10 +0100
committerStruan Donald <struan@exo.org.uk>2012-08-22 10:57:10 +0100
commit2e0a4e8ec45579e4e5c9cf8aa123d5ab215b9703 (patch)
treec13e3c59b686e01460dc7960547f7e9c53c288bd /perllib/FixMyStreet/Cobrand.pm
parentb99c5ff97b29a27eeba52ed24385ac30388e875c (diff)
parent88a7d38dffa3dabdf0f85573b254cea9c8ab232b (diff)
Merge remote-tracking branch 'origin/master' into fmb-read-only
Conflicts: .gitignore bin/make_css conf/general.yml-example perllib/FixMyStreet/App/Controller/Council.pm perllib/FixMyStreet/App/Controller/Report/New.pm perllib/FixMyStreet/Cobrand/Default.pm templates/web/default/around/around_index.html templates/web/default/index.html templates/web/emptyhomes/index.html templates/web/fixmystreet/around/around_index.html templates/web/fixmystreet/index.html web/fixmystreet_app_cgi.cgi web/fixmystreet_app_fastcgi.cgi
Diffstat (limited to 'perllib/FixMyStreet/Cobrand.pm')
-rw-r--r--perllib/FixMyStreet/Cobrand.pm28
1 files changed, 21 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/Cobrand.pm b/perllib/FixMyStreet/Cobrand.pm
index b88f6facc..881183463 100644
--- a/perllib/FixMyStreet/Cobrand.pm
+++ b/perllib/FixMyStreet/Cobrand.pm
@@ -38,7 +38,7 @@ Simply returns the config variable (so this function can be overridden in test s
=cut
sub _get_allowed_cobrands {
- return FixMyStreet->config('ALLOWED_COBRANDS');
+ return FixMyStreet->config('ALLOWED_COBRANDS') || [];
}
=head2 available_cobrand_classes
@@ -46,9 +46,9 @@ sub _get_allowed_cobrands {
@available_cobrand_classes =
FixMyStreet::Cobrand->available_cobrand_classes();
-Return an array of all the classes that were found and that have monikers
-that match the values from get_allowed_cobrands, in the order of
-get_allowed_cobrands.
+Return an array of all the classes from get_allowed_cobrands, in
+the order of get_allowed_cobrands, with added class information
+for those that have found classes.
=cut
@@ -58,7 +58,7 @@ sub available_cobrand_classes {
my %all = map { $_->moniker => $_ } @ALL_COBRAND_CLASSES;
my @avail;
foreach (@{ $class->get_allowed_cobrands }) {
- next unless $all{$_->{moniker}};
+ #next unless $all{$_->{moniker}};
$_->{class} = $all{$_->{moniker}};
push @avail, $_;
}
@@ -66,6 +66,20 @@ sub available_cobrand_classes {
return @avail;
}
+=head2 class
+
+=cut
+
+sub class {
+ my $avail = shift;
+ return $avail->{class} if $avail->{class};
+ my $moniker = $avail->{moniker};
+ Class::MOP::Class->create("FixMyStreet::Cobrand::$moniker" => (
+ superclasses => [ 'FixMyStreet::Cobrand::Default' ],
+ ));
+ return "FixMyStreet::Cobrand::$moniker";
+}
+
=head2 get_class_for_host
$cobrand_class = FixMyStreet::Cobrand->get_class_for_host( $host );
@@ -79,7 +93,7 @@ sub get_class_for_host {
my $host = shift;
foreach my $avail ( $class->available_cobrand_classes ) {
- return $avail->{class} if $host =~ /$avail->{host}/;
+ return class($avail) if $host =~ /$avail->{host}/;
}
# if none match then use the default
@@ -99,7 +113,7 @@ sub get_class_for_moniker {
my $moniker = shift;
foreach my $avail ( $class->available_cobrand_classes ) {
- return $avail->{class} if $moniker eq $avail->{moniker};
+ return class($avail) if $moniker eq $avail->{moniker};
}
# Special case for old blank cobrand entries in fixmystreet.com.