Skip to content

Commit

Permalink
refactor existing element handling to not drop attrs on existing elem…
Browse files Browse the repository at this point in the history
…ents
  • Loading branch information
patrickmj committed Mar 6, 2016
1 parent e819d3f commit 22f5976
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions VraCorePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,24 +490,22 @@ protected function processNewElement($omekaRecord, $omekaElementId, $elementData

protected function processExistingElement($omekaRecord, $omekaElementId, $vraElementId, $elementData)
{

//elements to skip deletion. these are containers for other elements, so
//content is alway null
$skipElements = array('Agent',
'Date',
'dates',
'Inscription',
'Location',
'Rights',
'Source',
'State Edition',
'Subject',
'Textref');
$vraElementObject = $this->_db->getTable('VraCoreElement')->find($vraElementId);
if (empty($elementData['content'])) {
//elements to skip deletion. these are containers for other elements, so
//content is alway null
$skipElements = array('Agent',
'Date',
'dates',
'Inscription',
'Location',
'Rights',
'Source',
'State Edition',
'Subject',
'Textref');
if( ! in_array($vraElementObject->name, $skipElements)) {
$vraElementObject->delete();
}

if (empty($elementData['content']) && ! in_array($vraElementObject->name, $skipElements)) {
$vraElementObject->delete();
} else {
if ($vraElementObject->content != $elementData['content']) {
$vraElementObject->updateDataDate();
Expand Down Expand Up @@ -539,6 +537,7 @@ protected function processNewSubelement($omekaRecord, $omekaElementId, $parentVr
protected function processExistingSubelement($omekaRecord, $omekaElementId, $vraElementId, $elementData)
{
//@todo check if still needed
debug('processExistingSubelement');
$omekaRecordData = array('id' => $omekaRecord->id, 'type' => get_class($omekaRecord));
}

Expand Down

0 comments on commit 22f5976

Please sign in to comment.