Skip to content

Commit

Permalink
Use ICanBoogie\Application
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Nov 12, 2016
1 parent 034a3d8 commit 2739b4a
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 24 deletions.
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -9,8 +9,8 @@

The **icanboogie/bind-routing** package binds [icanboogie/routing][] to [ICanBoogie][].

The package adds the getter `routes` to the [Core][] instance, a `url_for()` method that creates
URLs, and a synthesizer for the `routes` configuration fragments.
The package adds the getter `routes` to the [Application][] instance, a `url_for()` method that
creates URLs, and a synthesizer for the `routes` configuration fragments.

```php
<?php
Expand All @@ -31,6 +31,7 @@ $config = $app->configs['routes'];
# Get the route collection and add a new route
#

use ICanBoogie\HTTP\Request;
use ICanBoogie\Routing\RouteDefinition;

$app->routes->get('/hello', function(Request $request) {
Expand Down Expand Up @@ -227,7 +228,7 @@ The package is continuously tested by [Travis CI](http://about.travis-ci.org/).
[icanboogie/icanboogie]: https://github.com/ICanBoogie/ICanBoogie
[icanboogie/routing]: https://github.com/ICanBoogie/Routing
[ICanBoogie]: https://github.com/ICanBoogie/ICanBoogie
[Core]: http://api.icanboogie.org/icanboogie/4.0/class-ICanBoogie.Core.html
[Application]: http://api.icanboogie.org/icanboogie/4.0/class-ICanBoogie.Core.html
[documentation]: http://api.icanboogie.org/bind-routing/4.0/
[BeforeSynthesizeRoutesEvent]: http://api.icanboogie.org/bind-routing/4.0/class-ICanBoogie.Binding.Routing.BeforeSynthesizeRoutesEvent.html
[SynthesizeRoutesEvent]: http://api.icanboogie.org/bind-routing/4.0/class-ICanBoogie.Binding.Routing.SynthesizeRoutesEvent.html
4 changes: 2 additions & 2 deletions lib/CoreBindings.php → lib/ApplicationBindings.php
Expand Up @@ -14,7 +14,7 @@
use ICanBoogie\Routing\RouteCollection;

/**
* {@link \ICanBoogie\Core} bindings.
* {@link \ICanBoogie\Application} bindings.
*
* @method string url_for($route_or_route_id, $values = null) Returns the contextualized URL of a route.
*
Expand All @@ -23,7 +23,7 @@
* @see \ICanBoogie\Binding\Routing\Hooks::url_for()
* @see \ICanBoogie\Binding\Routing\Hooks::get_routes()
*/
trait CoreBindings
trait ApplicationBindings
{

}
4 changes: 2 additions & 2 deletions lib/ControllerBindings.php
Expand Up @@ -11,12 +11,12 @@

namespace ICanBoogie\Binding\Routing;

use ICanBoogie\Core;
use ICanBoogie\Application;

/**
* {@link \ICanBoogie\Routing\Controller} prototype bindings.
*
* @property-read Core $app
* @property-read Application $app
*/
trait ControllerBindings
{
Expand Down
13 changes: 11 additions & 2 deletions lib/ForwardUndefinedPropertiesToApplication.php
@@ -1,8 +1,17 @@
<?php

/*
* This file is part of the ICanBoogie package.
*
* (c) Olivier Laviale <olivier.laviale@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace ICanBoogie\Binding\Routing;

use ICanBoogie\Core;
use ICanBoogie\Application;
use ICanBoogie\PropertyNotDefined;
use ICanBoogie\Routing\RouteCollection;

Expand All @@ -12,7 +21,7 @@
* **Note:** This trait is to be used by classes extending
* {@link \ICanBoogie\Accessor\AccessorTrait}.
*
* @property Core $app
* @property Application $app
* @property-read RouteCollection $routes
*/
trait ForwardUndefinedPropertiesToApplication
Expand Down
12 changes: 5 additions & 7 deletions lib/Hooks.php
Expand Up @@ -11,12 +11,10 @@

namespace ICanBoogie\Binding\Routing;

use ICanBoogie\Core;
use ICanBoogie\HTTP\RequestDispatcher;
use ICanBoogie\Application;
use ICanBoogie\Routing\ControllerNotDefined;
use ICanBoogie\Routing\Route;
use ICanBoogie\Routing\RouteDefinition;
use ICanBoogie\Routing\RouteDispatcher;
use ICanBoogie\Routing\PatternNotDefined;
use ICanBoogie\Routing\RouteCollection;

Expand Down Expand Up @@ -68,11 +66,11 @@ static public function synthesize_routes_config(array $fragments)
/**
* Returns the route collection.
*
* @param Core|CoreBindings $app
* @param Application $app
*
* @return RouteCollection
*/
static public function get_routes(Core $app)
static public function get_routes(Application $app)
{
static $routes;

Expand All @@ -83,13 +81,13 @@ static public function get_routes(Core $app)
/**
* Returns the contextualized URL of a route.
*
* @param Core|CoreBindings $app
* @param Application $app
* @param string|Route $route
* @param array|object|null $values
*
* @return string
*/
static public function url_for(Core $app, $route, $values = null)
static public function url_for(Application $app, $route, $values = null)
{
if (!$route instanceof Route)
{
Expand Down
4 changes: 2 additions & 2 deletions lib/RouteDispatcherConstructor.php
Expand Up @@ -11,8 +11,8 @@

namespace ICanBoogie\Binding\Routing;

use ICanBoogie\Application;
use ICanBoogie\Binding\HTTP\AbstractDispatcherConstructor;
use ICanBoogie\Core;
use ICanBoogie\Routing\RouteDispatcher;

/**
Expand All @@ -21,7 +21,7 @@
class RouteDispatcherConstructor extends AbstractDispatcherConstructor
{
/**
* @var Core|CoreBindings
* @var Application
*/
protected $app;

Expand Down
Expand Up @@ -11,11 +11,12 @@

namespace ICanBoogie\Binding\Routing;

use ICanBoogie\Application;
use ICanBoogie\Routing\RouteCollection;

use function ICanBoogie\app;

class CoreBindingsTest extends \PHPUnit_Framework_TestCase
class ApplicationBindingsTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Application
Expand Down
4 changes: 2 additions & 2 deletions tests/HooksTest.php
Expand Up @@ -11,8 +11,8 @@

namespace ICanBoogie\Binding\Routing;

use ICanBoogie\Application;
use ICanBoogie\HTTP\Request;
use ICanBoogie\HTTP\RequestDispatcher;
use ICanBoogie\Routing\RouteCollection;
use ICanBoogie\Routing\RouteDefinition;
use ICanBoogie\Routing\RouteDispatcher;
Expand All @@ -23,7 +23,7 @@
class HooksTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \ICanBoogie\Core|CoreBindings
* @var Application
*/
static private $app;

Expand Down
6 changes: 3 additions & 3 deletions tests/RoutingDispatcherConstructorTest.php
Expand Up @@ -11,7 +11,7 @@

namespace ICanBoogie\Binding\Routing;

use ICanBoogie\Core;
use ICanBoogie\Application;
use ICanBoogie\Routing\RouteCollection;
use ICanBoogie\Routing\RouteDispatcher;

Expand All @@ -27,11 +27,11 @@ public function test_construct()
}

/**
* @return Core
* @return Application
*/
private function mockApp()
{
$app = $this->getMockBuilder(Core::class)
$app = $this->getMockBuilder(Application::class)
->disableOriginalConstructor()
->setMethods([ 'get_routes' ])
->getMock();
Expand Down
5 changes: 5 additions & 0 deletions tests/bootstrap.php
Expand Up @@ -13,4 +13,9 @@

require __DIR__ . '/../vendor/autoload.php';

class Application extends Core
{

}

boot();

0 comments on commit 2739b4a

Please sign in to comment.