Skip to content

Commit

Permalink
Router changes
Browse files Browse the repository at this point in the history
Added possibility for Router to work without rewrite engine on
  • Loading branch information
s3b4stian committed Sep 10, 2016
1 parent 5b603bc commit 8fb0508
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 62 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Features:

* Model View Controller
* Session Managment and Login
* Router
* Routing
* Dependency Injections
* Storage Manager for data base and cache
* PSR4 Autoloader
Expand Down
7 changes: 1 addition & 6 deletions src/Linna/DI/DIResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

class DIResolver
{
//private $class;

private $cache = array();

private $dependencyTree = array();
Expand All @@ -25,13 +23,10 @@ public function __construct()

public function resolve($resolveClass)
{
//$this->class = $class;

$this->buildDependencyTree(0, $resolveClass);

$this->buildObjects();

//return $this->getCache($this->class);
return $this->getCache($resolveClass);
}

Expand Down Expand Up @@ -63,7 +58,7 @@ private function buildObjects()
{
//reverse array for build first required classes
$array = array_reverse($this->dependencyTree);

//deep dependency level
foreach ($array as $key => $value) {

Expand Down
48 changes: 0 additions & 48 deletions src/Linna/Http/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
*/
class Route implements RouteInterface
{
/**
* @var int $typeOfRoute Indicates that route point at controller, method etc...
*
* @deprecated since 0.3.1 After front controller refactor this method become unnecessary
*/
protected $typeOfRoute = null;

/**
* @var string $name Route name
*/
Expand Down Expand Up @@ -59,8 +52,6 @@ class Route implements RouteInterface
*/
protected $param = array();



/**
* Contructor
*
Expand All @@ -81,45 +72,6 @@ public function __construct($name, $method, $model, $view, $controller, $action,
$this->controller = $controller;
$this->action = $action;
$this->param = $param;
//$this->typeOfRoute = $this->type();
}

/**
* Type of route identifiend by a number
* 1 for controller default method
* 2 for controller with custom method
* 3 for controller with custom method passing parameter
*
* @deprecated since 0.3.1 After front controller refactor this method become unnecessary
* @return int Type of route
*/
protected function type()
{
$type = null;

if ($this->controller !== null) {
$type = 1;
}

if ($this->action !== null) {
$type = 2;
}

if (sizeof($this->param) > 0) {
$type = 3;
}

return $type;
}

/**
* Return type of route
*
* @return int Type of route
*/
public function getType()
{
return $this->typeOfRoute;
}

/**
Expand Down
6 changes: 0 additions & 6 deletions src/Linna/Http/RouteInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ interface RouteInterface
*/
public function __construct($name, $method, $model, $view, $controller, $action, $param);

/**
* Return type of route
*
*/
public function getType();

/**
* Return controller
*
Expand Down
7 changes: 6 additions & 1 deletion src/Linna/Http/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class Router
*/
protected $options = array(
'basePath' => '/',
'badRoute' => ''
'badRoute' => '',
'rewriteMode' => false
);

/**
Expand Down Expand Up @@ -198,6 +199,10 @@ protected function buildParam($validRoute)
*/
protected function getCurrentUri($passedUri)
{
if ($this->options['rewriteMode'] === false) {
$passedUri = str_replace('/index.php?/', '', $passedUri);
}

$url = isset($passedUri) ? $passedUri : '/';
$url = filter_var($url, FILTER_SANITIZE_URL);

Expand Down

0 comments on commit 8fb0508

Please sign in to comment.