Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
Merge 2b2f135 into 2bda670
Browse files Browse the repository at this point in the history
  • Loading branch information
stripthis committed Apr 3, 2019
2 parents 2bda670 + 2b2f135 commit cede6b6
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 76 deletions.
5 changes: 1 addition & 4 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ build:
project_setup:
before:
- mysql -e "CREATE DATABASE test"
- sudo composer self-update
- composer --version
- composer global require hirak/prestissimo --no-plugins
- composer install --prefer-dist --no-interaction

tests:
override:
-
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ php:
- 7.0
- 7.1
- 7.2
- 7.3
- nightly

env:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "burzum/cakephp-file-storage",
"type": "cakephp-plugin",
"description": "This plugin is giving you the possibility to store files in virtually and kind of storage backend. This plugin is wrapping the Gaufrette library (https://github.com/KnpLabs/Gaufrette) library in a CakePHP fashion and provides a simple way to use the storage adapters through the StorageManager class.",
"description": "This plugin is giving you the possibility to store files in virtually any kind of storage backend. This plugin is wrapping the Gaufrette library (https://github.com/KnpLabs/Gaufrette) library in a CakePHP fashion and provides a simple way to use the storage adapters through the StorageManager class.",
"keywords": ["file", "filesystem", "media", "abstraction", "upload", "cakephp", "storage"],
"homepage": "http://github.com/burzum/cakephp-file-storage-plugin",
"license": "MIT",
Expand All @@ -23,7 +23,7 @@
"cakephp/cakephp": "^3.6.0",
"cakephp/plugin-installer": "^1.0.0",
"cakephp/migrations": "^2.0.0",
"knplabs/gaufrette": "^0.7.0"
"knplabs/gaufrette": "^0.7.0|^0.8.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7.14|^6.0",
Expand Down
104 changes: 78 additions & 26 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 17 additions & 8 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
<?php
use Burzum\FileStorage\Storage\Listener\ImageProcessingListener;
use Burzum\FileStorage\Storage\Listener\LocalListener;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Event\EventManager;
use Cake\Log\Log;

$listener = new LocalListener();
EventManager::instance()->on($listener);

if (Plugin::loaded('Burzum/Imagine')) {
if (\version_compare(Configure::version(), '3.7.0', 'ge')) {
$imaginePluginIsLoaded = Plugin::isLoaded('Burzum/Imagine');
} else {
$imaginePluginIsLoaded = Plugin::loaded('Burzum/Imagine');
}

if ($imaginePluginIsLoaded) {
$listener = new ImageProcessingListener();
EventManager::instance()->on($listener);
}

Log::setConfig('FileStorage', [
'className' => 'File',
'path' => LOGS,
'levels' => [],
'scopes' => ['fileStorage'],
'file' => 'fileStorage.log',
]);
if (Log::getConfig('FileStorage') === null) {
Log::setConfig('FileStorage', [
'className' => 'File',
'path' => LOGS,
'levels' => [],
'scopes' => ['fileStorage'],
'file' => 'fileStorage.log',
]);
}
11 changes: 11 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Burzum\FileStorage;

use Cake\Core\BasePlugin;

/**
* FileStorage Plugin for CakePHP
*/
class Plugin extends BasePlugin {
}
15 changes: 8 additions & 7 deletions src/Storage/Listener/BaseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ public function afterSave(Event $event, EntityInterface $entity) {
* @return void
*/
public function imagePath(Event $event) {
$event->setData($event->getData()+ [
$event->setData($event->getData() + [
'image' => null,
'version' => null,
'options' => [],
'pathType' => 'fullPath'
]);

$data = $event->getData()+ [
$data = $event->getData() + [
'image' => null,
'version' => null,
'options' => [],
Expand Down Expand Up @@ -188,7 +188,7 @@ protected function _processImages(Event $event, $method) {
}

$versions = $this->_getVersionData($event);
$options = (array)$event->getData('options') ;
$options = (array)$event->getData('options');

$this->loadImageProcessingFromConfig();
$event->result = $this->{$method}(
Expand All @@ -209,10 +209,11 @@ protected function _processImages(Event $event, $method) {
* @return array
*/
protected function _getVersionData($event) {
if (isset($event->data['versions'])) {
$versions = $event->data['versions'];
} elseif (isset($event->data['operations'])) {
$versions = array_keys($event->data['operations']);
$data = $event->getData();
if (isset($data['versions'])) {
$versions = $data['versions'];
} elseif (isset($data['operations'])) {
$versions = array_keys($data['operations']);
} else {
$versions = [];
}
Expand Down
Loading

0 comments on commit cede6b6

Please sign in to comment.