File indexing completed on 2025-01-26 05:29:15
0001 <?php 0002 0003 namespace Intervention\Image; 0004 0005 use Illuminate\Support\ServiceProvider; 0006 0007 class ImageServiceProvider extends ServiceProvider 0008 { 0009 /** 0010 * Indicates if loading of the provider is deferred. 0011 * 0012 * @var bool 0013 */ 0014 protected $defer = false; 0015 0016 /** 0017 * Actual provider 0018 * 0019 * @var \Illuminate\Support\ServiceProvider 0020 */ 0021 protected $provider; 0022 0023 /** 0024 * Create a new service provider instance. 0025 * 0026 * @param \Illuminate\Contracts\Foundation\Application $app 0027 * @return void 0028 */ 0029 public function __construct($app) 0030 { 0031 parent::__construct($app); 0032 0033 $this->provider = $this->getProvider(); 0034 } 0035 0036 /** 0037 * Bootstrap the application events. 0038 * 0039 * @return void 0040 */ 0041 public function boot() 0042 { 0043 if (method_exists($this->provider, 'boot')) { 0044 return $this->provider->boot(); 0045 } 0046 } 0047 0048 /** 0049 * Register the service provider. 0050 * 0051 * @return void 0052 */ 0053 public function register() 0054 { 0055 return $this->provider->register(); 0056 } 0057 0058 /** 0059 * Return ServiceProvider according to Laravel version 0060 * 0061 * @return \Intervention\Image\Provider\ProviderInterface 0062 */ 0063 private function getProvider() 0064 { 0065 if ($this->app instanceof \Laravel\Lumen\Application) { 0066 $provider = '\Intervention\Image\ImageServiceProviderLumen'; 0067 } elseif (version_compare(\Illuminate\Foundation\Application::VERSION, '5.0', '<')) { 0068 $provider = '\Intervention\Image\ImageServiceProviderLaravel4'; 0069 } else { 0070 $provider = '\Intervention\Image\ImageServiceProviderLaravel5'; 0071 } 0072 0073 return new $provider($this->app); 0074 } 0075 0076 /** 0077 * Get the services provided by the provider. 0078 * 0079 * @return array 0080 */ 0081 public function provides() 0082 { 0083 return ['image']; 0084 } 0085 }