Beispiel #1
0
 /**
  * Sets dependencies.
  *
  * @param object $router
  * @param object $view
  * @param object $loader
  */
 public function __construct(Interfaces\Router $router, Interfaces\View $view, $loader)
 {
     $this->Router = $router;
     $this->View = $view;
     $this->Loader = $loader;
     $this->theme = \Tinker\Configure::read('theme');
     $this->layout = \Tinker\Configure::read('layout');
 }
Beispiel #2
0
 /**
  * Parse out the URI to determine the MVC routing
  * 0 /main/main/index
  * 1 /[plugin]/[plugin]/index
  * 2 /[plugin]/[controller]/index
  * 3 /[plugin]/[controller]/[action]
  * 4 /[plugin]/[controller]/[action]/[params]
  * Any params not falling into on of the above categories will be added as
  * named or numbered params
  *
  * @param string $requestUri Represents the URI to be parsed
  */
 public function parseUri($requestUri)
 {
     //Parse each URI segment into it's own element then remove all elements
     //with an empty value.
     $uriSegments = array_filter(explode('/', $requestUri));
     $uriLegnth = count($uriSegments);
     switch ($uriLegnth) {
         case 0:
             $this->setPlugin(\Tinker\Configure::read('plugin'));
             $this->setController(\Tinker\Configure::read('controller'));
             $this->setAction('index');
             break;
         case 1:
             $this->setPlugin($uriSegments[1]);
             $this->setController($uriSegments[1]);
             $this->setAction('index');
             break;
         case 2:
             $this->setPlugin($uriSegments[1]);
             $this->setController($uriSegments[2]);
             $this->setAction('index');
             break;
         case 3:
             $this->setPlugin($uriSegments[1]);
             $this->setController($uriSegments[2]);
             $this->setAction($uriSegments[3]);
             break;
             //Greater than 3
         //Greater than 3
         default:
             $this->setPlugin($uriSegments[1]);
             $this->setController($uriSegments[2]);
             $this->setAction($uriSegments[3]);
             $this->setParams(array_slice($uriSegments, 3));
             break;
     }
 }
 public function testSetsVar()
 {
     $this->assertTrue(empty(\Tinker\Configure::read('foo')));
     \Tinker\Configure::write('foo', 'bar');
     $this->assertSame('bar', \Tinker\Configure::read('foo'));
 }