| 1 | package Silki::AppRole::Domain; | ||
| 2 | { | ||
| 3 | $Silki::AppRole::Domain::VERSION = '0.29'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | use Silki::Schema::Domain; | ||
| 11 | |||
| 12 | use Moose::Role; | ||
| 13 | |||
| 14 | has 'domain' => ( | ||
| 15 | is => 'ro', | ||
| 16 | isa => 'Silki::Schema::Domain', | ||
| 17 | lazy => 1, | ||
| 18 | builder => '_build_domain', | ||
| 19 | ); | ||
| 20 | |||
| 21 | sub _build_domain { | ||
| 22 | my $self = shift; | ||
| 23 | |||
| 24 | my $host = $self->request()->uri()->host(); | ||
| 25 | |||
| 26 | my $domain = Silki::Schema::Domain->new( web_hostname => $host ) | ||
| 27 | or die "No domain found for hostname ($host)\n"; | ||
| 28 | |||
| 29 | return $domain; | ||
| 30 | } | ||
| 31 | |||
| 32 | 1; | ||
| 33 | |||
| 34 | # ABSTRACT: Adds $c->domain() to the Catalyst object | ||
| 35 | |||
| 36 | __END__ |