1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92:
<?php
namespace Omeka\Installation\Task;
use Omeka\Api\Exception\ValidationException;
use Omeka\Installation\Installer;
class InstallDefaultVocabulariesTask implements TaskInterface
{
protected $vocabularies = [
[
'vocabulary' => [
'o:namespace_uri' => 'http://purl.org/dc/terms/',
'o:prefix' => 'dcterms',
'o:label' => 'Dublin Core',
'o:comment' => 'Basic resource metadata (DCMI Metadata Terms)',
],
'strategy' => 'file',
'file' => 'dcterms.rdf',
'format' => 'rdfxml',
],
[
'vocabulary' => [
'o:namespace_uri' => 'http://purl.org/dc/dcmitype/',
'o:prefix' => 'dctype',
'o:label' => 'Dublin Core Type',
'o:comment' => 'Basic resource types (DCMI Type Vocabulary)',
],
'strategy' => 'file',
'file' => 'dctype.rdf',
'format' => 'rdfxml',
],
[
'vocabulary' => [
'o:namespace_uri' => 'http://purl.org/ontology/bibo/',
'o:prefix' => 'bibo',
'o:label' => 'Bibliographic Ontology',
'o:comment' => 'Bibliographic metadata (BIBO)',
],
'strategy' => 'file',
'file' => 'bibo.owl',
'format' => 'rdfxml',
],
[
'vocabulary' => [
'o:namespace_uri' => 'http://xmlns.com/foaf/0.1/',
'o:prefix' => 'foaf',
'o:label' => 'Friend of a Friend',
'o:comment' => 'Relationships between people and organizations (FOAF)',
],
'strategy' => 'file',
'file' => 'foaf.rdf',
'format' => 'rdfxml',
],
];
public function perform(Installer $installer)
{
$rdfImporter = $installer->getServiceLocator()->get('Omeka\RdfImporter');
$entityManager = $installer->getServiceLocator()->get('Omeka\EntityManager');
foreach ($this->vocabularies as $vocabulary) {
try {
$response = $rdfImporter->import(
$vocabulary['strategy'],
$vocabulary['vocabulary'],
[
'file' => OMEKA_PATH . "/application/data/vocabularies/{$vocabulary['file']}",
'format' => $vocabulary['format'],
]
);
} catch (ValidationException $e) {
$installer->addErrorStore($e->getErrorStore());
return;
}
$entityManager->clear();
}
}
public function getVocabularies()
{
return $this->vocabularies;
}
}