Skip to content

Instantly share code, notes, and snippets.

@mjordan
Last active February 21, 2017 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjordan/f6eefe4e95d66bad535fb78dcfd82ea4 to your computer and use it in GitHub Desktop.
Save mjordan/f6eefe4e95d66bad535fb78dcfd82ea4 to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_islandora_datastream_alter().
*/
function mjtest_islandora_datastream_alter(AbstractObject $object, AbstractDatastream $datastream, array &$context) {
$now = date("Y-m-d H:i:s");
$dc = <<<EOX
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<dc:title>Testing at $now</dc:title>
<dc:description>I am concocted.</dc:description>
</oai_dc:dc>
EOX;
if ($context['action'] == 'ingest') {
if ($object['DC'] && $datastream->id == 'DC') {
$datastream->setContentFromString($dc);
}
}
if ($context['action'] == 'modify') {
if ($object['DC'] && $datastream->id == 'DC') {
if (isset($context['params']['dsString'])) {
$context['params']['dsString'] = $dc;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment