Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin de Graaf committed May 29, 2016
2 parents 889e564 + ea976c0 commit 7bbcfca
Show file tree
Hide file tree
Showing 41 changed files with 913 additions and 776 deletions.
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
# Parable PHP Framework Changelog

### 0.7.0

__Note: This version breaks backwards compatibility!__

__Changes__
- Since SessionMessage depends on an instantiated & set to 'session' resource GetSet, it shouldn't be a Component. It's been moved to \Devvoh\Parable. Because this means a namespace change, it's yet another minor version bump. Goes quickly.
- To make the module Routes file simpler, the more framework-y functionality (DI & the module adding) has been moved to a new class - \Devvoh\Parable\Routes. This means yet another backwards incompatible change. I'm on a roll.
- Comments have been improved significantly. Handy.
- index.phtml mapped $this to \Devvoh\Parable\App, but it should now map to \Devvoh\Parable\View
- The magic methods in \Devvoh\Parable\View are gone again. Though they worked fine, they felt out of place and inconsistent with how the rest of Parable now approaches its DI components. They've been replaced with magic properties that do the exact same thing. In a view, you can use $this->tool->method(), etc.
- set_exception_handler function has been moved up, so it will also catch Autoloader/DI exceptions.
- Property definitions now no longer explicitly set to null. Order of properties has been made consistent: DI properties > defined properties > undefined properties.
- Some small fixes where false was being returned where a value was expected. These now return null.
- Vestigial properties have been removed from App, since the functionality has been moved to Tool.
- Session management methods have been moved to \Devvoh\Parable\Session and out of \Devvoh\Components\GetSet, as they should be.
- SessionMessage has lost initSession and gained a DI.
- Cli has been reworked, now offers cll (clear line), cr (return to beginning of line) as well as colors.

### 0.6.0

__Note: This version significantly breaks backwards compatibility!__

__Changes__
- APP IS DEAD. ALL HAIL APP.
- Because App is gone, much of the changelog of 0.5.0 is redundant, but I leave it for historical purposes.
- Because App is gone, much of the changelog of 0.5.0 is redundant, but I have included what's still relevant.
- \Devvoh\Components\DI has been added. This is why App could go. Parable now has a barebones dependency injection system and uses it throughout. It attempts to keep track of class dependency hierarchy to prevent cyclical references. It should throw an Exception when A requires B requires A...etc.
- Views now can no longer simply re-route all function calls to App. Therefore, magic methods have been added to \Devvoh\Parable\View to allow the ->getXXX calls to still work (they now go through DI, though), and really only affects the methods previously directly called on App (getUrl, createRepository, etc.), which are almost all moved to \Devvoh\Parable\Tool
- Although this major refactor has been tested (and found to work correctly) on one project, it's entirely possible bugs may still be hidden.
Expand All @@ -26,6 +44,7 @@ __Changes__
- Added ->returnOne() and ->returnAll() to Repository, which will return the first result only, preventing the need for either manual current() calls or [0].
- In Repository, orderBy and limit are now implemented on getQuery, which enables it everywhere.
- All Cli functionality removed until Cli has been refactored.
- Training wheels are off. Soft requirement for parameters (returning falls on required parameter null values) is out and hard requirements are in. Also made type hinting more strict. In some cases, it's no longer possible to pass either a string or an array, casting the string to array, it'll always need an array instead.

__Bugfixes__
- GetSet no longer resets the localResource when using setResource. Not only does this fix a bug where using setResource multiple times would clear it every time, it also makes it possible to use, for example, App::getParam()->setResource('headerJs')->getAll(). This makes Param even more powerful and useful. Param does, however, remember the last set resource, so switching is necessary whenever you want a different resource.
Expand Down
3 changes: 1 addition & 2 deletions app/modules/App/Controller/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
class Home {

public function index() {
/** Doesn't need anything if there's just a view */
}

}
}
6 changes: 5 additions & 1 deletion app/modules/App/Init/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class Hooks {

/** @var int */
public $order = 1;

/** @var \Devvoh\Components\Hook */
Expand All @@ -30,6 +31,9 @@ public function __construct(
$this->log = $log;
}

/**
* This function is automatically executed when inits are loaded at the end of $app->boot();
*/
public function run() {
// Register global loop to log all triggers
$this->hook->into('*', function($event) {
Expand All @@ -47,4 +51,4 @@ public function run() {
});
}

}
}
23 changes: 18 additions & 5 deletions app/modules/App/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,28 @@

class User extends \Devvoh\Parable\Entity {

protected $tableName = 'users';
protected $tableKey = 'id';
/** @var string */
protected $tableName = 'users';

/** @var string */
protected $tableKey = 'id';

/** @var array */
protected $exportable = ['id', 'email', 'created_at', 'updated_at'];

/** @var int */
public $id;

/** @var string */
public $email;

/** @var string */
public $password;

/** @var string */
public $created_at;
public $updated_at;

protected $exportable = ['id', 'email', 'created_at', 'updated_at'];
/** @var string */
public $updated_at;

}
}
33 changes: 4 additions & 29 deletions app/modules/App/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,12 @@

namespace App;

class Routes {

/** @var \Devvoh\Parable\Tool */
protected $tool;

/** @var \Devvoh\Components\Router */
protected $router;

/**
* @param \Devvoh\Parable\Tool $tool
* @param \Devvoh\Components\Router $router
*/
public function __construct(
\Devvoh\Parable\Tool $tool,
\Devvoh\Components\Router $router
) {
$this->tool = $tool;
$this->router = $router;

$this->registerRoutes();
}
class Routes extends \Devvoh\Parable\Routes {

/**
*
* This function is automatically called when the routes are being loaded
*/
protected function registerRoutes() {
public function run() {
$routes = [
'index' => [
'method' => 'GET',
Expand All @@ -49,12 +29,7 @@ protected function registerRoutes() {
},
],
];

// Add module to all routes
foreach ($routes as &$route) {
$route['module'] = $this->tool->getModuleFromPath(__DIR__);
}
$this->router->addRoutes($routes);
$this->registerRoutes($routes, __DIR__);
}

}
Expand Down
1 change: 1 addition & 0 deletions app/modules/App/View/Error/404.phtml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<?php /** @var $this \Devvoh\Parable\View */ ?>
#404, can't find page
1 change: 1 addition & 0 deletions app/modules/App/View/Error/Route.phtml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<?php /** @var $this \Devvoh\Parable\View */ ?>
Route found but there\'s something wrong. Possibly the controller or action doesn't exist.
6 changes: 2 additions & 4 deletions app/modules/App/View/Home/index.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php
/** @var $this \Devvoh\Parable\App */
?>
<?php /** @var $this \Devvoh\Parable\View */ ?>
<!DOCTYPE HTML>
<html>
<head>
Expand All @@ -13,7 +11,7 @@

<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />

<link rel="icon" type="image/png" href="./images/icon-32.png" />
<link rel="icon" type="image/png" href="<?=$this->tool->getUrl('images/icon-32.png');?>" />

<style>
* {
Expand Down
11 changes: 1 addition & 10 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@
* @author Robin de Graaf ([email protected])
*/

/**
* Include Bootstrap.php to enable all functionality.
*
* This will set all base values and allow use of all App->methods
*/
/** @var \Devvoh\Parable\App $app */
$app = require_once('../vendor/Devvoh/Parable/Bootstrap.php');

/**
* Dispatch the current route.
*/
$app->dispatch();
$app->dispatch();
4 changes: 3 additions & 1 deletion vendor/Devvoh/Components/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function register() {
* Add a location to the stack
*
* @param string $location
*
* @return $this
*/
public function addLocation($location) {
Expand All @@ -47,6 +48,7 @@ public function getLocations() {
* Attempts to load the class if it exists
*
* @param string $class
*
* @return bool
*/
public function load($class) {
Expand All @@ -64,4 +66,4 @@ public function load($class) {
return false;
}

}
}
Loading

0 comments on commit 7bbcfca

Please sign in to comment.