Skip to content

Commit

Permalink
Volume drivers (#329)
Browse files Browse the repository at this point in the history
* Added settings for box, onedrive and renamed dropbox to dropbox2

* Added missed end() statement

* Added options to dropbox test configuration

* Added options to dropbox, onedrive and box test configuration

* Added apiThumbnail element to onedrive

* Apply fixes from StyleCI (#328)

* Added tmpPath option to box settings
  • Loading branch information
helios-ag authored Oct 6, 2018
1 parent edd88ba commit 68a32dc
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 50 deletions.
47 changes: 40 additions & 7 deletions src/Configuration/ElFinderConfigurationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,46 @@ private function configureDriver(array $parameter)
$settings['path'] = $parameter['ftp_settings']['path'];

break;
case 'dropbox':
$settings['consumerKey'] = $parameter['dropbox_settings']['app_key'] ?: $parameter['dropbox_settings']['consumer_key'];
$settings['consumerSecret'] = $parameter['dropbox_settings']['app_secret'] ?: $parameter['dropbox_settings']['consumer_secret'];
$settings['accessToken'] = $parameter['dropbox_settings']['access_token'];
$settings['accessTokenSecret'] = $parameter['dropbox_settings']['access_token_secret'];
$settings['dropboxUid'] = $parameter['dropbox_settings']['dropbox_uid'];
$settings['metaCachePath'] = $parameter['dropbox_settings']['meta_cache_path'];
case 'dropbox2':
$settings['app_key'] = $parameter['dropbox2_settings']['app_key'];
$settings['app_secret'] = $parameter['dropbox2_settings']['app_secret'];
$settings['access_token'] = $parameter['dropbox2_settings']['access_token'];
$settings['aliasFormat'] = $parameter['dropbox2_settings']['aliasFormat'];
$settings['path'] = $parameter['dropbox2_settings']['path'];
$settings['separator'] = $parameter['dropbox2_settings']['separator'];
$settings['acceptedName'] = $parameter['dropbox2_settings']['acceptedName'];
$settings['rootCssClass'] = $parameter['dropbox2_settings']['rootCssClass'];
$settings['publishPermission'] = $parameter['dropbox2_settings']['publishPermission'];
$settings['getThumbSize'] = $parameter['dropbox2_settings']['getThumbSize'];

break;
case 'onedrive':
$settings['client_id'] = $parameter['onedrive_settings']['client_id'];
$settings['client_secret'] = $parameter['onedrive_settings']['client_secret'];
$settings['accessToken'] = $parameter['onedrive_settings']['accessToken'];
$settings['root'] = $parameter['onedrive_settings']['root'];
$settings['OneDriveApiClient'] = $parameter['onedrive_settings']['OneDriveApiClient'];
$settings['path'] = $parameter['onedrive_settings']['path'];
$settings['separator'] = $parameter['onedrive_settings']['separator'];
$settings['tmbPath'] = $parameter['onedrive_settings']['tmbPath'];
$settings['tmbURL'] = $parameter['onedrive_settings']['tmbURL'];
$settings['tmpPath'] = $parameter['onedrive_settings']['tmpPath'];
$settings['acceptedName'] = $parameter['onedrive_settings']['acceptedName'];
$settings['rootCssClass'] = $parameter['onedrive_settings']['rootCssClass'];
$settings['useApiThumbnail'] = $parameter['onedrive_settings']['useApiThumbnail'];

break;
case 'box':
$settings['client_id'] = $parameter['box_settings']['client_id'];
$settings['client_secret'] = $parameter['box_settings']['client_secret'];
$settings['accessToken'] = $parameter['box_settings']['accessToken'];
$settings['root'] = $parameter['box_settings']['root'];
$settings['path'] = $parameter['box_settings']['path'];
$settings['separator'] = $parameter['box_settings']['separator'];
$settings['tmbPath'] = $parameter['box_settings']['tmbPath'];
$settings['tmbURL'] = $parameter['box_settings']['tmbURL'];
$settings['acceptedName'] = $parameter['box_settings']['acceptedName'];
$settings['rootCssClass'] = $parameter['box_settings']['rootCssClass'];

break;
case 's3':
Expand Down
55 changes: 45 additions & 10 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,21 +219,56 @@ public function getConfigTreeBuilder()
->scalarNode('glide_key')->defaultValue('')->end()
->append($this->createPluginsNode())
->append($this->createDriverOptionsNode())
->arrayNode('dropbox_settings')
->arrayNode('dropbox2_settings')
->canBeEnabled()
->children()
->scalarNode('consumer_key')
->setDeprecated('You should use "app_key" to make the dropbox driver work prepoerly')
->end()
->scalarNode('consumer_secret')
->setDeprecated('You should use "app_secret" to make the dropbox driver work prepoerly')
->end()
->scalarNode('app_key')->end()
->scalarNode('app_secret')->end()
->scalarNode('access_token')->end()
->scalarNode('access_token_secret')->end()
->scalarNode('dropbox_uid')->end()
->scalarNode('meta_cache_path')->end()
->scalarNode('aliasFormat')->defaultValue('%s@Dropbox')->end()
->scalarNode('path')->defaultValue('/')->end()
->scalarNode('separator')->defaultValue('/')->end()
->scalarNode('acceptedName')->defaultValue('%s@Dropbox')->end()
->scalarNode('rootCssClass')->defaultValue('elfinder-navbar-root-dropbox')->end()
->arrayNode('publishPermission')
->children()
->scalarNode('requested_visibility')->defaultValue('public')->end()
->end()
->end()
->scalarNode('getThumbSize')->defaultValue('medium')->end()
->end()
->end()
->arrayNode('box_settings')
->canBeEnabled()
->children()
->scalarNode('client_id')->end()
->scalarNode('client_secret')->end()
->scalarNode('accessToken')->end()
->scalarNode('root')->defaultValue('Box.com')->end()
->scalarNode('path')->defaultValue('/')->end()
->scalarNode('separator')->defaultValue('/')->end()
->scalarNode('tmbPath')->defaultValue('')->end()
->scalarNode('tmbURL')->defaultValue('')->end()
->scalarNode('tmpPath')->defaultValue('')->end()
->scalarNode('acceptedName')->defaultValue('#^[^/\\?*:|"<>]*[^./\\?*:|"<>]$#')->end()
->scalarNode('rootCssClass')->defaultValue('elfinder-navbar-root-box')->end()
->end()
->end()
->arrayNode('onedrive_settings')
->canBeEnabled()
->children()
->scalarNode('client_id')->end()
->scalarNode('client_secret')->end()
->scalarNode('accessToken')->end()
->scalarNode('root')->defaultValue('OneDrive.com')->end()
->scalarNode('OneDriveApiClient')->defaultValue('')->end()
->scalarNode('path')->defaultValue('/')->end()
->scalarNode('separator')->defaultValue('/')->end()
->scalarNode('tmbPath')->defaultValue('')->end()
->scalarNode('tmbURL')->defaultValue('')->end()
->scalarNode('acceptedName')->defaultValue('#^[^/\\?*:|"<>]*[^./\\?*:|"<>]$#')->end()
->scalarNode('rootCssClass')->defaultValue('elfinder-navbar-root-onedrive')->end()
->booleanNode('useApiThumbnail')->defaultTrue()->end()
->end()
->end()
->arrayNode('ftp_settings')
Expand Down
59 changes: 45 additions & 14 deletions tests/DependencyInjection/ConfigurationLoadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

/**
* Class ConfigurationLoadTest.
*
* @package FM\ElfinderBundle\Tests\DependencyInjection
*/
class ConfigurationLoadTest extends AbstractExtensionConfigurationTestCase
{
Expand Down Expand Up @@ -108,22 +106,55 @@ public function testSupportsAllConfigFormats($path)
'create' => array(),
'extract' => array(),
),
'glide_url' => '',
'glide_key' => '',
'alias' => 'foo',
'tree_deep' => 1,
'upload_allow' => array('image/png', 'image/jpg', 'image/jpeg'),
'upload_order' => array('deny', 'allow'),
'defaults' => array('read' => true, 'write' => true),
'upload_deny' => array('all'),
'upload_max_size' => 0,
'dropbox_settings' => array(
'consumer_key' => 'some_consumer',
'consumer_secret' => 'con$umer',
'glide_url' => '',
'glide_key' => '',
'alias' => 'foo',
'tree_deep' => 1,
'upload_allow' => array('image/png', 'image/jpg', 'image/jpeg'),
'upload_order' => array('deny', 'allow'),
'defaults' => array('read' => true, 'write' => true),
'upload_deny' => array('all'),
'upload_max_size' => 0,
'dropbox2_settings' => array(
'aliasFormat' => '%s@Dropbox',
'path' => '/',
'separator' => '/',
'acceptedName' => '%s@Dropbox',
'rootCssClass' => 'elfinder-navbar-root-dropbox',
'getThumbSize' => 'medium',
'app_key' => 'some_consumer',
'app_secret' => 'con$umer',
'enabled' => true,
),
'box_settings' => array(
'client_id' => 'some_consumer',
'client_secret' => 'con$umer',
'accessToken' => 'token',
'root' => 'Box.com',
'path' => '/',
'separator' => '/',
'tmbPath' => '',
'tmbURL' => '',
'tmpPath' => '',
'acceptedName' => '#^[^/\?*:|"<>]*[^./\?*:|"<>]$#',
'rootCssClass' => 'elfinder-navbar-root-box',
'enabled' => true,
),
'onedrive_settings' => array(
'client_id' => 'some_consumer',
'client_secret' => 'con$umer',
'accessToken' => 'token',
'root' => 'OneDrive.com',
'OneDriveApiClient' => '',
'path' => '/',
'separator' => '/',
'tmbPath' => '',
'tmbURL' => '',
'acceptedName' => '#^[^/\?*:|"<>]*[^./\?*:|"<>]$#',
'rootCssClass' => 'elfinder-navbar-root-onedrive',
'useApiThumbnail' => true,
'enabled' => true,
),
'ftp_settings' => array(
'host' => '127.0.0.1',
'user' => 'root',
Expand Down
34 changes: 21 additions & 13 deletions tests/Fixtures/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,30 @@
'debug' => true,
'roots' => array(
'uploads' => array(
'driver' => 'LocalFileSystem',
'path' => 'uploads',
'show_hidden' => true,
'trash_hash' => 'trash_hash',
'alias' => 'foo',
'check_subfolders' => 1,
'tree_deep' => 1,
'upload_allow' => array('image/png', 'image/jpg', 'image/jpeg'),
'upload_deny' => array('all'),
'upload_max_size' => 0,
'dropbox_settings' => array(
'consumer_key' => 'some_consumer',
'consumer_secret' => 'con$umer',
'driver' => 'LocalFileSystem',
'path' => 'uploads',
'show_hidden' => true,
'trash_hash' => 'trash_hash',
'alias' => 'foo',
'check_subfolders' => 1,
'tree_deep' => 1,
'upload_allow' => array('image/png', 'image/jpg', 'image/jpeg'),
'upload_deny' => array('all'),
'upload_max_size' => 0,
'dropbox2_settings' => array(
'app_key' => 'some_consumer',
'app_secret' => 'con$umer',
),
'box_settings' => array(
'client_id' => 'some_consumer',
'client_secret' => 'con$umer',
'accessToken' => 'token',
),
'onedrive_settings' => array(
'client_id' => 'some_consumer',
'client_secret' => 'con$umer',
'accessToken' => 'token',
),
'ftp_settings' => array(
'host' => '127.0.0.1',
'user' => 'root',
Expand Down
14 changes: 11 additions & 3 deletions tests/Fixtures/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@
upload-deny="all"
upload-max-size="0"
>
<fm-elfinder:dropbox-settings
consumer-key="some_consumer"
consumer-secret="con$umer"
<fm-elfinder:dropbox2-settings
app-key="some_consumer"
app-secret="con$umer"
/>
<fm-elfinder:onedrive-settings
client-id="some_consumer"
client-secret="con$umer"
accessToken="token"
/>
<fm-elfinder:box-settings
client-id="some_consumer"
client-secret="con$umer"
accessToken="token"
/>
<fm-elfinder:ftp-settings
host="127.0.0.1"
user="root"
Expand Down
12 changes: 9 additions & 3 deletions tests/Fixtures/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ fm_elfinder:
alias: foo
tree_deep: 1
upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
dropbox_settings:
consumer_key: some_consumer
consumer_secret: con$umer
dropbox2_settings:
app_key: some_consumer
app_secret: con$umer
onedrive_settings:
client_id: some_consumer
client_secret: con$umer
accessToken: token
box_settings:
client_id: some_consumer
client_secret: con$umer
accessToken: token
ftp_settings:
host: 127.0.0.1
user: root
Expand Down

0 comments on commit 68a32dc

Please sign in to comment.