/**
  * Bootstrap up the stapler package:
  * - Boot stapler.
  * - Set the config driver.
  * - Set public_path config using laravel's public_path() method (if necessary).
  * - Set base_path config using laravel's base_path() method (if necessary).
  * 
  * @return void
  */
 protected function bootstrapStapler()
 {
     Stapler::boot();
     $config = new IlluminateConfig(Config::getFacadeRoot(), 'laravel-stapler');
     Stapler::setConfigInstance($config);
     if (!$config->get('stapler.public_path')) {
         $config->set('stapler.public_path', realpath(public_path()));
     }
     if (!$config->get('stapler.base_path')) {
         $config->set('stapler.base_path', realpath(base_path()));
     }
 }
 /**
  * Bootstrap up the stapler package:
  * - Boot stapler.
  * - Set the config driver.
  * - Set public_path config using laravel's public_path() method (if necessary).
  * - Set base_path config using laravel's base_path() method (if necessary).
  *
  * @return void
  */
 protected function bootstrapStapler()
 {
     Stapler::boot();
     $config = new NativeConfig($this->app['config']->get('stapler'));
     Stapler::setConfigInstance($config);
     if (!$config->get('stapler.public_path')) {
         $config->set('stapler.public_path', realpath(public_path()));
     }
     if (!$config->get('stapler.base_path')) {
         $config->set('stapler.base_path', realpath(base_path()));
     }
 }
示例#3
0
 /**
  * Build a storage instance.
  *
  * @param  AttachedFile $attachment
  * @return \Codesleeve\Stapler\Storage\StorageableInterface
  */
 public static function create(AttachedFile $attachment)
 {
     switch ($attachment->storage) {
         case 'filesystem':
             return new Filesystem($attachment);
             break;
         case 's3':
             $s3Client = Stapler::getS3ClientInstance($attachment);
             return new S3($attachment, $s3Client);
             break;
         default:
             return new Filesystem($attachment);
             break;
     }
 }
 /**
  * Test that the stapler class can build a single instance of
  * Codesleeve\Stapler\Config\IlluminateConfig.
  *
  * @test
  * @return void
  */
 public function it_should_be_able_to_create_set_singleton_config_instance()
 {
     $loaderInterface = m::mock('Illuminate\\Config\\loaderInterface');
     $illuminateConfig = new \Illuminate\Config\Repository($loaderInterface, 'testing');
     $config1 = new Config\IlluminateConfig($illuminateConfig, 'test');
     Stapler::setConfigInstance($config1);
     $config2 = Stapler::getConfigInstance();
     $this->assertInstanceOf('Codesleeve\\Stapler\\Config\\IlluminateConfig', $config1);
     $this->assertInstanceOf('Codesleeve\\Stapler\\Config\\ConfigurableInterface', $config1);
     $this->assertSame($config1, $config2);
 }
示例#5
0
 /**
  * Setup method.
  */
 public function setUp()
 {
     parent::setUp();
     Stapler::boot();
 }
示例#6
0
 /**
  * Build an attachment object.
  *
  * @param  \Codesleeve\Stapler\Interpolator
  * @return \Codesleeve\Stapler\Attachment
  */
 protected function build_attachment()
 {
     Stapler::boot();
     $instance = $this->build_mock_instance();
     $interpolator = new Interpolator();
     $attachmentConfig = new \Codesleeve\Stapler\AttachmentConfig('photo', ['styles' => [], 'placeholder_style' => 'original', 'url' => '/system/:attachment/:id_partition/:style/:filename', 'path' => ':app_root/public:url']);
     $imagine = m::mock('Imagine\\Image\\ImagineInterface');
     $resizer = new \Codesleeve\Stapler\File\Image\Resizer($imagine);
     $attachment = new \Codesleeve\Stapler\Attachment($attachmentConfig, $interpolator, $resizer);
     $attachment->setInstance($instance);
     $storageDriver = new \Codesleeve\Stapler\Storage\Filesystem($attachment);
     $attachment->setStorageDriver($storageDriver);
     return $attachment;
 }
示例#7
0
 /**
  * Test that the stapler class can build a single instance of
  * Codesleeve\Stapler\Config\NativeConfig.
  *
  * @test
  */
 public function it_should_be_able_to_create_a_singleton_native_config_instance()
 {
     $config1 = Stapler::getConfigInstance();
     $config2 = Stapler::getConfigInstance();
     $this->assertInstanceOf('Codesleeve\\Stapler\\Config\\NativeConfig', $config1);
     $this->assertInstanceOf('Codesleeve\\Stapler\\Interfaces\\Config', $config1);
     $this->assertSame($config1, $config2);
 }
示例#8
-1
 /**
  * Merge configuration options.
  * Here we'll merge user defined options with the stapler defaults in a cascading manner.
  * We start with overall stapler options.  Next we merge in storage driver specific options.
  * Finally we'll merge in attachment specific options on top of that.
  *
  * @param array $options
  *
  * @return array
  */
 protected static function mergeOptions(array $options)
 {
     $config = Stapler::getConfigInstance();
     $defaultOptions = $config->get('stapler');
     $options = array_merge($defaultOptions, (array) $options);
     $storage = $options['storage'];
     $options = array_replace_recursive($config->get($storage), $options);
     $options['styles'] = array_merge((array) $options['styles'], ['original' => '']);
     return $options;
 }