The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

CatalystX::Declare::Keyword::Controller - Declare Catalyst Controllers

SYNOPSIS

controller MyApp::Web::Controller::Example
   extends MyApp::Web::ControllerBase::CRUD
   with    MyApp::Web::ControllerRole::Caching {


    $CLASS->config(option_name => 'value');


    has attr => (is => 'rw', lazy_build => 1);

    method _build_attr { 'Hello World' }


    action base as '';

    final action site, under base {
        $ctx->response->body( $self->attr );
    }
}

DESCRIPTION

This handler module allows the declaration of Catalyst controllers. The controller keyword is an extension of the CatalystX::Declare::Keyword::Component, which in turn is an extension of "class" in MooseX::Declare with all the bells and whistles, including extends, with, method and modifier declarations.

In addition to the keywords and features provided by MooseX::Declare, you can also specify your controller's actions declaratively. For the whole truth about the syntax refer to CatalystX::Declare::Keyword::Action.

For controller roles, please see CatalystX::Declare::Keyword::Role. You can extend controllers with the extends keyword and consume roles via with as usual.

SUPERCLASSES

CatalystX::Declare::Keyword::Component

METHODS

These methods are implementation details. Unless you are extending or developing CatalystX::Declare, you should not be concerned with them.

add_namespace_customizations

Object->add_namespace_customizations (Object $ctx, Str $package)

This method modifier will initialise the controller with MooseX::MethodAttributes and add the CatalystX::Declare::Controller::ActionPreparation and CatalystX::Declare::Controller::DetermineActionClass controller roles before calling the original.

default_superclasses

Str Object->default_superclasses ()

Returns Catalyst::Controller as the default superclass for all declared controllers.

add_with_option_customizations

Object->add_with_option_customizations (
    Object   $ctx,
    Str      $package,
    ArrayRef $roles,
    HashRef  $options,
)

This hook method will be called by MooseX::Declare when with options were encountered. Since 0.011 the roles will be applied all at once.

This method will also add a callback to make the controller immutable to the cleanup code parts unless is mutable was specified.

auto_make_immutable

Bool Object->auto_make_immutable ()

Returns 0, indicating that MooseX::Declare should not make this class immutable by itself. We will do that in the "add_with_option_customizations" method ourselves.

default_inner

ArrayRef[Object] Object->default_inner ()

A method modifier around the original. The inner syntax handlers inherited by MooseX::Declare::Syntax::Keyword::Class are extended with instances of the CatalystX::Declare::Keyword::Action handler class for the action, under and final identifiers.

SEE ALSO

CatalystX::Declare
CatalystX::Declare::Keyword::Action
CatalystX::Declare::Keyword::Component
"class" in MooseX::Declare

AUTHOR

See "AUTHOR" in CatalystX::Declare for author information.

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as perl itself.