Skip to content

Commit

Permalink
Improved compatibility to Laravel 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Jan 30, 2017
1 parent 29dc273 commit 00c9696
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 63 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Expand Up @@ -2,14 +2,14 @@ sudo: false
language: php

php:
- 5.5
- 5.6
- 7.0

env:
- LARAVEL_VERSION=5.1.*
- LARAVEL_VERSION=5.2.*
- LARAVEL_VERSION=5.3.*
- LARAVEL_VERSION=5.4.*

before_script:
- composer self-update
Expand All @@ -23,6 +23,3 @@ after_success:

matrix:
fast_finish: true
exclude:
- php: 5.5
env: LARAVEL_VERSION=5.3.*
22 changes: 19 additions & 3 deletions README.md
Expand Up @@ -26,7 +26,10 @@ pages including routing is also available for a quick start.

## Installation or update

This document is for the latest Aimeos Laravel **2016.04 release and later**.
This document is for the latest Aimeos Laravel **2016.10 release and later**.

- Beta release: 2017.01 (Laravel 5.1 to 5.4)
- LTS release: 2016.10 (Laravel 5.1 to 5.3)

If you want to **upgrade between major versions**, please have a look into the
[upgrade guide](https://aimeos.org/docs/Laravel/Upgrade)!
Expand Down Expand Up @@ -191,6 +194,7 @@ Please follow the Laravel documentation to create the necessary code:
* [Laravel 5.1](https://laravel.com/docs/5.1/authentication)
* [Laravel 5.2](https://laravel.com/docs/5.2/authentication)
* [Laravel 5.3](https://laravel.com/docs/5.3/authentication)
* [Laravel 5.4](https://laravel.com/docs/5.4/authentication)

**Note:** You need a route for **/login in Laravel 5.1** too!

Expand All @@ -208,7 +212,7 @@ As a last step, you need to extend the ```boot()``` method of your
```App\Providers\AuthServiceProvider``` class and add the lines to define how
authorization for "admin" is checked in ```app/Providers/AuthServiceProvider.php```.

For Laravel 5.1 and 5.2 you have to use:
For Laravel 5.1/5.2 and Aimeos 2016.x/2017.x you have to use:
```php
public function boot(GateContract $gate)
{
Expand All @@ -220,7 +224,7 @@ public function boot(GateContract $gate)
}
```

In Laravel 5.3 use instead:
For Laravel 5.3 and Aimeos 2016.x use instead:
```php
public function boot()
{
Expand All @@ -232,6 +236,18 @@ public function boot()
}
```

For Laravel 5.3/5.4 and Aimeos 2017.x use instead:
```php
public function boot()
{
// Keep the lines before

Gate::define('admin', function($user, $class, $roles) {
return app( '\Aimeos\Shop\Base\Support' )->checkGroup( $user->id, $roles );
});
}
```

If your `./public` directory isn't writable by your web server, you have to create these
directories:
```
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -37,6 +37,7 @@
"require-dev": {
"mockery/mockery": "~0.9",
"orchestra/testbench": "~3.0",
"orchestra/testbench-browser-kit": "~3.1",
"satooshi/php-coveralls": "dev-master"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/Aimeos/Shop/Controller/AdminController.php
Expand Up @@ -39,7 +39,7 @@ class AdminController extends Controller
public function indexAction( Request $request )
{
if( config( 'shop.authorize', true ) && ( Auth::check() === false
|| $request->user()->can( 'admin', ['admin', 'editor'] ) ) === false
|| $request->user()->can( 'admin', [AdminController::class, ['admin', 'editor']] ) ) === false
) {
return View::make( 'shop::admin.index' );
}
Expand Down
6 changes: 3 additions & 3 deletions src/Aimeos/Shop/Controller/ExtadmController.php
Expand Up @@ -37,7 +37,7 @@ class ExtadmController extends AdminController
public function indexAction( Request $request )
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin']] );
$this->authorize( 'admin', [ExtadmController::class, ['admin']] );
}

$site = Route::input( 'site', Input::get( 'site', 'default' ) );
Expand Down Expand Up @@ -105,7 +105,7 @@ public function indexAction( Request $request )
public function doAction( Request $request )
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin']] );
$this->authorize( 'admin', [ExtadmController::class, ['admin']] );
}

$site = Route::input( 'site', Input::get( 'site', 'default' ) );
Expand All @@ -132,7 +132,7 @@ public function doAction( Request $request )
public function fileAction()
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin']] );
$this->authorize( 'admin', [ExtadmController::class, ['admin']] );
}

$contents = '';
Expand Down
14 changes: 7 additions & 7 deletions src/Aimeos/Shop/Controller/JqadmController.php
Expand Up @@ -35,7 +35,7 @@ class JqadmController extends AdminController
public function fileAction()
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'editor']] );
$this->authorize( 'admin', [JqadmController::class, ['admin', 'editor']] );
}

$contents = '';
Expand Down Expand Up @@ -80,7 +80,7 @@ public function fileAction()
public function copyAction()
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'editor']] );
$this->authorize( 'admin', [JqadmController::class, ['admin', 'editor']] );
}

$cntl = $this->createClient();
Expand All @@ -96,7 +96,7 @@ public function copyAction()
public function createAction()
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'editor']] );
$this->authorize( 'admin', [JqadmController::class, ['admin', 'editor']] );
}

$cntl = $this->createClient();
Expand All @@ -112,7 +112,7 @@ public function createAction()
public function deleteAction()
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'editor']] );
$this->authorize( 'admin', [JqadmController::class, ['admin', 'editor']] );
}

$cntl = $this->createClient();
Expand All @@ -128,7 +128,7 @@ public function deleteAction()
public function getAction()
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'editor']] );
$this->authorize( 'admin', [JqadmController::class, ['admin', 'editor']] );
}

$cntl = $this->createClient();
Expand All @@ -144,7 +144,7 @@ public function getAction()
public function saveAction()
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'editor']] );
$this->authorize( 'admin', [JqadmController::class, ['admin', 'editor']] );
}

$cntl = $this->createClient();
Expand All @@ -160,7 +160,7 @@ public function saveAction()
public function searchAction()
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'editor']] );
$this->authorize( 'admin', [JqadmController::class, ['admin', 'editor']] );
}

$cntl = $this->createClient();
Expand Down
12 changes: 6 additions & 6 deletions src/Aimeos/Shop/Controller/JsonadmController.php
Expand Up @@ -39,7 +39,7 @@ class JsonadmController extends Controller
public function deleteAction( ServerRequestInterface $request )
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'api']] );
$this->authorize( 'admin', [JsonadmController::class, ['admin', 'api']] );
}

return $this->createClient()->delete( $request, new Response() );
Expand All @@ -55,7 +55,7 @@ public function deleteAction( ServerRequestInterface $request )
public function getAction( ServerRequestInterface $request )
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'api', 'editor']] );
$this->authorize( 'admin', [JsonadmController::class, ['admin', 'api', 'editor']] );
}

return $this->createClient()->get( $request, new Response() );
Expand All @@ -71,7 +71,7 @@ public function getAction( ServerRequestInterface $request )
public function patchAction( ServerRequestInterface $request )
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'api']] );
$this->authorize( 'admin', [JsonadmController::class, ['admin', 'api']] );
}

return $this->createClient()->patch( $request, new Response() );
Expand All @@ -87,7 +87,7 @@ public function patchAction( ServerRequestInterface $request )
public function postAction( ServerRequestInterface $request )
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'api']] );
$this->authorize( 'admin', [JsonadmController::class, ['admin', 'api']] );
}

return $this->createClient()->post( $request, new Response() );
Expand All @@ -103,7 +103,7 @@ public function postAction( ServerRequestInterface $request )
public function putAction( ServerRequestInterface $request )
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'api']] );
$this->authorize( 'admin', [JsonadmController::class, ['admin', 'api']] );
}

return $this->createClient()->put( $request, new Response() );
Expand All @@ -119,7 +119,7 @@ public function putAction( ServerRequestInterface $request )
public function optionsAction( ServerRequestInterface $request )
{
if( config( 'shop.authorize', true ) ) {
$this->authorize( 'admin', [['admin', 'api', 'editor']] );
$this->authorize( 'admin', [JsonadmController::class, ['admin', 'api', 'editor']] );
}

return $this->createClient()->options( $request, new Response() );
Expand Down
63 changes: 25 additions & 38 deletions src/Aimeos/Shop/ShopServiceProvider.php
Expand Up @@ -72,59 +72,45 @@ public function boot()
*/
public function register()
{
$this->app->singleton('\Aimeos\Shop\Base\Aimeos', function($app) {
$this->app->singleton('Aimeos\Shop\Base\Aimeos', function($app) {
return new \Aimeos\Shop\Base\Aimeos($app['config']);
});

$this->app->singleton('\Aimeos\Shop\Base\Config', function($app) {
return new \Aimeos\Shop\Base\Config($app['config'], $app['\Aimeos\Shop\Base\Aimeos']);
$this->app->singleton('Aimeos\Shop\Base\Config', function($app) {
return new \Aimeos\Shop\Base\Config($app['config'], $app['Aimeos\Shop\Base\Aimeos']);
});

$this->app->singleton('\Aimeos\Shop\Base\I18n', function($app) {
return new \Aimeos\Shop\Base\I18n($this->app['config'], $app['\Aimeos\Shop\Base\Aimeos']);
$this->app->singleton('Aimeos\Shop\Base\I18n', function($app) {
return new \Aimeos\Shop\Base\I18n($this->app['config'], $app['Aimeos\Shop\Base\Aimeos']);
});

$this->app->singleton('\Aimeos\Shop\Base\Locale', function($app) {
$this->app->singleton('Aimeos\Shop\Base\Locale', function($app) {
return new \Aimeos\Shop\Base\Locale($app['config']);
});

$this->app->singleton('\Aimeos\Shop\Base\Context', function($app) {
return new \Aimeos\Shop\Base\Context($app['session.store'], $app['\Aimeos\Shop\Base\Config'], $app['\Aimeos\Shop\Base\Locale'], $app['\Aimeos\Shop\Base\I18n']);
$this->app->singleton('Aimeos\Shop\Base\Context', function($app) {
return new \Aimeos\Shop\Base\Context($app['session.store'], $app['Aimeos\Shop\Base\Config'], $app['Aimeos\Shop\Base\Locale'], $app['Aimeos\Shop\Base\I18n']);
});

$this->app->singleton('\Aimeos\Shop\Base\Page', function($app) {
return new \Aimeos\Shop\Base\Page($app['config'], $app['\Aimeos\Shop\Base\Aimeos'], $app['\Aimeos\Shop\Base\Context'], $app['\Aimeos\Shop\Base\Locale'], $app['\Aimeos\Shop\Base\View']);
$this->app->singleton('Aimeos\Shop\Base\Page', function($app) {
return new \Aimeos\Shop\Base\Page($app['config'], $app['Aimeos\Shop\Base\Aimeos'], $app['Aimeos\Shop\Base\Context'], $app['Aimeos\Shop\Base\Locale'], $app['Aimeos\Shop\Base\View']);
});

$this->app->singleton('\Aimeos\Shop\Base\Support', function($app) {
return new \Aimeos\Shop\Base\Support($app['\Aimeos\Shop\Base\Context'], $app['\Aimeos\Shop\Base\Locale']);
$this->app->singleton('Aimeos\Shop\Base\Support', function($app) {
return new \Aimeos\Shop\Base\Support($app['Aimeos\Shop\Base\Context'], $app['Aimeos\Shop\Base\Locale']);
});

$this->app->singleton('\Aimeos\Shop\Base\View', function($app) {
return new \Aimeos\Shop\Base\View($app['\Aimeos\Shop\Base\I18n'], $app['\Aimeos\Shop\Base\Support']);
$this->app->singleton('Aimeos\Shop\Base\View', function($app) {
return new \Aimeos\Shop\Base\View($app['Aimeos\Shop\Base\I18n'], $app['Aimeos\Shop\Base\Support']);
});


$this->app['command.aimeos.account'] = $this->app->share(function() {
return new Command\AccountCommand();
});

$this->app['command.aimeos.cache'] = $this->app->share(function() {
return new Command\CacheCommand();
});

$this->app['command.aimeos.jobs'] = $this->app->share(function() {
return new Command\JobsCommand();
});

$this->app['command.aimeos.setup'] = $this->app->share(function() {
return new Command\SetupCommand();
});

$this->commands('command.aimeos.account');
$this->commands('command.aimeos.cache');
$this->commands('command.aimeos.setup');
$this->commands('command.aimeos.jobs');
$this->commands( array(
'Aimeos\Shop\Command\AccountCommand',
'Aimeos\Shop\Command\CacheCommand',
'Aimeos\Shop\Command\SetupCommand',
'Aimeos\Shop\Command\JobsCommand',
) );
}


Expand All @@ -136,10 +122,11 @@ public function register()
public function provides()
{
return array(
'command.aimeos.account', 'command.aimeos.cache', 'command.aimeos.jobs', 'command.aimeos.setup',
'\Aimeos\Shop\Base\Aimeos', '\Aimeos\Shop\Base\I18n', '\Aimeos\Shop\Base\Context',
'\Aimeos\Shop\Base\Config', '\Aimeos\Shop\Base\Locale', '\Aimeos\Shop\Base\View',
'\Aimeos\Shop\Base\Page', '\Aimeos\Shop\Base\Support'
'Aimeos\Shop\Base\Aimeos', 'Aimeos\Shop\Base\I18n', 'Aimeos\Shop\Base\Context',
'Aimeos\Shop\Base\Config', 'Aimeos\Shop\Base\Locale', 'Aimeos\Shop\Base\View',
'Aimeos\Shop\Base\Page', 'Aimeos\Shop\Base\Support',
'Aimeos\Shop\Command\AccountCommand', 'Aimeos\Shop\Command\CacheCommand',
'Aimeos\Shop\Command\SetupCommand', 'Aimeos\Shop\Command\JobsCommand',
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/AimeosTestAbstract.php
@@ -1,6 +1,6 @@
<?php

class AimeosTestAbstract extends Orchestra\Testbench\TestCase
class AimeosTestAbstract extends Orchestra\Testbench\BrowserKit\TestCase
{
protected function getEnvironmentSetUp($app)
{
Expand Down

0 comments on commit 00c9696

Please sign in to comment.