diff --git a/app/tipsy.php b/app/tipsy.php index 2d30ef3..8c28009 100644 --- a/app/tipsy.php +++ b/app/tipsy.php @@ -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(); diff --git a/composer.json b/composer.json index 28753c7..0338e1c 100644 --- a/composer.json +++ b/composer.json @@ -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" + ] } } diff --git a/composer.lock b/composer.lock index 092a9eb..2af6157 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "9479f3014ec494c60b5aaa2db938f64c", - "content-hash": "df7eb7062155ccf15dee7598bda32ef4", + "hash": "074507bb87a09101accc107e4d88f204", + "content-hash": "0276c0948095fc2b2afcf12bb755bcd3", "packages": [ { "name": "arzynik/tipsy", @@ -13,12 +13,12 @@ "source": { "type": "git", "url": "https://github.com/arzynik/tipsy.git", - "reference": "591cb1daff683ca544ee3bec48615834af8f15c5" + "reference": "c0e6893d6b86dd49feb686a9eadfde8927836311" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/arzynik/tipsy/zipball/591cb1daff683ca544ee3bec48615834af8f15c5", - "reference": "591cb1daff683ca544ee3bec48615834af8f15c5", + "url": "https://api.github.com/repos/arzynik/tipsy/zipball/c0e6893d6b86dd49feb686a9eadfde8927836311", + "reference": "c0e6893d6b86dd49feb686a9eadfde8927836311", "shasum": "" }, "require": { @@ -29,8 +29,8 @@ }, "type": "library", "autoload": { - "psr-0": { - "Tipsy": "src/" + "psr-4": { + "Tipsy\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -52,14 +52,67 @@ "mvw", "php" ], - "time": "2015-12-04 15:22:26" + "time": "2015-12-04 19:26:53" + }, + { + "name": "arzynik/tipsy-mvc", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/arzynik/tipsy-mvc.git", + "reference": "d65d9be31a6e76fa3cc9b7e6ef72d4187b8eb9fd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/arzynik/tipsy-mvc/zipball/d65d9be31a6e76fa3cc9b7e6ef72d4187b8eb9fd", + "reference": "d65d9be31a6e76fa3cc9b7e6ef72d4187b8eb9fd", + "shasum": "" + }, + "require": { + "arzynik/tipsy": "dev-master", + "php": ">=5.4.0" + }, + "require-dev": { + "satooshi/php-coveralls": "dev-master" + }, + "type": "library", + "autoload": { + "psr-4": { + "Tipsy\\MVC\\": "src/" + }, + "files": [ + "src/Run.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Devin Smith", + "email": "devin@tipsy.la", + "homepage": "http://devin.la", + "role": "Developer" + } + ], + "description": "An MVC extension for Tipsy", + "keywords": [ + "extension", + "framework", + "mvc", + "php", + "plugin" + ], + "time": "2015-12-04 22:53:31" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": { - "arzynik/tipsy": 20 + "arzynik/tipsy": 20, + "arzynik/tipsy-mvc": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/config/tipsy.ini b/config/config.ini similarity index 100% rename from config/tipsy.ini rename to config/config.ini