mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
Merge pull request #15 from s-m/image-subclass-fix
FIX: Forgot to include the classname that can be derived from the config
This commit is contained in:
commit
8a85918e33
@ -120,15 +120,23 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the classname of the first has_one image-relation of the managed DataObject
|
* Returns the classname of the first has_one image-relation of the managed DataObject or the
|
||||||
|
* classname of the given fieldname
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getDefaultRecordImageClass()
|
private function getRecordImageClass()
|
||||||
{
|
{
|
||||||
$recordClass = $this->gridField->list->dataClass;
|
$recordClass = $this->gridField->list->dataClass;
|
||||||
$recordHasOneFields = Config::inst()->get($recordClass, 'has_one', Config::INHERITED);
|
$recordHasOneFields = Config::inst()->get($recordClass, 'has_one', Config::INHERITED);
|
||||||
|
|
||||||
|
$fieldName = $this->component->getConfig('imageFieldName');
|
||||||
|
if($fieldName != null)
|
||||||
|
{
|
||||||
|
// filter out ID at the end:
|
||||||
|
$fieldName = substr($fieldName, 0, -2);
|
||||||
|
return $recordHasOneFields[$fieldName];
|
||||||
|
}
|
||||||
foreach($recordHasOneFields as $field => $type)
|
foreach($recordHasOneFields as $field => $type)
|
||||||
{
|
{
|
||||||
if($type == 'Image' || is_subclass_of($type, 'Image'))
|
if($type == 'Image' || is_subclass_of($type, 'Image'))
|
||||||
@ -306,7 +314,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
|||||||
|
|
||||||
// Process the uploaded file
|
// Process the uploaded file
|
||||||
if (!$return['error']) {
|
if (!$return['error']) {
|
||||||
$fileObject = Object::create($this->getDefaultRecordImageClass());
|
$fileObject = Object::create($this->getRecordImageClass());
|
||||||
|
|
||||||
// Get the uploaded file into a new file object.
|
// Get the uploaded file into a new file object.
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user