Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
1def1ae5
Commit
1def1ae5
authored
Oct 30, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a refresh thumbnail command
parent
6ae7f9f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
1 deletion
+71
-1
RefreshThumbnailCommand.php
Console/RefreshThumbnailCommand.php
+43
-0
MediaServiceProvider.php
Providers/MediaServiceProvider.php
+28
-1
No files found.
Console/RefreshThumbnailCommand.php
0 → 100644
View file @
1def1ae5
<?php
namespace
Modules\Media\Console
;
use
Illuminate\Console\Command
;
use
Modules\Media\Image\Imagy
;
use
Modules\Media\Repositories\FileRepository
;
class
RefreshThumbnailCommand
extends
Command
{
protected
$name
=
'media:thumb-refresh'
;
protected
$description
=
'Create and or refresh the thumbnails'
;
/**
* @var Imagy
*/
private
$imagy
;
/**
* @var FileRepository
*/
private
$file
;
public
function
__construct
(
Imagy
$imagy
,
FileRepository
$file
)
{
parent
::
__construct
();
$this
->
imagy
=
$imagy
;
$this
->
file
=
$file
;
}
/**
* Execute the console command.
*
* @return mixed
*/
public
function
fire
()
{
$this
->
line
(
'Preparing to regenerate all thumbnails...'
);
foreach
(
$this
->
file
->
all
()
as
$file
)
{
$this
->
imagy
->
createAll
(
$file
->
path
);
}
$this
->
info
(
'All thumbnails refreshed'
);
}
}
Providers/MediaServiceProvider.php
View file @
1def1ae5
<?php
namespace
Modules\Media\Providers
;
use
Illuminate\Support\ServiceProvider
;
use
Modules\Media\Console\RefreshThumbnailCommand
;
use
Modules\Media\Entities\File
;
use
Modules\Media\Image\Imagy
;
use
Modules\Media\Image\Intervention\InterventionFactory
;
use
Modules\Media\Image\ThumbnailsManager
;
use
Modules\Media\Repositories\Eloquent\EloquentFileRepository
;
class
MediaServiceProvider
extends
ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
...
...
@@ -24,6 +27,7 @@ class MediaServiceProvider extends ServiceProvider
$this
->
app
->
booted
(
function
()
{
$this
->
registerBindings
();
});
$this
->
registerCommands
();
}
/**
...
...
@@ -46,4 +50,27 @@ class MediaServiceProvider extends ServiceProvider
);
}
/**
* Register all commands for this module
*/
private
function
registerCommands
()
{
$this
->
registerRefreshCommand
();
}
/**
* Register the refresh thumbnails command
*/
private
function
registerRefreshCommand
()
{
$this
->
app
->
bindShared
(
'command.media.refresh'
,
function
(
$app
)
{
$thumbnailManager
=
new
ThumbnailsManager
(
$app
[
'config'
],
$app
[
'modules'
]);
$imagy
=
new
Imagy
(
new
InterventionFactory
,
$thumbnailManager
);
return
new
RefreshThumbnailCommand
(
$imagy
,
$app
[
'Modules\Media\Repositories\FileRepository'
]);
});
$this
->
commands
(
'command.media.refresh'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment