Skip to content

Commit

Permalink
Conform to PSR2 coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Dec 28, 2014
1 parent d6174fa commit 70b9622
Show file tree
Hide file tree
Showing 50 changed files with 162 additions and 167 deletions.
4 changes: 2 additions & 2 deletions Config/thumbnails.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
'fit' => [
'width' => 50,
'height' => 50,
'callback' => function($constraint) {
'callback' => function ($constraint) {
$constraint->upsize();
}
},
],
]
];
1 change: 0 additions & 1 deletion Console/RefreshThumbnailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,4 @@ public function fire()

$this->info('All thumbnails refreshed');
}

}
56 changes: 27 additions & 29 deletions Database/Migrations/2014_10_26_162751_create_files_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,34 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateFilesTable extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('files', function(Blueprint $table)
{
class CreateFilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('files', function (Blueprint $table) {
$table->increments('id');
$table->string('filename');
$table->string('path');
$table->string('extension');
$table->string('mimetype');
$table->string('filesize');
$table->integer('folder_id')->unsigned();
$table->string('filename');
$table->string('path');
$table->string('extension');
$table->string('mimetype');
$table->string('filesize');
$table->integer('folder_id')->unsigned();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('files');
}
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('files');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ public function down()
{
Schema::drop('file_translations');
}

}
2 changes: 0 additions & 2 deletions Database/Seeders/MediaDatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

class MediaDatabaseSeeder extends Seeder
{

/**
* Run the database seeds.
*
Expand All @@ -15,5 +14,4 @@ public function run()
{
Model::unguard();
}

}
2 changes: 1 addition & 1 deletion Entities/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ class File extends Model
'width',
'height',
'filesize',
'folder_id'
'folder_id',
];
}
2 changes: 1 addition & 1 deletion Helpers/FileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static function slug($name)

$name = Str::slug($name);

return $name . $extension;
return $name.$extension;
}

/**
Expand Down
10 changes: 6 additions & 4 deletions Http/Controllers/Admin/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function store()
/**
* Show the form for editing the specified resource.
*
* @param File $file
* @param File $file
* @return Response
*/
public function edit(File $file)
Expand All @@ -87,22 +87,23 @@ public function edit(File $file)
/**
* Update the specified resource in storage.
*
* @param File $file
* @param UpdateMediaRequest $request
* @param File $file
* @param UpdateMediaRequest $request
* @return Response
*/
public function update(File $file, UpdateMediaRequest $request)
{
$this->file->update($file, $request->all());

Flash::success(trans('media::messages.file updated'));

return Redirect::route('dashboard.media.index');
}

/**
* Remove the specified resource from storage.
*
* @param File $file
* @param File $file
* @internal param int $id
* @return Response
*/
Expand All @@ -112,6 +113,7 @@ public function destroy(File $file)
$this->file->destroy($file);

Flash::success(trans('media::messages.file deleted'));

return Redirect::route('dashboard.media.index');
}
}
2 changes: 1 addition & 1 deletion Http/Controllers/Api/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(FileService $fileService)
/**
* Store a newly created resource in storage.
*
* @param UploadMediaRequest $request
* @param UploadMediaRequest $request
* @return Response
*/
public function store(UploadMediaRequest $request)
Expand Down
6 changes: 2 additions & 4 deletions Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

$router->model('media', 'Modules\Media\Entities\File');

$router->group(['prefix' => LaravelLocalization::setLocale(), 'before' => 'LaravelLocalizationRedirectFilter|auth.admin|permissions'], function(Router $router)
{
$router->group(['prefix' => Config::get('core::core.admin-prefix'), 'namespace' => 'Modules\Media\Http\Controllers'], function(Router $router)
{
$router->group(['prefix' => LaravelLocalization::setLocale(), 'before' => 'LaravelLocalizationRedirectFilter|auth.admin|permissions'], function (Router $router) {
$router->group(['prefix' => Config::get('core::core.admin-prefix'), 'namespace' => 'Modules\Media\Http\Controllers'], function (Router $router) {
$router->resource('media', 'Admin\MediaController', ['except' => ['show'], 'names' => [
'index' => 'dashboard.media.index',
'create' => 'dashboard.media.create',
Expand Down
5 changes: 4 additions & 1 deletion Image/Facade/Imagy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@

class Imagy extends Facade
{
protected static function getFacadeAccessor() { return 'imagy'; }
protected static function getFacadeAccessor()
{
return 'imagy';
}
}
2 changes: 1 addition & 1 deletion Image/ImageFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface ImageFactoryInterface
{
/**
* Return a new Manipulation class
* @param string $manipulation
* @param string $manipulation
* @return \Modules\Media\Image\ImageHandlerInterface
*/
public function make($manipulation);
Expand Down
4 changes: 2 additions & 2 deletions Image/ImageHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ interface ImageHandlerInterface
{
/**
* Handle the image manipulation request
* @param \Intervention\Image\Image $image
* @param array $options
* @param \Intervention\Image\Image $image
* @param array $options
* @return \Intervention\Image\Image
*/
public function handle($image, $options);
Expand Down
5 changes: 2 additions & 3 deletions Image/ImageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ public function register()
);

$this->app['imagy'] = $this->app->share(function ($app) {
$factory = new InterventionFactory;
$factory = new InterventionFactory();
$thumbnailManager = new ThumbnailsManager($app['config'], $app['modules']);

return new Imagy($factory, $thumbnailManager, $app['config']);
});

$this->app->booting(function()
{
$this->app->booting(function () {
$loader = AliasLoader::getInstance();
$loader->alias('Imagy', 'Modules\Media\Image\Facade\Imagy');
});
Expand Down
48 changes: 24 additions & 24 deletions Image/Imagy.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class Imagy

/**
* @param ImageFactoryInterface $imageFactory
* @param ThumbnailsManager $manager
* @param Repository $config
* @param ThumbnailsManager $manager
* @param Repository $config
*/
public function __construct(ImageFactoryInterface $imageFactory, ThumbnailsManager $manager, Repository $config)
{
Expand All @@ -49,9 +49,9 @@ public function __construct(ImageFactoryInterface $imageFactory, ThumbnailsManag

/**
* Get an image in the given thumbnail options
* @param string $path
* @param string $thumbnail
* @param bool $forceCreate
* @param string $path
* @param string $thumbnail
* @param bool $forceCreate
* @return string
*/
public function get($path, $thumbnail, $forceCreate = false)
Expand All @@ -60,7 +60,7 @@ public function get($path, $thumbnail, $forceCreate = false)
return;
}

$filename = $this->config->get('media::config.files-path') . $this->newFilename($path, $thumbnail);
$filename = $this->config->get('media::config.files-path').$this->newFilename($path, $thumbnail);

if ($this->returnCreatedFile($filename, $forceCreate)) {
return $filename;
Expand All @@ -73,8 +73,8 @@ public function get($path, $thumbnail, $forceCreate = false)

/**
* Return the thumbnail path
* @param string $originalImage
* @param string $thumbnail
* @param string $originalImage
* @param string $thumbnail
* @return string
*/
public function getThumbnail($originalImage, $thumbnail)
Expand All @@ -83,7 +83,7 @@ public function getThumbnail($originalImage, $thumbnail)
return $originalImage;
}

return $this->config->get('media::config.files-path') . $this->newFilename($originalImage, $thumbnail);
return $this->config->get('media::config.files-path').$this->newFilename($originalImage, $thumbnail);
}

/**
Expand All @@ -97,8 +97,8 @@ public function createAll($path)
}

foreach ($this->manager->all() as $thumbName => $filters) {
$image = $this->image->make(public_path() . $path);
$filename = $this->config->get('media::config.files-path') . $this->newFilename($path, $thumbName);
$image = $this->image->make(public_path().$path);
$filename = $this->config->get('media::config.files-path').$this->newFilename($path, $thumbName);
foreach ($filters as $manipulation => $options) {
$image = $this->imageFactory->make($manipulation)->handle($image, $options);
}
Expand All @@ -117,18 +117,18 @@ private function newFilename($path, $thumbnail)
{
$filename = pathinfo($path, PATHINFO_FILENAME);

return $filename . '_' . $thumbnail . '.' . pathinfo($path, PATHINFO_EXTENSION);
return $filename.'_'.$thumbnail.'.'.pathinfo($path, PATHINFO_EXTENSION);
}

/**
* Return the already created file if it exists and force create is false
* @param string $filename
* @param bool $forceCreate
* @param string $filename
* @param bool $forceCreate
* @return bool
*/
private function returnCreatedFile($filename, $forceCreate)
{
return $this->finder->isFile(public_path() . $filename) && !$forceCreate;
return $this->finder->isFile(public_path().$filename) && !$forceCreate;
}

/**
Expand All @@ -138,18 +138,18 @@ private function returnCreatedFile($filename, $forceCreate)
*/
private function writeImage($filename, $image)
{
$this->finder->put(public_path() . $filename, $image);
$this->finder->put(public_path().$filename, $image);
}

/**
* Make a new image
* @param string $path
* @param string $filename
* @param string $path
* @param string $filename
* @param string null $thumbnail
*/
private function makeNew($path, $filename, $thumbnail)
{
$image = $this->image->make(public_path() . $path);
$image = $this->image->make(public_path().$path);

foreach ($this->manager->find($thumbnail) as $manipulation => $options) {
$image = $this->imageFactory->make($manipulation)->handle($image, $options);
Expand All @@ -161,7 +161,7 @@ private function makeNew($path, $filename, $thumbnail)

/**
* Check if the given path is en image
* @param string $path
* @param string $path
* @return bool
*/
public function isImage($path)
Expand All @@ -181,15 +181,15 @@ public function deleteAllFor(File $file)
return $this->finder->delete($file->path);
}

$paths[] = public_path() . $file->path;
$paths[] = public_path().$file->path;
$fileName = pathinfo($file->path, PATHINFO_FILENAME);
$extension = pathinfo($file->path, PATHINFO_EXTENSION);
foreach ($this->manager->all() as $thumbnail => $filters) {
$paths[] = public_path() . $this->config->get(
$paths[] = public_path().$this->config->get(
'media::config.files-path'
) . "{$fileName}_{$thumbnail}.{$extension}";
)."{$fileName}_{$thumbnail}.{$extension}";
}

return $this->finder->delete($paths);
}

}
6 changes: 3 additions & 3 deletions Image/Intervention/InterventionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
class InterventionFactory implements ImageFactoryInterface
{
/**
* @param string $manipulation
* @param string $manipulation
* @return \Modules\Media\Image\ImageHandlerInterface
*/
public function make($manipulation)
{
$class = 'Modules\\Media\\Image\\Intervention\\Manipulations\\'. ucfirst($manipulation);
$class = 'Modules\\Media\\Image\\Intervention\\Manipulations\\'.ucfirst($manipulation);

return new $class;
return new $class();
}
}
Loading

0 comments on commit 70b9622

Please sign in to comment.