mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
Merge pull request #222 from colymba/pulls/master/php81
ENH PHP 8.1 compatibility
This commit is contained in:
commit
ece0e209ef
@ -111,8 +111,8 @@ class ArchiveHandler extends Handler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$doneCount = count($response->getSuccessRecords());
|
$doneCount = count($response->getSuccessRecords() ?? []);
|
||||||
$failCount = count($response->getFailedRecords());
|
$failCount = count($response->getFailedRecords() ?? []);
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'Archived %1$d of %2$d records.',
|
'Archived %1$d of %2$d records.',
|
||||||
$doneCount,
|
$doneCount,
|
||||||
|
@ -104,7 +104,7 @@ class DeleteHandler extends Handler
|
|||||||
$record->delete();
|
$record->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
$doneCount = count($response->getSuccessRecords());
|
$doneCount = count($response->getSuccessRecords() ?? []);
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'Deleted %1$d records.',
|
'Deleted %1$d records.',
|
||||||
$doneCount
|
$doneCount
|
||||||
|
@ -148,7 +148,7 @@ class EditHandler extends Handler
|
|||||||
$recordsFieldList = new FieldList();
|
$recordsFieldList = new FieldList();
|
||||||
$config = $this->component->getConfig();
|
$config = $this->component->getConfig();
|
||||||
|
|
||||||
$editingCount = count($recordList);
|
$editingCount = count($recordList ?? []);
|
||||||
$modelClass = $this->gridField->getModelClass();
|
$modelClass = $this->gridField->getModelClass();
|
||||||
$singleton = singleton($modelClass);
|
$singleton = singleton($modelClass);
|
||||||
$titleModelClass = (($editingCount > 1) ? $singleton->i18n_plural_name() : $singleton->i18n_singular_name());
|
$titleModelClass = (($editingCount > 1) ? $singleton->i18n_plural_name() : $singleton->i18n_singular_name());
|
||||||
@ -341,7 +341,7 @@ class EditHandler extends Handler
|
|||||||
protected function unEscapeFieldName($fieldName)
|
protected function unEscapeFieldName($fieldName)
|
||||||
{
|
{
|
||||||
$parts = array();
|
$parts = array();
|
||||||
$match = preg_match('/record_(\d+)_(\w+)/i', $fieldName, $parts);
|
$match = preg_match('/record_(\d+)_(\w+)/i', $fieldName ?? '', $parts);
|
||||||
|
|
||||||
if (!$match) {
|
if (!$match) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -111,8 +111,8 @@ class PublishHandler extends Handler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$doneCount = count($response->getSuccessRecords());
|
$doneCount = count($response->getSuccessRecords() ?? []);
|
||||||
$failCount = count($response->getFailedRecords());
|
$failCount = count($response->getFailedRecords() ?? []);
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'Published %1$d of %2$d records.',
|
'Published %1$d of %2$d records.',
|
||||||
$doneCount,
|
$doneCount,
|
||||||
|
@ -111,8 +111,8 @@ class UnPublishHandler extends Handler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$doneCount = count($response->getSuccessRecords());
|
$doneCount = count($response->getSuccessRecords() ?? []);
|
||||||
$failCount = count($response->getFailedRecords());
|
$failCount = count($response->getFailedRecords() ?? []);
|
||||||
$message = sprintf(
|
$message = sprintf(
|
||||||
'UnPublished %1$d of %2$d records.',
|
'UnPublished %1$d of %2$d records.',
|
||||||
$doneCount,
|
$doneCount,
|
||||||
|
@ -79,7 +79,7 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
|
|||||||
*/
|
*/
|
||||||
public function setConfig($reference, $value)
|
public function setConfig($reference, $value)
|
||||||
{
|
{
|
||||||
if (!array_key_exists($reference, $this->config)) {
|
if (!array_key_exists($reference, $this->config ?? [])) {
|
||||||
user_error("Unknown option reference: $reference", E_USER_ERROR);
|
user_error("Unknown option reference: $reference", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
|
|||||||
*/
|
*/
|
||||||
public function addBulkAction($handlerClassName, $action = null)
|
public function addBulkAction($handlerClassName, $action = null)
|
||||||
{
|
{
|
||||||
if (!class_exists($handlerClassName)) {
|
if (!class_exists($handlerClassName ?? '')) {
|
||||||
user_error("Bulk action handler not found: $handlerClassName", E_USER_ERROR);
|
user_error("Bulk action handler not found: $handlerClassName", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
|
|||||||
*/
|
*/
|
||||||
public function augmentColumns($gridField, &$columns)
|
public function augmentColumns($gridField, &$columns)
|
||||||
{
|
{
|
||||||
if (!in_array('BulkSelect', $columns)) {
|
if (!in_array('BulkSelect', $columns ?? [])) {
|
||||||
$columns[] = 'BulkSelect';
|
$columns[] = 'BulkSelect';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
|
|||||||
Requirements::css('colymba/gridfield-bulk-editing-tools:client/dist/styles/main.css');
|
Requirements::css('colymba/gridfield-bulk-editing-tools:client/dist/styles/main.css');
|
||||||
Requirements::add_i18n_javascript('colymba/gridfield-bulk-editing-tools:client/lang');
|
Requirements::add_i18n_javascript('colymba/gridfield-bulk-editing-tools:client/lang');
|
||||||
|
|
||||||
if (!count($this->config['actions'])) {
|
if (!count($this->config['actions'] ?? [])) {
|
||||||
user_error('Trying to use BulkManager without any bulk action.', E_USER_ERROR);
|
user_error('Trying to use BulkManager without any bulk action.', E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ class BulkManager implements GridField_HTMLProvider, GridField_ColumnProvider, G
|
|||||||
'Select' => array(
|
'Select' => array(
|
||||||
'Label' => _t('GRIDFIELD_BULK_MANAGER.SELECT_ALL_LABEL', 'Select all'),
|
'Label' => _t('GRIDFIELD_BULK_MANAGER.SELECT_ALL_LABEL', 'Select all'),
|
||||||
),
|
),
|
||||||
'Colspan' => (count($gridField->getColumns()) - 1),
|
'Colspan' => (count($gridField->getColumns() ?? []) - 1),
|
||||||
);
|
);
|
||||||
|
|
||||||
$templateData = new ArrayData($templateData);
|
$templateData = new ArrayData($templateData);
|
||||||
|
@ -344,7 +344,7 @@ class HTTPBulkToolsResponse extends HTTPResponse
|
|||||||
$body['records']['failed'] = $this->failedRecords;
|
$body['records']['failed'] = $this->failedRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($body['records']['success']) && count($body['records']['success']) === 0) {
|
if (isset($body['records']['success']) && count($body['records']['success'] ?? []) === 0) {
|
||||||
$body['isWarning'] = true;
|
$body['isWarning'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class BulkUploadHandler extends RequestHandler
|
|||||||
$bulkToolsResponse = new HTTPBulkToolsResponse(false, $this->gridField);
|
$bulkToolsResponse = new HTTPBulkToolsResponse(false, $this->gridField);
|
||||||
$bulkToolsResponse->addSuccessRecord($record);
|
$bulkToolsResponse->addSuccessRecord($record);
|
||||||
|
|
||||||
$responseData['bulkTools'] = json_decode($bulkToolsResponse->getBody());
|
$responseData['bulkTools'] = json_decode($bulkToolsResponse->getBody() ?? '');
|
||||||
$uploadResponse->setBody(json_encode(array($responseData)));
|
$uploadResponse->setBody(json_encode(array($responseData)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ class BulkUploader implements GridField_HTMLProvider, GridField_URLHandler
|
|||||||
*/
|
*/
|
||||||
public function setConfig($reference, $value)
|
public function setConfig($reference, $value)
|
||||||
{
|
{
|
||||||
if (!array_key_exists($reference, $this->config)) {
|
if (!array_key_exists($reference, $this->config ?? [])) {
|
||||||
user_error("Unknown option reference: $reference", E_USER_ERROR);
|
user_error("Unknown option reference: $reference", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ class BulkUploader implements GridField_HTMLProvider, GridField_URLHandler
|
|||||||
$uploadField = $this->bulkUploadField($gridField);
|
$uploadField = $this->bulkUploadField($gridField);
|
||||||
|
|
||||||
$data = ArrayData::create(array(
|
$data = ArrayData::create(array(
|
||||||
'Colspan' => (count($gridField->getColumns())),
|
'Colspan' => (count($gridField->getColumns() ?? [])),
|
||||||
'UploadField' => $uploadField->Field() // call ->Field() to get requirements in right order
|
'UploadField' => $uploadField->Field() // call ->Field() to get requirements in right order
|
||||||
));
|
));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user