Skip to content

Commit

Permalink
Merge pull request #3 from ARCANESOFT/develop
Browse files Browse the repository at this point in the history
Adding Laravel 5.4 Support
  • Loading branch information
arcanedev-maroc authored Feb 2, 2017
2 parents afb9498 + f6d53ea commit bdd6618
Show file tree
Hide file tree
Showing 15 changed files with 254 additions and 47 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/build/
/vendor/
/_ide_helper.php
/composer.lock
/composer.phar
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ checks:
tools:
external_code_coverage:
timeout: 600
runs: 2
runs: 3
php_code_sniffer:
enabled: true
config:
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ matrix:
- php: nightly

env:
- TESTBENCH_VERSION=3.3.*
- TESTBENCH_VERSION=3.4.*

before_script:
- travis_retry composer self-update
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 ARCANEDEV <[email protected]> - Media For ARCANESOFT
Copyright (c) 2016-2017 ARCANEDEV <[email protected]> - Media For ARCANESOFT

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
"license": "MIT",
"require": {
"php": ">=5.6.4",
"arcanesoft/auth": "~1.0",
"arcanesoft/core": "~1.4",
"intervention/image": "~2.0"
"arcanesoft/auth": "~2.0",
"arcanesoft/core": "~1.5",
"intervention/image": "~2.3"
},
"require-dev": {
"phpunit/phpcov": "~3.0",
"phpunit/phpunit": "~5.0"
"phpunit/phpunit": "~5.0",
"orchestra/testbench": "~3.4.0"
},
"autoload": {
"psr-4": {
Expand All @@ -36,7 +37,7 @@
}
},
"scripts": {
"testbench": "composer require --dev \"orchestra/testbench=~3.3.0\""
"testbench": "composer require --dev \"orchestra/testbench=~3.4.0\""
},
"extra": {
"branch-alias": {
Expand Down
30 changes: 30 additions & 0 deletions src/Contracts/Media.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php namespace Arcanesoft\Media\Contracts;

/**
* Interface Media
*
* @package Arcanesoft\Media\Contracts
* @author ARCANEDEV <[email protected]>
*/
interface Media
{
/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Get a filesystem adapter.
*
* @param string|null $driver
*
* @return \Illuminate\Contracts\Filesystem\Filesystem
*/
public function disk($driver = null);

/**
* Get the default filesystem adapter.
*
* @return \Illuminate\Contracts\Filesystem\Filesystem
*/
public function defaultDisk();
}
4 changes: 2 additions & 2 deletions src/Http/Controllers/Admin/Controller.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Arcanesoft\Media\Http\Controllers\Admin;

use Arcanesoft\Core\Bases\AdminController as BaseController;
use Arcanesoft\Core\Http\Controllers\AdminController;
use Arcanesoft\Core\Traits\Notifyable;

/**
Expand All @@ -9,7 +9,7 @@
* @package Arcanesoft\Media\Http\Controllers\Admin
* @author ARCANEDEV <[email protected]>
*/
abstract class Controller extends BaseController
abstract class Controller extends AdminController
{
/* ------------------------------------------------------------------------------------------------
| Traits
Expand Down
6 changes: 3 additions & 3 deletions src/Http/Controllers/Admin/MediasController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function uploadMedia(Request $request)
public function createDirectory(Request $request)
{
$data = $request->all();
$validator = \Validator::make($data, [
$validator = validator($data, [
'name' => 'required', // TODO: check if the folder does not exists
'location' => 'required',
]);
Expand All @@ -103,7 +103,7 @@ public function renameMedia(Request $request)
$data = $request->all();

// TODO: check if the folder does not exists
$validator = \Validator::make($data, [
$validator = validator($data, [
'media' => 'required',
'newName' => 'required',
'location' => 'required',
Expand All @@ -117,7 +117,7 @@ public function renameMedia(Request $request)

$location = trim($data['location'], '/');
$media = $data['media'];
$src = $location . '/' . $media['name'];
$src = $location . '/' . $media['name'];

if ($media['type'] == 'file') {
$ext = pathinfo($media['url'], PATHINFO_EXTENSION);
Expand Down
39 changes: 39 additions & 0 deletions src/Http/Routes/Admin/ApiRoutes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php namespace Arcanesoft\Media\Http\Routes\Admin;

use Arcanedev\Support\Routing\RouteRegistrar;

/**
* Class ApiRoutes
*
* @package Arcanesoft\Media\Http\Routes\Admin
* @author ARCANEDEV <[email protected]>
*/
class ApiRoutes extends RouteRegistrar
{
/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Map routes.
*/
public function map()
{
$this->prefix('api')->name('api.')->group(function () {
$this->get('all', 'MediasController@getAll')
->name('get'); // admin::media.api.get

$this->post('upload', 'MediasController@uploadMedia')
->name('upload'); // admin::media.api.upload

$this->post('rename', 'MediasController@renameMedia')
->name('rename'); // admin::media.api.rename

$this->post('delete', 'MediasController@deleteMedia')
->name('delete'); // admin::media.api.delete

$this->post('create', 'MediasController@createDirectory')
->name('create'); // admin::media.api.create
});
}
}
35 changes: 5 additions & 30 deletions src/Http/Routes/Admin/MediaRoutes.php
Original file line number Diff line number Diff line change
@@ -1,50 +1,25 @@
<?php namespace Arcanesoft\Media\Http\Routes\Admin;

use Arcanedev\Support\Bases\RouteRegister;
use Illuminate\Contracts\Routing\Registrar;
use Arcanedev\Support\Routing\RouteRegistrar;

/**
* Class MediaRoutes
*
* @package Arcanesoft\Media\Http\Routes
* @author ARCANEDEV <[email protected]>
*/
class MediaRoutes extends RouteRegister
class MediaRoutes extends RouteRegistrar
{
/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Map routes.
*
* @param \Illuminate\Contracts\Routing\Registrar $router
*/
public function map(Registrar $router)
public function map()
{
// media::foundation.index
$this->get('/', 'MediasController@index')->name('index');

$this->registerApiRoutes();
}

/**
* Register the media api routes.
*/
private function registerApiRoutes()
{
// TODO: Adding ajax middleware
$this->group(['prefix' => 'api', 'as' => 'api.'], function () {
// admin::media.api.get
$this->get('all', 'MediasController@getAll')->name('get');
// admin::media.api.upload
$this->post('upload', 'MediasController@uploadMedia')->name('upload');
// admin::media.api.delete
$this->post('rename', 'MediasController@renameMedia')->name('rename');
// admin::media.api.delete
$this->post('delete', 'MediasController@deleteMedia')->name('delete');
// admin::media.api.create
$this->post('create', 'MediasController@createDirectory')->name('create');
});
$this->get('/', 'MediasController@index')
->name('index'); // media::foundation.index
}
}
90 changes: 90 additions & 0 deletions src/Media.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php namespace Arcanesoft\Media;

use Arcanesoft\Media\Contracts\Media as MediaContract;
use Illuminate\Contracts\Foundation\Application;

/**
* Class Media
*
* @package Arcanesoft\Media
* @author ARCANEDEV <[email protected]>
*/
class Media implements MediaContract
{
/* ------------------------------------------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
*/
/**
* The application instance.
*
* @var \Illuminate\Contracts\Foundation\Application
*/
protected $app;

/* ------------------------------------------------------------------------------------------------
| Constructor
| ------------------------------------------------------------------------------------------------
*/
/**
* Media constructor.
*
* @param \Illuminate\Contracts\Foundation\Application $app
*/
public function __construct(Application $app)
{
$this->app = $app;
}

/* ------------------------------------------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
*/
/**
* Get the Filesystem Manager instance.
*
* @return \Illuminate\Contracts\Filesystem\Factory
*/
public function filesystem()
{
return $this->app->make('filesystem');
}

/**
* Get the Config Repository.
*
* @return \Illuminate\Contracts\Config\Repository
*/
protected function config()
{
return $this->app->make('config');
}

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Get a filesystem adapter.
*
* @param string|null $driver
*
* @return \Illuminate\Contracts\Filesystem\Filesystem
*/
public function disk($driver = null)
{
return $this->filesystem()->disk($driver);
}

/**
* Get the default filesystem adapter.
*
* @return \Illuminate\Contracts\Filesystem\Filesystem
*/
public function defaultDisk()
{
return $this->disk(
$this->config()->get('arcanesoft.media.filesystem.default')
);
}
}
13 changes: 12 additions & 1 deletion src/MediaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public function getBasePath()
*/
public function register()
{
parent::register();

$this->registerConfig();
$this->registerSidebarItems();
$this->registerProviders([
Expand All @@ -55,6 +57,7 @@ public function register()
$this->registerConsoleServiceProvider(Providers\ConsoleServiceProvider::class);

$this->syncFilesystemConfig();
$this->registerMediaManager();
}

/**
Expand Down Expand Up @@ -82,7 +85,7 @@ public function boot()
public function provides()
{
return [
//
Contracts\Media::class,
];
}

Expand All @@ -100,6 +103,14 @@ private function syncFilesystemConfig()
}
}

/**
* Register the media manager.
*/
private function registerMediaManager()
{
$this->singleton(Contracts\Media::class, Media::class);
}

/**
* Publish the assets.
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ private function mapAdminRoutes(Router $router)
$this->config()->get('arcanesoft.media.route.prefix', 'media')
);

$router->group($attributes, function (Router $router) {
$router->group($attributes, function ($router) {
Routes\Admin\MediaRoutes::register($router);
Routes\Admin\ApiRoutes::register($router); // TODO: Adding `api` or `ajax` middleware ?
});
}
}
2 changes: 1 addition & 1 deletion tests/MediaServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function it_can_be_instantiated()
public function it_can_provides()
{
$expected = [
//
\Arcanesoft\Media\Contracts\Media::class,
];

$this->assertSame($expected, $this->provider->provides());
Expand Down
Loading

0 comments on commit bdd6618

Please sign in to comment.