PHP Classes

File: JLaso/SlimRoutingManager/Controller/Controller.php

Recommend this page to a friend!
  Classes of Joseluis Laso   Slim Routing Manager   JLaso/SlimRoutingManager/Controller/Controller.php   Download  
File: JLaso/SlimRoutingManager/Controller/Controller.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Slim Routing Manager
Read routes from controller class annotations
Author: By
Last change: Update of JLaso/SlimRoutingManager/Controller/Controller.php
Date: 12 days ago
Size: 869 bytes
 

Contents

Class file image Download
<?php

namespace JLaso\SlimRoutingManager\Controller;

use
Slim\Slim;

abstract class
Controller
{
    protected
$slimInstance;

    function
__construct()
    {
       
$this->slimInstance = Slim::getInstance();
    }

    public static function
__callStatic($name, $arguments)
    {
       
$calledClass = get_called_class();
       
$obj = new $calledClass;
       
$name = preg_replace('/^___/','',$name);
       
call_user_func_array(array($obj, $name), $arguments);
    }

   
/**
     * @return Slim
     */
   
protected function getSlim()
    {
        return
$this->slimInstance;
    }

   
/**
     * Returns the logic name of the current route that are currently processed by Slim
     *
     * @return string
     */
   
protected function getName()
    {
        return
$this->slimInstance->router()->getCurrentRoute()->getName();
    }

}