Cheetah
ImageServiceProviderLaravel5.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Intervention\Image;
4 
5 use Illuminate\Support\ServiceProvider;
6 use Illuminate\Http\Response as IlluminateResponse;
7 
8 class ImageServiceProviderLaravel5 extends ServiceProvider
9 {
15  private function cacheIsInstalled()
16  {
17  return class_exists('Intervention\\Image\\ImageCache');
18  }
19 
25  public function boot()
26  {
27  $this->publishes(array(
28  __DIR__.'/../../config/config.php' => config_path('image.php')
29  ));
30 
31  // setup intervention/imagecache if package is installed
32  $this->cacheIsInstalled() ? $this->bootstrapImageCache() : null;
33  }
34 
40  public function register()
41  {
42  $app = $this->app;
43 
44  // merge default config
45  $this->mergeConfigFrom(
46  __DIR__.'/../../config/config.php',
47  'image'
48  );
49 
50  // create image
51  $app['image'] = $app->share(function ($app) {
52  return new ImageManager($app['config']->get('image'));
53  });
54 
55  $app->alias('image', 'Intervention\Image\ImageManager');
56  }
57 
63  private function bootstrapImageCache()
64  {
65  $app = $this->app;
66  $config = __DIR__.'/../../../../imagecache/src/config/config.php';
67 
68  $this->publishes(array(
69  $config => config_path('imagecache.php')
70  ));
71 
72  // merge default config
73  $this->mergeConfigFrom(
74  $config,
75  'imagecache'
76  );
77 
78  // imagecache route
79  if (is_string(config('imagecache.route'))) {
80 
81  $filename_pattern = '[ \w\\.\\/\\-]+';
82 
83  // route to access template applied image file
84  $app['router']->get(config('imagecache.route').'/{template}/{filename}', array(
85  'uses' => 'Intervention\Image\ImageCacheController@getResponse',
86  'as' => 'imagecache'
87  ))->where(array('filename' => $filename_pattern));
88  }
89  }
90 }
$config
$config
Definition: Filter.ExtractStyleBlocks.txt:33
use
GNU LESSER GENERAL PUBLIC LICENSE February Free Software Inc Franklin Fifth MA USA Everyone is permitted to copy and distribute verbatim copies of this license but changing it is not allowed[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it By the GNU General Public Licenses are intended to guarantee your freedom to share and change free software to make sure the software is free for all its users This the Lesser General Public applies to some specially designated software packages typically libraries of the Free Software Foundation and other authors who decide to use it You can use it but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular based on the explanations below When we speak of free we are referring to freedom of use
Definition: license.txt:27
php
Intervention\Image\ImageServiceProviderLaravel5
Definition: ImageServiceProviderLaravel5.php:9
Intervention\Image\ImageManager
Definition: ImageManager.php:8
Intervention\Image\ImageServiceProviderLaravel5\boot
boot()
Definition: ImageServiceProviderLaravel5.php:25
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
Intervention\Image
Definition: AbstractColor.php:3