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

Commit e566dd7

Browse files
authored
Merge pull request #187 from stripthis/2.0
Fix deprecated warnings for CakePHP 3.7
2 parents 2bda670 + 2b2f135 commit e566dd7

File tree

12 files changed

+162
-76
lines changed

12 files changed

+162
-76
lines changed

.scrutinizer.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ build:
2121
project_setup:
2222
before:
2323
- mysql -e "CREATE DATABASE test"
24-
- sudo composer self-update
25-
- composer --version
26-
- composer global require hirak/prestissimo --no-plugins
27-
- composer install --prefer-dist --no-interaction
24+
2825
tests:
2926
override:
3027
-

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ php:
55
- 7.0
66
- 7.1
77
- 7.2
8+
- 7.3
89
- nightly
910

1011
env:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "burzum/cakephp-file-storage",
33
"type": "cakephp-plugin",
4-
"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.",
4+
"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.",
55
"keywords": ["file", "filesystem", "media", "abstraction", "upload", "cakephp", "storage"],
66
"homepage": "http://github.com/burzum/cakephp-file-storage-plugin",
77
"license": "MIT",
@@ -23,7 +23,7 @@
2323
"cakephp/cakephp": "^3.6.0",
2424
"cakephp/plugin-installer": "^1.0.0",
2525
"cakephp/migrations": "^2.0.0",
26-
"knplabs/gaufrette": "^0.7.0"
26+
"knplabs/gaufrette": "^0.7.0|^0.8.0"
2727
},
2828
"require-dev": {
2929
"phpunit/phpunit": "^5.7.14|^6.0",

composer.lock

Lines changed: 78 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/bootstrap.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11
<?php
22
use Burzum\FileStorage\Storage\Listener\ImageProcessingListener;
33
use Burzum\FileStorage\Storage\Listener\LocalListener;
4+
use Cake\Core\Configure;
45
use Cake\Core\Plugin;
56
use Cake\Event\EventManager;
67
use Cake\Log\Log;
78

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

11-
if (Plugin::loaded('Burzum/Imagine')) {
12+
if (\version_compare(Configure::version(), '3.7.0', 'ge')) {
13+
$imaginePluginIsLoaded = Plugin::isLoaded('Burzum/Imagine');
14+
} else {
15+
$imaginePluginIsLoaded = Plugin::loaded('Burzum/Imagine');
16+
}
17+
18+
if ($imaginePluginIsLoaded) {
1219
$listener = new ImageProcessingListener();
1320
EventManager::instance()->on($listener);
1421
}
1522

16-
Log::setConfig('FileStorage', [
17-
'className' => 'File',
18-
'path' => LOGS,
19-
'levels' => [],
20-
'scopes' => ['fileStorage'],
21-
'file' => 'fileStorage.log',
22-
]);
23+
if (Log::getConfig('FileStorage') === null) {
24+
Log::setConfig('FileStorage', [
25+
'className' => 'File',
26+
'path' => LOGS,
27+
'levels' => [],
28+
'scopes' => ['fileStorage'],
29+
'file' => 'fileStorage.log',
30+
]);
31+
}

src/Plugin.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Burzum\FileStorage;
4+
5+
use Cake\Core\BasePlugin;
6+
7+
/**
8+
* FileStorage Plugin for CakePHP
9+
*/
10+
class Plugin extends BasePlugin {
11+
}

src/Storage/Listener/BaseListener.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ public function afterSave(Event $event, EntityInterface $entity) {
121121
* @return void
122122
*/
123123
public function imagePath(Event $event) {
124-
$event->setData($event->getData()+ [
124+
$event->setData($event->getData() + [
125125
'image' => null,
126126
'version' => null,
127127
'options' => [],
128128
'pathType' => 'fullPath'
129129
]);
130130

131-
$data = $event->getData()+ [
131+
$data = $event->getData() + [
132132
'image' => null,
133133
'version' => null,
134134
'options' => [],
@@ -188,7 +188,7 @@ protected function _processImages(Event $event, $method) {
188188
}
189189

190190
$versions = $this->_getVersionData($event);
191-
$options = (array)$event->getData('options') ;
191+
$options = (array)$event->getData('options');
192192

193193
$this->loadImageProcessingFromConfig();
194194
$event->result = $this->{$method}(
@@ -209,10 +209,11 @@ protected function _processImages(Event $event, $method) {
209209
* @return array
210210
*/
211211
protected function _getVersionData($event) {
212-
if (isset($event->data['versions'])) {
213-
$versions = $event->data['versions'];
214-
} elseif (isset($event->data['operations'])) {
215-
$versions = array_keys($event->data['operations']);
212+
$data = $event->getData();
213+
if (isset($data['versions'])) {
214+
$versions = $data['versions'];
215+
} elseif (isset($data['operations'])) {
216+
$versions = array_keys($data['operations']);
216217
} else {
217218
$versions = [];
218219
}

0 commit comments

Comments
 (0)