saxulum/saxulum-controller-provider

This package is abandoned and no longer maintained. No replacement package was suggested.

A controller registration provider

1.1.0 2013-06-30 11:31 UTC

This package is not auto-updated.

Last update: 2020-09-22 19:10:46 UTC


README

works with plain silex-php

Build Status Total Downloads Latest Stable Version Scrutinizer Code Quality

Features

  • Register Controllers as a Service with container, __construct and method injection
  • register their actions over a static method within the controller

Requirements

  • php >=5.3
  • silex/silex ~1.0

Installation

The ServiceControllerServiceProvider from silex itself is needed!

$app->register(new ServiceControllerServiceProvider());
$app->register(new SaxulumControllerProvider());

Usage

The example controllers ContainerExampleController and ServiceExampleController they implement ControllerRouteInterface

public static function addRoutes(Application $app, $serviceId)
{
    $app
        ->get('/container', $serviceId . ':indexAction')
        ->bind('container_index')
    ;
}
$app['controller.map']
    ->addController()
        ->setNamespace('Saxulum\SaxulumControllerProvider\Controller\ContainerExampleController')
        ->setServiceId('saxulum.saxulumcontrollerprovider.controller.containerinjectcontroller')
        ->setInjectContainer(true)
    ->end()
    ->addController()
        ->setNamespace('Saxulum\SaxulumControllerProvider\Controller\ServiceExampleController')
        ->setServiceId('saxulum.saxulumcontrollerprovider.controller.serviceController')
        ->setInjectionKeys(array('test.data'))
        ->addMethod()
            ->setName('setTestData1')
            ->setInjectionKeys(array('test.data'))
        ->end()
        ->addMethod()
            ->setName('setTestData2')
            ->setInjectionKeys(array('test.data'))
        ->end()
    ->end()
;