Skip to content

Commit

Permalink
cleaup mvc to use mvc plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedevin committed Dec 4, 2015
1 parent 00895aa commit 97eb49b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 64 deletions.
54 changes: 0 additions & 54 deletions app/tipsy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,5 @@
require_once __DIR__ . '/../vendor/autoload.php';

use Tipsy\Tipsy;

Tipsy::config('../config/*.ini');

Tipsy::router()
->otherwise(function($Request) {

$find = function($page, &$controller, &$posiblePage) {

$pageClass = explode('/',$page);
$controllers = __DIR__.'/../app/controllers/';

foreach ($pageClass as $posiblePage) {
$posiblePages[] = $fullPageNext.'/'.$posiblePage.'.php';
$posiblePages[] = $fullPageNext.'/'.$posiblePage.'/index.php';
$fullPageNext .= '/'.$posiblePage;
}
$posiblePages = array_reverse($posiblePages);

foreach ($posiblePages as $posiblePage) {
if (file_exists($controllers.$posiblePage)) {
$controller = $controllers.$posiblePage;
break;
}
}

return $controller;
};

$find($Request->path(), $controller, $posiblePage);

if (!isset($controller) || !file_exists($controller)) {
$find('home', $controller, $posiblePage);
}

require_once $controller;

$possibleClass = explode('/', substr($posiblePage, 0, strpos($posiblePage, '.')));
$fullPageNext = '\\App\\Controller';

foreach ($possibleClass as $class) {
if (!$class) {
continue;
}

$fullPageNext .= '\\'.ucfirst($class);

if (class_exists($fullPageNext, false)) {
$c = new $fullPageNext(['tipsy' => $this->tipsy()]);
if (method_exists($fullPageNext, 'init')) {
$c->init();
}
}
}
});

Tipsy::run();
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{
"require": {
"arzynik/tipsy": "dev-master"
"arzynik/tipsy": "dev-master",
"arzynik/tipsy-mvc": "dev-master"
},
"autoload": {
"psr-4": {
"App\\": "app/models/"
}
},
"scripts": {
"post-install-cmd": [
"php vendor/arzynik/tipsy-mvc/install.php"
]
}
}
71 changes: 62 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.

0 comments on commit 97eb49b

Please sign in to comment.