API Rename classes to be less confusing with the namespaces
This commit is contained in:
parent
57d7f6adee
commit
35fadcd3cf
14
.upgrade.yml
14
.upgrade.yml
|
@ -1,10 +1,10 @@
|
|||
mappings:
|
||||
GridFieldBulkActionDeleteHandler: Colymba\BulkManager\GridFieldBulkActionDeleteHandler
|
||||
GridFieldBulkActionEditHandler: Colymba\BulkManager\GridFieldBulkActionEditHandler
|
||||
GridFieldBulkActionHandler: Colymba\BulkManager\GridFieldBulkActionHandler
|
||||
GridFieldBulkActionUnlinkHandler: Colymba\BulkManager\GridFieldBulkActionUnlinkHandler
|
||||
GridFieldBulkManager: Colymba\BulkManager\GridFieldBulkManager
|
||||
GridFieldBulkActionDeleteHandler: Colymba\BulkManager\BulkAction\DeleteHandler
|
||||
GridFieldBulkActionEditHandler: Colymba\BulkManager\BulkAction\EditHandler
|
||||
GridFieldBulkActionHandler: Colymba\BulkManager\BulkAction\Handler
|
||||
GridFieldBulkActionUnlinkHandler: Colymba\BulkManager\BulkAction\UnlinkHandler
|
||||
GridFieldBulkManager: Colymba\BulkManager\BulkManager
|
||||
BulkUploadField: Colymba\BulkUpload\BulkUploadField
|
||||
GridFieldBulkImageUpload: Colymba\BulkUpload\GridFieldBulkImageUpload
|
||||
GridFieldBulkUpload: Colymba\BulkUpload\GridFieldBulkUpload
|
||||
GridFieldBulkUpload_Request: Colymba\BulkUpload\GridFieldBulkUpload_Request
|
||||
GridFieldBulkUpload: Colymba\BulkUpload\BulkUploader
|
||||
GridFieldBulkUpload_Request: Colymba\BulkUpload\BulkUploadRequest
|
||||
|
|
14
README.md
14
README.md
|
@ -28,7 +28,9 @@ Set of SilverStripe 4 GridField components to facilitate bulk file upload & reco
|
|||
* Download and copy module in SilverStripe root directory
|
||||
|
||||
## 3.0.0 deprecations
|
||||
The 3.x versions of this module require SilverStripe 4.x+, and PHP 5.5 or above.
|
||||
The 3.x versions of this module require SilverStripe 4.x+, and PHP 5.5 or above:
|
||||
|
||||
* Namespaces are implemented, and some class names have changed (see `.upgrade.yml` for mapping)
|
||||
|
||||
## 2.0.0 deprecations
|
||||
Major deprections in latest 2.0.0 release:
|
||||
|
@ -38,19 +40,23 @@ Major deprections in latest 2.0.0 release:
|
|||
## Bulk Upload
|
||||
Upload multiple images or files at once into DataObjects. Perfect for galleries and the like.
|
||||
|
||||
$config->addComponent(new \Colymba\BulkUpload\GridFieldBulkUpload());
|
||||
```php
|
||||
$config->addComponent(new \Colymba\BulkUpload\BulkUploader());
|
||||
```
|
||||
|
||||
See [BULK_UPLOAD.md](bulkUpload/BULK_UPLOAD.md) for detailed configuration.
|
||||
|
||||
## Bulk Manager
|
||||
Perform actions on multiple records straight from the GridField
|
||||
|
||||
$config->addComponent(new \Colymba\BulkManager\GridFieldBulkManager());
|
||||
```php
|
||||
$config->addComponent(new \Colymba\BulkManager\BulkManager());
|
||||
```
|
||||
|
||||
See [BULK_MANAGER.md](bulkManager/BULK_MANAGER.md) for detailed configuration.
|
||||
|
||||
## Interdependencies
|
||||
The `GridFieldBulkUpload` component makes use of `GridFieldBulkManager` to allow quick editing of the newly uploaded files. Although not nescessary for the component to work, adding `Colymba\BulkManager\GridFieldBulkManager` too to your `GridFieldConfig` will give you this advantage.
|
||||
The `BulkUploader` component makes use of `BulkManager` to allow quick editing of the newly uploaded files. Although not nescessary for the component to work, adding `Colymba\BulkManager\BulkManager` too to your `GridFieldConfig` will give you this advantage.
|
||||
|
||||
#### @TODO
|
||||
* Add individual actions for each upload (update + cancel)
|
||||
|
|
|
@ -5,14 +5,14 @@ Perform actions on multiple records straight from the GridField. Comes with *unl
|
|||
Simply add component to your `GridFieldConfig`
|
||||
|
||||
```php
|
||||
$config->addComponent(new \Colymba\BulkManager\GridFieldBulkManager());
|
||||
$config->addComponent(new \Colymba\BulkManager\BulkManager());
|
||||
```
|
||||
|
||||
## Configuration
|
||||
The component's options can be configurated individually or in bulk through the 'config' functions like this:
|
||||
|
||||
```php
|
||||
$config->getComponentByType('Colymba\\BulkManager\\GridFieldBulkManager')->setConfig($reference, $value);
|
||||
$config->getComponentByType('Colymba\\BulkManager\\BulkManager')->setConfig($reference, $value);
|
||||
```
|
||||
|
||||
### $config overview
|
||||
|
@ -27,7 +27,7 @@ To add a custom bulk action to the list use:
|
|||
|
||||
```php
|
||||
$config
|
||||
->getComponentByType('Colymba\\BulkManager\\GridFieldBulkManager')
|
||||
->getComponentByType('Colymba\\BulkManager\\BulkManager')
|
||||
->addBulkAction('actionName', 'Dropdown label', 'ActionHandlerClassName', $frontEndConfig)
|
||||
```
|
||||
|
||||
|
@ -36,9 +36,9 @@ You can omit the handler's class name and the front-end config array, those will
|
|||
* `$config = array( 'isAjax' => true, 'icon' => 'accept', 'isDestructive' => false )`
|
||||
|
||||
#### Custom action handler
|
||||
When creating your own bulk action `RequestHandler`, you should extend `GridFieldBulkActionHandler` which will expose 2 usefull functions `getRecordIDList()` and `getRecords()` returning either an array with the selected records IDs or a `DataList` of the selected records.
|
||||
When creating your own bulk action `RequestHandler`, you should extend `Colymba\BulkManager\BulkAction\Handler` which will expose 2 useful functions `getRecordIDList()` and `getRecords()` returning either an array with the selected records IDs or a `DataList` of the selected records.
|
||||
|
||||
Make sure to define your `$allowed_actions` and `$url_handlers` on your custom bulk action handler. See `GridFieldBulkActionEditHandler`, `GridFieldBulkActionDeleteHandler` and `GridFieldBulkActionUnlinkHandler` for examples.
|
||||
Make sure to define your `$allowed_actions` and `$url_handlers` on your custom bulk action handler. See `Handler`, `DeleteHandler` and `UnlinkHandler` for examples.
|
||||
|
||||
#### Front-end config
|
||||
The last `addBulkAction()` parameter lets you pass an array with configuration options for the UI/UX:
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Colymba\BulkManager;
|
||||
namespace Colymba\BulkManager\BulkAction;
|
||||
|
||||
use Colymba\BulkManager\GridFieldBulkActionHandler;
|
||||
use Colymba\BulkManager\BulkAction\Handler;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Convert;
|
||||
|
@ -12,7 +12,7 @@ use SilverStripe\Core\Convert;
|
|||
*
|
||||
* @author colymba
|
||||
*/
|
||||
class GridFieldBulkActionDeleteHandler extends GridFieldBulkActionHandler
|
||||
class DeleteHandler extends Handler
|
||||
{
|
||||
/**
|
||||
* RequestHandler allowed actions.
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Colymba\BulkManager;
|
||||
namespace Colymba\BulkManager\BulkAction;
|
||||
|
||||
use Colymba\BulkManager\GridFieldBulkActionHandler;
|
||||
use Colymba\BulkManager\BulkAction\Handler;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
|
@ -19,7 +19,7 @@ use SilverStripe\View\Requirements;
|
|||
*
|
||||
* @author colymba
|
||||
*/
|
||||
class GridFieldBulkActionEditHandler extends GridFieldBulkActionHandler
|
||||
class EditHandler extends Handler
|
||||
{
|
||||
/**
|
||||
* RequestHandler allowed actions.
|
||||
|
@ -230,7 +230,7 @@ class GridFieldBulkActionEditHandler extends GridFieldBulkActionHandler
|
|||
* based on component's config
|
||||
* and escape each field with unique name.
|
||||
*
|
||||
* See {@link GridFieldBulkManager} component for filtering config.
|
||||
* See {@link BulkManager} component for filtering config.
|
||||
*
|
||||
* @param FieldList $fields Record's CMS Fields
|
||||
* @param int $id Record's ID, used fir unique name
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Colymba\BulkManager;
|
||||
namespace Colymba\BulkManager\BulkAction;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
|
@ -16,7 +16,7 @@ use SilverStripe\View\ArrayData;
|
|||
*
|
||||
* @author colymba
|
||||
*/
|
||||
class GridFieldBulkActionHandler extends RequestHandler
|
||||
class Handler extends RequestHandler
|
||||
{
|
||||
/**
|
||||
* Related GridField instance.
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Colymba\BulkManager;
|
||||
namespace Colymba\BulkManager\BulkAction;
|
||||
|
||||
use Colymba\BulkManager\GridFieldBulkActionHandler;
|
||||
use Colymba\BulkManager\BulkAction\Handler;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
|
@ -12,7 +12,7 @@ use SilverStripe\Control\HTTPResponse;
|
|||
*
|
||||
* @author colymba
|
||||
*/
|
||||
class GridFieldBulkActionUnlinkHandler extends GridFieldBulkActionHandler
|
||||
class UnlinkHandler extends Handler
|
||||
{
|
||||
/**
|
||||
* RequestHandler allowed actions.
|
|
@ -19,7 +19,7 @@ use SilverStripe\View\Requirements;
|
|||
*
|
||||
* @author colymba
|
||||
*/
|
||||
class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, GridField_URLHandler
|
||||
class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, GridField_URLHandler
|
||||
{
|
||||
/**
|
||||
* component configuration.
|
||||
|
@ -50,7 +50,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||
$this->config['actions'] = array(
|
||||
'bulkEdit' => array(
|
||||
'label' => _t('GRIDFIELD_BULK_MANAGER.EDIT_SELECT_LABEL', 'Edit'),
|
||||
'handler' => 'Colymba\\BulkManager\\GridFieldBulkActionEditHandler',
|
||||
'handler' => 'Colymba\\BulkManager\\BulkAction\\EditHandler',
|
||||
'config' => array(
|
||||
'isAjax' => false,
|
||||
'icon' => 'pencil',
|
||||
|
@ -59,7 +59,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||
),
|
||||
'unLink' => array(
|
||||
'label' => _t('GRIDFIELD_BULK_MANAGER.UNLINK_SELECT_LABEL', 'UnLink'),
|
||||
'handler' => 'Colymba\\BulkManager\\GridFieldBulkActionUnlinkHandler',
|
||||
'handler' => 'Colymba\\BulkManager\\BulkAction\\UnlinkHandler',
|
||||
'config' => array(
|
||||
'isAjax' => true,
|
||||
'icon' => 'chain--minus',
|
||||
|
@ -68,7 +68,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||
),
|
||||
'delete' => array(
|
||||
'label' => _t('GRIDFIELD_BULK_MANAGER.DELETE_SELECT_LABEL', 'Delete'),
|
||||
'handler' => 'Colymba\\BulkManager\\GridFieldBulkActionDeleteHandler',
|
||||
'handler' => 'Colymba\\BulkManager\\BulkAction\\DeleteHandler',
|
||||
'config' => array(
|
||||
'isAjax' => true,
|
||||
'icon' => 'decline',
|
||||
|
@ -147,7 +147,7 @@ class GridFieldBulkManager implements GridField_HTMLProvider, GridField_ColumnPr
|
|||
}
|
||||
|
||||
if (!$handler) {
|
||||
$handler = 'Colymba\\BulkManager\\GridFieldBulkAction' . ucfirst($name) . 'Handler';
|
||||
$handler = 'Colymba\\BulkManager\\BulkAction\\' . ucfirst($name) . 'Handler';
|
||||
}
|
||||
|
||||
if (!ClassInfo::exists($handler)) {
|
|
@ -5,7 +5,7 @@ A component for uploading images and/or files in bulk into `DataObject` managed
|
|||
Simplest usage, add the component to your `GridFieldConfig` as below. The component will find the first `Image` or `File` has_one relation to use on the managed `DataObject`.
|
||||
|
||||
```php
|
||||
$config->addComponent(new \Colymba\BulkUpload\GridFieldBulkUpload());
|
||||
$config->addComponent(new \Colymba\BulkUpload\BulkUploader());
|
||||
```
|
||||
|
||||
## Usage 2
|
||||
|
@ -14,7 +14,7 @@ $fileRelationName (string, optional): The name of the `Image` or `File` has_one
|
|||
$recordClassName (string, optional): The class name of the `DataObject` to create (Usefull if for example your `GridField` holds `DataObject`s of different classes, like when used with the `GridFieldAddNewMultiClass` component.)
|
||||
|
||||
```php
|
||||
$config->addComponent(new \Colymba\BulkUpload\GridFieldBulkUpload($fileRelationName, $recordClassName));
|
||||
$config->addComponent(new \Colymba\BulkUpload\BulkUploader($fileRelationName, $recordClassName));
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
@ -22,7 +22,7 @@ $config->addComponent(new \Colymba\BulkUpload\GridFieldBulkUpload($fileRelationN
|
|||
The component's option can be configurated through the `setConfig` functions like this:
|
||||
|
||||
```php
|
||||
$config->getComponentByType('GridFieldBulkUpload')->setConfig($reference, $value);
|
||||
$config->getComponentByType('Colymba\\BulkUpload\\BulkUploader')->setConfig($reference, $value);
|
||||
```
|
||||
|
||||
The available configuration options are:
|
||||
|
@ -37,7 +37,7 @@ The underlying `UploadField` can be configured via a set of APIs:
|
|||
For example, to set the upload folder, which is set by calling `setFolderName` on the `UploadField`, and setting the upload method as sequential, you would use the following:
|
||||
|
||||
```php
|
||||
$config->getComponentByType('Colymba\\BulkUpload\\GridFieldBulkUpload')
|
||||
$config->getComponentByType('Colymba\\BulkUpload\\BulkUploader')
|
||||
->setUfSetup('setFolderName', 'myFolder')
|
||||
->setUfConfig('sequentialUploads', true);
|
||||
```
|
||||
|
@ -46,4 +46,4 @@ Please see the [`UploadField` api](http://api.silverstripe.org/master/class-Uplo
|
|||
|
||||
|
||||
## Bulk Editing
|
||||
To get a quick edit shortcut to all the newly upload files, please also add the `Colymba\BulkUpload\GridFieldBulkManager` component to your `GridFieldConfig`.
|
||||
To get a quick edit shortcut to all the newly upload files, please also add the `Colymba\BulkManager\BulkManager` component to your `GridFieldConfig`.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Colymba\BulkUpload;
|
||||
|
||||
use Colymba\BulkUpload\GridFieldBulkUpload_Request;
|
||||
use Colymba\BulkUpload\BulkUploaderRequest;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Forms\FormAction;
|
||||
|
@ -18,7 +18,7 @@ use SilverStripe\View\Requirements;
|
|||
*
|
||||
* @author colymba
|
||||
*/
|
||||
class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandler
|
||||
class BulkUploader implements GridField_HTMLProvider, GridField_URLHandler
|
||||
{
|
||||
/**
|
||||
* Component configuration.
|
||||
|
@ -107,7 +107,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
|||
public function setConfig($reference, $value)
|
||||
{
|
||||
if (in_array($reference, array('folderName', 'maxFileSize', 'sequentialUploads', 'canAttachExisting', 'canPreviewFolder'))) {
|
||||
Deprecation::notice('2.1.0', "GridFieldBulkUpload 'setConfig()' doesn't support '$reference' anymore. Please use 'setUfConfig()', 'setUfSetup()' or 'setUfValidatorSetup()' instead.");
|
||||
Deprecation::notice('2.1.0', "BulkUploader 'setConfig()' doesn't support '$reference' anymore. Please use 'setUfConfig()', 'setUfSetup()' or 'setUfValidatorSetup()' instead.");
|
||||
|
||||
if ($reference === 'folderName') {
|
||||
$this->setUfSetup('setFolderName', $value);
|
||||
|
@ -320,7 +320,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
|||
|
||||
->setRecord(DataObject::create()) // avoid UploadField to get auto-config from the Page (e.g fix allowedMaxFileNumber)
|
||||
|
||||
->setTemplate('GridFieldBulkUploadField')
|
||||
->setTemplate('BulkUploadField')
|
||||
->setDownloadTemplateName('colymba-bulkuploaddownloadtemplate')
|
||||
|
||||
->setConfig('url', $gridField->Link('bulkupload/upload'))
|
||||
|
@ -366,7 +366,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
|||
}
|
||||
|
||||
// check BulkManager exists
|
||||
$bulkManager = $gridField->getConfig()->getComponentsByType('Colymba\\BulkManager\\GridFieldBulkManager');
|
||||
$bulkManager = $gridField->getConfig()->getComponentsByType('Colymba\\BulkManager\\BulkManager');
|
||||
|
||||
// upload management buttons
|
||||
$finishButton = FormAction::create('Finish', _t('GRIDFIELD_BULK_UPLOAD.FINISH_BTN_LABEL', 'Finish'))
|
||||
|
@ -420,7 +420,7 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
|||
Requirements::add_i18n_javascript(BULKEDITTOOLS_PATH . '/lang/js');
|
||||
|
||||
return array(
|
||||
'header' => $data->renderWith('Colymba\\BulkUpload\\GridFieldBulkUpload'),
|
||||
'header' => $data->renderWith('Colymba\\BulkUpload\\BulkUploader'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -452,8 +452,8 @@ class GridFieldBulkUpload implements GridField_HTMLProvider, GridField_URLHandle
|
|||
*/
|
||||
public function handleBulkUpload($gridField, $request)
|
||||
{
|
||||
$controller = $gridField->getForm()->Controller();
|
||||
$handler = new GridFieldBulkUpload_Request($gridField, $this, $controller);
|
||||
$controller = $gridField->getForm()->getController();
|
||||
$handler = new BulkUploaderRequest($gridField, $this, $controller);
|
||||
|
||||
return $handler->handleRequest($request, DataModel::inst());
|
||||
}
|
|
@ -17,7 +17,7 @@ use SilverStripe\ORM\DataObject;
|
|||
*
|
||||
* @author colymba
|
||||
*/
|
||||
class GridFieldBulkUpload_Request extends RequestHandler
|
||||
class BulkUploaderRequest extends RequestHandler
|
||||
{
|
||||
/**
|
||||
* Gridfield instance.
|
||||
|
@ -29,7 +29,7 @@ class GridFieldBulkUpload_Request extends RequestHandler
|
|||
/**
|
||||
* Bulk upload component.
|
||||
*
|
||||
* @var GridFieldBulkUpload
|
||||
* @var BulkUploader
|
||||
*/
|
||||
protected $component;
|
||||
|
|
@ -2,22 +2,22 @@
|
|||
|
||||
namespace Colymba\BulkUpload;
|
||||
|
||||
use Colymba\BulkUpload\GridFieldBulkUpload;
|
||||
use Colymba\BulkUpload\BulkUploader;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
|
||||
/**
|
||||
* Legacy GridFieldBulkImageUpload component.
|
||||
*
|
||||
* @deprecated 2.0 "GridFieldBulkImageUpload" is deprecated, use {@link GridFieldBulkUpload} class instead.
|
||||
* @deprecated 2.0 "GridFieldBulkImageUpload" is deprecated, use {@link BulkUploader} class instead.
|
||||
*
|
||||
* @author colymba
|
||||
*/
|
||||
class GridFieldBulkImageUpload extends GridFieldBulkUpload
|
||||
class GridFieldBulkImageUpload extends BulkUploader
|
||||
{
|
||||
/**
|
||||
* Component constructor.
|
||||
*
|
||||
* @deprecated 2.0 "GridFieldBulkImageUpload" is deprecated, use {@link GridFieldBulkUpload} class instead.
|
||||
* @deprecated 2.0 "GridFieldBulkImageUpload" is deprecated, use {@link BulkUploader} class instead.
|
||||
*
|
||||
* @param string $fileRelationName
|
||||
*/
|
||||
|
@ -25,9 +25,9 @@ class GridFieldBulkImageUpload extends GridFieldBulkUpload
|
|||
{
|
||||
Deprecation::notice(
|
||||
'2.0',
|
||||
'"GridFieldBulkImageUpload" is deprecated, use "GridFieldBulkUpload" class instead.'
|
||||
'"GridFieldBulkImageUpload" is deprecated, use "BulkUploader" class instead.'
|
||||
);
|
||||
|
||||
return new GridFieldBulkUpload($fileRelationName);
|
||||
return new BulkUploader($fileRelationName);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue