Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Latest commit

 

History

History
74 lines (60 loc) · 2.87 KB

README.md

File metadata and controls

74 lines (60 loc) · 2.87 KB

saxulum controller provider

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()
;