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

Helix::Core::Driver::Loader - Helix Framework driver loader.

SYNOPSIS

This code must be placed in one of your application's controllers. For example, in lib/Example/Controller/Default.pm:

    use Helix::Core::Driver::Types;

    sub default : Default
    {
        my $r = Helix::Core::Registry->get_instance;

        if ($r->{"driver"}->is_loaded(DT_TEMPLATE)) 
        {
            $tpl = $r->{"driver"}->get_object(DT_TEMPLATE);
        }
    }

DESCRIPTION

The Helix::Core::Driver::Loader class parses application configuration's drivers section and loads some of them. Driver is loaded if it's at least one mount point defined for it in application configuration. Also, this package provides methods to access loaded drivers and to check if driver is loaded.

The driver being loaded must contain DRIVER_TYPE constant defined to pass loader's validity check. To view all available driver types please refer to Helix::Core::Driver::Types.

The object of Helix::Core::Driver::Loader is mounted in application registry as $r->{"driver"}, so it can be used by any application component.

METHODS

new()

Class constructor. Creates an object and calls the initialization function.

_init()

Class initialization. Parses drivers section from application configuration and loads specified drivers. Each defined driver is included and checked for consistency, exception thrown if any error occurs.

get_config($type)

Returns the driver configuration hashref (that was defined in application configuration). $type - type of the desired driver, all driver types are listed in Helix::Core::Driver::Types.

is_loaded($type)

Checks if a driver of the given $type is loaded (i.e. has at least one mount point in configuration). Returns the number of mount points specified in the application configuration for this driver.

get_mount_points($type)

Returns a reference to the array of mount points specified in the application configuration for the driver of the given $type.

get_class($type)

Returns the class name of a driver of the given $type.

get_params($type)

Returns a reference to the array of driver's initialization parameters, that were defined in application configuration.

get_object($type)

Returns an object of the loaded driver. If driver with given $type isn't loaded undef will be returned.

SEE ALSO

Helix, Helix::Core::Config, Helix::Core::Driver::Types, Helix::Core::Exception::List

LICENSE

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

AUTHOR

Anton Belousov, <abel@cpan.org>

COPYRIGHT

Copyright (c) 2009, Atma 7, http://www.atma7.com