From 85f8a95e283564cd8392431cce4d43762cd24df0 Mon Sep 17 00:00:00 2001 From: Travis Bennett Date: Wed, 4 Feb 2015 01:33:44 -0600 Subject: [PATCH] Convert indentation to spaces. Converted indentation to spaces on all files. --- src/Commands/FastenCommand.php | 196 ++++++++++---------- src/Commands/RefreshCommand.php | 132 +++++++------- src/LaravelStaplerServiceProvider.php | 176 +++++++++--------- src/Services/ImageRefreshService.php | 242 ++++++++++++------------- src/config/filesystem.php | 84 ++++----- src/config/s3.php | 90 +++++----- src/config/stapler.php | 246 +++++++++++++------------- src/views/migration.php | 68 +++---- tests/TestCase.php | 30 ++-- 9 files changed, 632 insertions(+), 632 deletions(-) diff --git a/src/Commands/FastenCommand.php b/src/Commands/FastenCommand.php index dc91edd..9f59316 100644 --- a/src/Commands/FastenCommand.php +++ b/src/Commands/FastenCommand.php @@ -9,103 +9,103 @@ class FastenCommand extends Command { - /** - * The console command name. - * - * @var string - */ - protected $name = 'stapler:fasten'; - - /** - * The console command description. - * - * @var string - */ - protected $description = 'Generate a migration for adding stapler file fields to a database table'; - - /** - * An instance of Laravel's view factory. - * - * @var View - */ - protected $view; - - /** - * An instance of Laravel's filesystem. - * - * @var File - */ - protected $file; - - /** - * Create a new command instance. - * - * @return void - */ - public function __construct(View $view, File $file) - { - parent::__construct(); - - $this->view = $view; - $this->file = $file; - } - - /** - * Execute the console command. - * - * @return void - */ - public function fire() - { - $this->createMigration(); - } - - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['table', InputArgument::REQUIRED, 'The name of the database table the file fields will be added to.'], - ['attachment', InputArgument::REQUIRED, 'The name of the corresponding stapler attachment.'], - ]; - } - - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return array(); - } - - /** - * Create a new migration. - * - * @return void - */ - protected function createMigration() - { - $data = ['table' => $this->argument('table'), 'attachment' => $this->argument('attachment')]; - $prefix = date('Y_m_d_His'); - $path = app_path() . '/database/migrations'; - - if (!is_dir($path)) mkdir($path); - - $fileName = $path . '/' . $prefix . '_add_' . $data['attachment'] . '_fields_to_' . $data['table'] . '_table.php'; - $data['className'] = 'Add' . ucfirst(Str::camel($data['attachment'])) . 'FieldsTo' . ucfirst(Str::camel($data['table'])) . 'Table'; - - // Save the new migration to disk using the stapler migration view. - $migration = $this->view->make('laravel-stapler::migration', $data)->render(); - $this->file->put($fileName, $migration); - - // Dump the autoloader and print a created migration message to the console. - $this->call('dump-autoload'); - $this->info("Created migration: $fileName"); - } + /** + * The console command name. + * + * @var string + */ + protected $name = 'stapler:fasten'; + + /** + * The console command description. + * + * @var string + */ + protected $description = 'Generate a migration for adding stapler file fields to a database table'; + + /** + * An instance of Laravel's view factory. + * + * @var View + */ + protected $view; + + /** + * An instance of Laravel's filesystem. + * + * @var File + */ + protected $file; + + /** + * Create a new command instance. + * + * @return void + */ + public function __construct(View $view, File $file) + { + parent::__construct(); + + $this->view = $view; + $this->file = $file; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->createMigration(); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return [ + ['table', InputArgument::REQUIRED, 'The name of the database table the file fields will be added to.'], + ['attachment', InputArgument::REQUIRED, 'The name of the corresponding stapler attachment.'], + ]; + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array(); + } + + /** + * Create a new migration. + * + * @return void + */ + protected function createMigration() + { + $data = ['table' => $this->argument('table'), 'attachment' => $this->argument('attachment')]; + $prefix = date('Y_m_d_His'); + $path = app_path() . '/database/migrations'; + + if (!is_dir($path)) mkdir($path); + + $fileName = $path . '/' . $prefix . '_add_' . $data['attachment'] . '_fields_to_' . $data['table'] . '_table.php'; + $data['className'] = 'Add' . ucfirst(Str::camel($data['attachment'])) . 'FieldsTo' . ucfirst(Str::camel($data['table'])) . 'Table'; + + // Save the new migration to disk using the stapler migration view. + $migration = $this->view->make('laravel-stapler::migration', $data)->render(); + $this->file->put($fileName, $migration); + + // Dump the autoloader and print a created migration message to the console. + $this->call('dump-autoload'); + $this->info("Created migration: $fileName"); + } } diff --git a/src/Commands/RefreshCommand.php b/src/Commands/RefreshCommand.php index 6113dab..accafa5 100644 --- a/src/Commands/RefreshCommand.php +++ b/src/Commands/RefreshCommand.php @@ -7,79 +7,79 @@ class RefreshCommand extends Command { - /** - * The console command name. - * - * @var string - */ - protected $name = 'stapler:refresh'; + /** + * The console command name. + * + * @var string + */ + protected $name = 'stapler:refresh'; - /** - * The console command description. - * - * @var string - */ - protected $description = 'Regenerate images for a given model (and optional attachment and styles)'; + /** + * The console command description. + * + * @var string + */ + protected $description = 'Regenerate images for a given model (and optional attachment and styles)'; - /** - * The image refresh service that will be used to - * rebuild images. - * - * @var ImageRefreshService - */ - protected $imageRefreshService; + /** + * The image refresh service that will be used to + * rebuild images. + * + * @var ImageRefreshService + */ + protected $imageRefreshService; - /** - * Create a new command instance. - * - * @param ImageRefreshService $imageRefreshService - * @return void - */ - public function __construct(ImageRefreshService $imageRefreshService) - { - parent::__construct(); + /** + * Create a new command instance. + * + * @param ImageRefreshService $imageRefreshService + * @return void + */ + public function __construct(ImageRefreshService $imageRefreshService) + { + parent::__construct(); - $this->imageRefreshService = $imageRefreshService; - } + $this->imageRefreshService = $imageRefreshService; + } - /** - * Execute the console command. - * - * @return void - */ - public function fire() - { - $this->imageRefreshService->setOutput($this->output); + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->imageRefreshService->setOutput($this->output); - $class = $this->argument('class'); - $attachments = $this->option('attachments') ?: []; + $class = $this->argument('class'); + $attachments = $this->option('attachments') ?: []; - $this->info('Refreshing uploaded images...'); - $this->imageRefreshService->refresh($class, $attachments); - $this->info('Done!'); - } + $this->info('Refreshing uploaded images...'); + $this->imageRefreshService->refresh($class, $attachments); + $this->info('Done!'); + } - /** - * Get the console command arguments. - * - * @return array - */ - protected function getArguments() - { - return [ - ['class', InputArgument::REQUIRED, 'The name of a class (model) to refresh images on'], - ]; - } + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return [ + ['class', InputArgument::REQUIRED, 'The name of a class (model) to refresh images on'], + ]; + } - /** - * Get the console command options. - * - * @return array - */ - protected function getOptions() - { - return [ - ['attachments', null, InputOption::VALUE_OPTIONAL, 'A list of specific attachments to refresh images on.'], - ]; - } + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return [ + ['attachments', null, InputOption::VALUE_OPTIONAL, 'A list of specific attachments to refresh images on.'], + ]; + } } diff --git a/src/LaravelStaplerServiceProvider.php b/src/LaravelStaplerServiceProvider.php index c9dfe4a..37f97e9 100644 --- a/src/LaravelStaplerServiceProvider.php +++ b/src/LaravelStaplerServiceProvider.php @@ -8,106 +8,106 @@ class LaravelStaplerServiceProvider extends ServiceProvider { - /** - * Indicates if loading of the provider is deferred. - * - * @var bool - */ - protected $defer = false; - - /** - * Bootstrap the application events. - * - * @return void - */ - public function boot() - { - $this->package('codesleeve/laravel-stapler', null, __DIR__); - $this->bootstrapStapler(); - } - - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - // commands - $this->registerStaplerFastenCommand(); - $this->registerStaplerRefreshCommand(); - - // services - $this->registerImageRefreshService(); + /** + * Indicates if loading of the provider is deferred. + * + * @var bool + */ + protected $defer = false; + + /** + * Bootstrap the application events. + * + * @return void + */ + public function boot() + { + $this->package('codesleeve/laravel-stapler', null, __DIR__); + $this->bootstrapStapler(); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + // commands + $this->registerStaplerFastenCommand(); + $this->registerStaplerRefreshCommand(); + + // services + $this->registerImageRefreshService(); $this->commands('stapler.fasten'); - $this->commands('stapler.refresh'); - } - - /** - * Get the services provided by the provider. - * - * @return array - */ - public function provides() - { - return array(); - } - - /** - * 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() - { + $this->commands('stapler.refresh'); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array(); + } + + /** + * 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())); + $config->set('stapler.public_path', realpath(public_path())); } if (!$config->get('stapler.base_path')) { - $config->set('stapler.base_path', realpath(base_path())); + $config->set('stapler.base_path', realpath(base_path())); } - } - - /** - * Register the stapler fasten command with the container. - * - * @return void - */ - protected function registerStaplerFastenCommand() - { - $this->app->bind('stapler.fasten', function($app) - { - return new Commands\FastenCommand($app['view'], $app['files']); - }); - } - - /** - * Register the stapler refresh command with the container. - * - * @return void - */ - protected function registerStaplerRefreshCommand() - { - $this->app->bind('stapler.refresh', function($app) - { - $refreshService = $app['ImageRefreshService']; - - return new Commands\RefreshCommand($refreshService); - }); - } - - /** + } + + /** + * Register the stapler fasten command with the container. + * + * @return void + */ + protected function registerStaplerFastenCommand() + { + $this->app->bind('stapler.fasten', function($app) + { + return new Commands\FastenCommand($app['view'], $app['files']); + }); + } + + /** + * Register the stapler refresh command with the container. + * + * @return void + */ + protected function registerStaplerRefreshCommand() + { + $this->app->bind('stapler.refresh', function($app) + { + $refreshService = $app['ImageRefreshService']; + + return new Commands\RefreshCommand($refreshService); + }); + } + + /** * Register the image refresh service with the container. * * @return void diff --git a/src/Services/ImageRefreshService.php b/src/Services/ImageRefreshService.php index 75ad46d..f78613a 100644 --- a/src/Services/ImageRefreshService.php +++ b/src/Services/ImageRefreshService.php @@ -9,125 +9,125 @@ class ImageRefreshService { - /** - * The laravel application instance. - * - * @var Application - */ - protected $app; - - /** - * A Symfony console output instance. - * - * @var OutputInterface - */ - protected $output; - - /** - * @param Application $app - */ - public function __construct(Application $app) { - $this->app = $app; - } - - /** - * @param OutputInterface $output - */ - public function setOutput(OutputInterface $output) - { - $this->output = $output; - } - - /** - * Attempt to refresh the defined attachments on a particular model. - * - * @throws InvalidClassException - * @param string $class - * @param array $attachments - * @return void - */ - public function refresh($class, array $attachments) - { - if (!method_exists($class, 'hasAttachedFile')) { - throw new InvalidClassException("Invalid class: the $class class is not currently using Stapler.", 1); - } - - $models = $this->app->make($class)->all(); - - if ($attachments) - { - $attachments = explode(',', str_replace(', ', ',', $attachments)); - $this->processSomeAttachments($models, $attachments); - - return; - } - - $this->processAllAttachments($models); - } - - /** - * Process a only a specified subset of stapler attachments. - * - * @param Collection $models - * @param array $attachments - * @return void - */ - protected function processSomeAttachments(Collection $models, array $attachments) - { - $progress = $this->getProgressBar($models); - $progress->start(); - - foreach ($models as $model) - { - $progress->advance(); - - foreach ($model->getAttachedFiles() as $attachedFile) - { - if (in_array($attachedFile->name, $attachments)) { - $attachedFile->reprocess(); - } - } - } - - $progress->finish(); - } - - /** - * Process all stapler attachments defined on a class. - * - * @param Collection $models - * @return void - */ - protected function processAllAttachments(Collection $models) - { - $progress = $this->getProgressBar($models); - $progress->start(); - - foreach ($models as $model) - { - $progress->advance(); - - foreach ($model->getAttachedFiles() as $attachedFile) - { - $attachedFile->reprocess(); - } - } - - $progress->finish(); - } - - /** - * Get an instance of the ProgressBar helper - * - * @param Collection $models - * - * @return ProgressBar - */ - protected function getProgressBar(Collection $models) - { - $output = $this->output ?: new NullOutput(); - $progress = new ProgressBar($output, $models->count()); - - return $progress; - } + /** + * The laravel application instance. + * + * @var Application + */ + protected $app; + + /** + * A Symfony console output instance. + * + * @var OutputInterface + */ + protected $output; + + /** + * @param Application $app + */ + public function __construct(Application $app) { + $this->app = $app; + } + + /** + * @param OutputInterface $output + */ + public function setOutput(OutputInterface $output) + { + $this->output = $output; + } + + /** + * Attempt to refresh the defined attachments on a particular model. + * + * @throws InvalidClassException + * @param string $class + * @param array $attachments + * @return void + */ + public function refresh($class, array $attachments) + { + if (!method_exists($class, 'hasAttachedFile')) { + throw new InvalidClassException("Invalid class: the $class class is not currently using Stapler.", 1); + } + + $models = $this->app->make($class)->all(); + + if ($attachments) + { + $attachments = explode(',', str_replace(', ', ',', $attachments)); + $this->processSomeAttachments($models, $attachments); + + return; + } + + $this->processAllAttachments($models); + } + + /** + * Process a only a specified subset of stapler attachments. + * + * @param Collection $models + * @param array $attachments + * @return void + */ + protected function processSomeAttachments(Collection $models, array $attachments) + { + $progress = $this->getProgressBar($models); + $progress->start(); + + foreach ($models as $model) + { + $progress->advance(); + + foreach ($model->getAttachedFiles() as $attachedFile) + { + if (in_array($attachedFile->name, $attachments)) { + $attachedFile->reprocess(); + } + } + } + + $progress->finish(); + } + + /** + * Process all stapler attachments defined on a class. + * + * @param Collection $models + * @return void + */ + protected function processAllAttachments(Collection $models) + { + $progress = $this->getProgressBar($models); + $progress->start(); + + foreach ($models as $model) + { + $progress->advance(); + + foreach ($model->getAttachedFiles() as $attachedFile) + { + $attachedFile->reprocess(); + } + } + + $progress->finish(); + } + + /** + * Get an instance of the ProgressBar helper + * + * @param Collection $models + * + * @return ProgressBar + */ + protected function getProgressBar(Collection $models) + { + $output = $this->output ?: new NullOutput(); + $progress = new ProgressBar($output, $models->count()); + + return $progress; + } } diff --git a/src/config/filesystem.php b/src/config/filesystem.php index ae894bb..2f889e3 100644 --- a/src/config/filesystem.php +++ b/src/config/filesystem.php @@ -2,47 +2,47 @@ return [ - /* - |-------------------------------------------------------------------------- - | Stapler File Url - |-------------------------------------------------------------------------- - | - | The url (relative to your project document root) where files will be stored. - | It is composed of 'interpolations' that will be replaced their - | corresponding values during runtime. It's unique in that it functions as both - | a configuration option and an interpolation. - | - */ - - 'url' => '/system/:class/:attachment/:id_partition/:style/:filename', - - /* - |-------------------------------------------------------------------------- - | Stapler File Path - |-------------------------------------------------------------------------- - | - | Similar to the url, the path option is the location where your files will - | be stored at on disk. It should be noted that the path option should not - | conflict with the url option. Stapler provides sensible defaults that take - | care of this for you. - | - */ - - 'path' => ':app_root/public:url', - - /* - |-------------------------------------------------------------------------- - | Override File Permissions Flag - |-------------------------------------------------------------------------- - | - | Override the default file permissions used by stapler when creating a new - | file in the file system. Leaving this value as null will result in stapler - | chmod'ing files to 0666. Set it to a specific octal value and stapler will - | chmod accordingly. Set it to false to prevent chmod from occuring (useful - | for non unix-based environments). - | - */ - - 'override_file_permissions' => null, + /* + |-------------------------------------------------------------------------- + | Stapler File Url + |-------------------------------------------------------------------------- + | + | The url (relative to your project document root) where files will be stored. + | It is composed of 'interpolations' that will be replaced their + | corresponding values during runtime. It's unique in that it functions as both + | a configuration option and an interpolation. + | + */ + + 'url' => '/system/:class/:attachment/:id_partition/:style/:filename', + + /* + |-------------------------------------------------------------------------- + | Stapler File Path + |-------------------------------------------------------------------------- + | + | Similar to the url, the path option is the location where your files will + | be stored at on disk. It should be noted that the path option should not + | conflict with the url option. Stapler provides sensible defaults that take + | care of this for you. + | + */ + + 'path' => ':app_root/public:url', + + /* + |-------------------------------------------------------------------------- + | Override File Permissions Flag + |-------------------------------------------------------------------------- + | + | Override the default file permissions used by stapler when creating a new + | file in the file system. Leaving this value as null will result in stapler + | chmod'ing files to 0666. Set it to a specific octal value and stapler will + | chmod accordingly. Set it to false to prevent chmod from occuring (useful + | for non unix-based environments). + | + */ + + 'override_file_permissions' => null, ]; \ No newline at end of file diff --git a/src/config/s3.php b/src/config/s3.php index 8f6d23a..4e4003d 100644 --- a/src/config/s3.php +++ b/src/config/s3.php @@ -2,52 +2,52 @@ return [ - /* - |-------------------------------------------------------------------------- - | S3 Client Config - |-------------------------------------------------------------------------- - | - | This is array holds the default configuration options used when creating - | an instance of Aws\S3\S3Client. These options will be passed directly to - | the s3ClientFactory when creating an S3 client instance. - | - */ - 's3_client_config' => [ - 'key' => '', - 'secret' => '', - 'region' => '', - 'scheme' => 'http' - ], - - /* - |-------------------------------------------------------------------------- - | S3 Object Config - |-------------------------------------------------------------------------- - | - | An array of options used by the Aws\S3\S3Client::putObject() method when - | storing a file on S3. - | AWS Documentation for Aws\S3\S3Client::putObject() at - | http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.S3.S3Client.html#_putObject - | - */ - 's3_object_config' => [ - 'Bucket' => '', - 'ACL' => 'public-read' - ], + /* + |-------------------------------------------------------------------------- + | S3 Client Config + |-------------------------------------------------------------------------- + | + | This is array holds the default configuration options used when creating + | an instance of Aws\S3\S3Client. These options will be passed directly to + | the s3ClientFactory when creating an S3 client instance. + | + */ + 's3_client_config' => [ + 'key' => '', + 'secret' => '', + 'region' => '', + 'scheme' => 'http' + ], + + /* + |-------------------------------------------------------------------------- + | S3 Object Config + |-------------------------------------------------------------------------- + | + | An array of options used by the Aws\S3\S3Client::putObject() method when + | storing a file on S3. + | AWS Documentation for Aws\S3\S3Client::putObject() at + | http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.S3.S3Client.html#_putObject + | + */ + 's3_object_config' => [ + 'Bucket' => '', + 'ACL' => 'public-read' + ], - /* - |-------------------------------------------------------------------------- - | S3 Path - |-------------------------------------------------------------------------- - | - | This is the key under the bucket in which the file will be stored. - | The URL will be constructed from the bucket and the path. - | This is what you will want to interpolate. Keys should be unique, - | like filenames, and despite the fact that S3 (strictly speaking) does not - | support directories, you can still use a / to separate parts of your file name. - | - */ + /* + |-------------------------------------------------------------------------- + | S3 Path + |-------------------------------------------------------------------------- + | + | This is the key under the bucket in which the file will be stored. + | The URL will be constructed from the bucket and the path. + | This is what you will want to interpolate. Keys should be unique, + | like filenames, and despite the fact that S3 (strictly speaking) does not + | support directories, you can still use a / to separate parts of your file name. + | + */ - 'path' => ':attachment/:id/:style/:filename', + 'path' => ':attachment/:id/:style/:filename', ]; diff --git a/src/config/stapler.php b/src/config/stapler.php index 7c40405..7ce65c6 100644 --- a/src/config/stapler.php +++ b/src/config/stapler.php @@ -2,128 +2,128 @@ return [ - /* - |-------------------------------------------------------------------------- - | Stapler Public Path Location - |-------------------------------------------------------------------------- - | - | The location of the web application's document root. - | - */ - - 'public_path' => '', - - /* - |-------------------------------------------------------------------------- - | Stapler Base Path Location - |-------------------------------------------------------------------------- - | - | The path to the base of the web application. - | - */ - - 'base_path' => '', - - /* - |-------------------------------------------------------------------------- - | Stapler Storage Driver - |-------------------------------------------------------------------------- - | - | The default mechanism for handling file storage. Currently Stapler supports - | both file system and Amazon S3 as options. - | - */ - - 'storage' => 'filesystem', - - /* - |-------------------------------------------------------------------------- - | Stapler Image Processing Library - |-------------------------------------------------------------------------- - | - | The default library used for image processing. Can be one of the following: - | Imagine\Gd\Imagine, Imagine\Imagick\Imagine, or Imagine\Gmagick\Imagine. - | - */ - - 'image_processing_library' => 'Imagine\Gd\Imagine', - - - /* - |-------------------------------------------------------------------------- - | Stapler Default Url - |-------------------------------------------------------------------------- - | - | The url (relative to your project document root) containing a default image - | that will be used for attachments that don't currently have an uploaded image - | attached to them. - | - */ - - 'default_url' => '/:attachment/:style/missing.png', - - /* - |-------------------------------------------------------------------------- - | Stapler Default Style - |-------------------------------------------------------------------------- - | - | The default style returned from the Stapler file location helper methods. - | An unaltered version of uploaded file is always stored within the 'original' - | style, however the default_style can be set to point to any of the defined - | styles within the styles array. - | - */ - - 'default_style' => 'original', - - /* - |-------------------------------------------------------------------------- - | Stapler Styles - |-------------------------------------------------------------------------- - | - | An array of image sizes defined for the file attachment. - | Stapler will attempt to format the file upload into the defined style. - | - */ - - 'styles' => [], - - /* - |-------------------------------------------------------------------------- - | Convert Options - |-------------------------------------------------------------------------- - | - | An array of options for setting the quality and DPI of resized images. - | Default values are 75 for Jpeg quality and 72 dpi for x/y-resolution. - | Please see the Imagine\Image documentation for more details. - | - */ - - 'convert_options' => [], - - /* - |-------------------------------------------------------------------------- - | Keep Old Files Flag - |-------------------------------------------------------------------------- - | - | Set this to true in order to prevent older file uploads from being deleted - | from storage when a record is updated with a new upload. - | - */ - - 'keep_old_files' => false, - - /* - |-------------------------------------------------------------------------- - | Preserve Files Flag - |-------------------------------------------------------------------------- - | - | Set this to true in order to prevent file uploads from being deleted - | from the file system when an attachment is destroyed. Essentially this - | ensures the preservation of uploads event after their corresponding database - | records have been removed. - | - */ - 'preserve_files' => false + /* + |-------------------------------------------------------------------------- + | Stapler Public Path Location + |-------------------------------------------------------------------------- + | + | The location of the web application's document root. + | + */ + + 'public_path' => '', + + /* + |-------------------------------------------------------------------------- + | Stapler Base Path Location + |-------------------------------------------------------------------------- + | + | The path to the base of the web application. + | + */ + + 'base_path' => '', + + /* + |-------------------------------------------------------------------------- + | Stapler Storage Driver + |-------------------------------------------------------------------------- + | + | The default mechanism for handling file storage. Currently Stapler supports + | both file system and Amazon S3 as options. + | + */ + + 'storage' => 'filesystem', + + /* + |-------------------------------------------------------------------------- + | Stapler Image Processing Library + |-------------------------------------------------------------------------- + | + | The default library used for image processing. Can be one of the following: + | Imagine\Gd\Imagine, Imagine\Imagick\Imagine, or Imagine\Gmagick\Imagine. + | + */ + + 'image_processing_library' => 'Imagine\Gd\Imagine', + + + /* + |-------------------------------------------------------------------------- + | Stapler Default Url + |-------------------------------------------------------------------------- + | + | The url (relative to your project document root) containing a default image + | that will be used for attachments that don't currently have an uploaded image + | attached to them. + | + */ + + 'default_url' => '/:attachment/:style/missing.png', + + /* + |-------------------------------------------------------------------------- + | Stapler Default Style + |-------------------------------------------------------------------------- + | + | The default style returned from the Stapler file location helper methods. + | An unaltered version of uploaded file is always stored within the 'original' + | style, however the default_style can be set to point to any of the defined + | styles within the styles array. + | + */ + + 'default_style' => 'original', + + /* + |-------------------------------------------------------------------------- + | Stapler Styles + |-------------------------------------------------------------------------- + | + | An array of image sizes defined for the file attachment. + | Stapler will attempt to format the file upload into the defined style. + | + */ + + 'styles' => [], + + /* + |-------------------------------------------------------------------------- + | Convert Options + |-------------------------------------------------------------------------- + | + | An array of options for setting the quality and DPI of resized images. + | Default values are 75 for Jpeg quality and 72 dpi for x/y-resolution. + | Please see the Imagine\Image documentation for more details. + | + */ + + 'convert_options' => [], + + /* + |-------------------------------------------------------------------------- + | Keep Old Files Flag + |-------------------------------------------------------------------------- + | + | Set this to true in order to prevent older file uploads from being deleted + | from storage when a record is updated with a new upload. + | + */ + + 'keep_old_files' => false, + + /* + |-------------------------------------------------------------------------- + | Preserve Files Flag + |-------------------------------------------------------------------------- + | + | Set this to true in order to prevent file uploads from being deleted + | from the file system when an attachment is destroyed. Essentially this + | ensures the preservation of uploads event after their corresponding database + | records have been removed. + | + */ + 'preserve_files' => false ]; diff --git a/src/views/migration.php b/src/views/migration.php index d0ecef9..75cd1bd 100644 --- a/src/views/migration.php +++ b/src/views/migration.php @@ -5,39 +5,39 @@ class extends Migration { - /** - * Make changes to the table. - * - * @return void - */ - public function up() - { - Schema::table('', function(Blueprint $table) { - - $table->string('_file_name')->nullable(); - $table->integer('_file_size')->nullable(); - $table->string('_content_type')->nullable(); - $table->timestamp('_updated_at')->nullable(); - - }); - - } - - /** - * Revert the changes to the table. - * - * @return void - */ - public function down() - { - Schema::table('', function(Blueprint $table) { - - $table->dropColumn('_file_name'); - $table->dropColumn('_file_size'); - $table->dropColumn('_content_type'); - $table->dropColumn('_updated_at'); - - }); - } + /** + * Make changes to the table. + * + * @return void + */ + public function up() + { + Schema::table('', function(Blueprint $table) { + + $table->string('_file_name')->nullable(); + $table->integer('_file_size')->nullable(); + $table->string('_content_type')->nullable(); + $table->timestamp('_updated_at')->nullable(); + + }); + + } + + /** + * Revert the changes to the table. + * + * @return void + */ + public function down() + { + Schema::table('', function(Blueprint $table) { + + $table->dropColumn('_file_name'); + $table->dropColumn('_file_size'); + $table->dropColumn('_content_type'); + $table->dropColumn('_updated_at'); + + }); + } } diff --git a/tests/TestCase.php b/tests/TestCase.php index fecc95d..0048a8d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -5,20 +5,20 @@ class TestCase extends \PHPUnit_Framework_TestCase { - /** - * Bootstrap the test environemnt: - * - Create an application instance and register it within itself. - * - Register the package service provider with the app. - * - Set the APP facade. - * - * @return void - */ - public function setUp() - { - $app = new Application; - $app->instance('app', $app); - $app->register('Codesleeve\LaravelStapler\LaravelStaplerServiceProvider'); - Facade::setFacadeApplication($app); - } + /** + * Bootstrap the test environemnt: + * - Create an application instance and register it within itself. + * - Register the package service provider with the app. + * - Set the APP facade. + * + * @return void + */ + public function setUp() + { + $app = new Application; + $app->instance('app', $app); + $app->register('Codesleeve\LaravelStapler\LaravelStaplerServiceProvider'); + Facade::setFacadeApplication($app); + } }