From cb3a8d8f4a6ebebc96c84c2482929ea80d9901d9 Mon Sep 17 00:00:00 2001 From: Tyler Antonio <contact@tanton.io> Date: Wed, 8 Apr 2015 10:59:22 -0600 Subject: [PATCH] Added import script for flatfile metadata --- bin/importPdoMetadata.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 bin/importPdoMetadata.php diff --git a/bin/importPdoMetadata.php b/bin/importPdoMetadata.php new file mode 100755 index 000000000..70c690613 --- /dev/null +++ b/bin/importPdoMetadata.php @@ -0,0 +1,25 @@ +<?php +$baseDir = dirname(dirname(__FILE__)); + +require_once $baseDir . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . '_autoload.php'; +require_once $baseDir . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; + +# Iterate through configured metadata sources and ensure +# that a PDO source exists. +foreach ($config['metadata.sources'] as $s) { + # If pdo is configured, create the new handler and add in the metadata sets. + if ("pdo" === $s['type']) { + $mdshp = new SimpleSAML_Metadata_MetaDataStorageHandlerPdo($s); + $mdshp->initDatabase(); + foreach (glob("metadata/*.php") as $filename) { + $metadata = array(); + require_once $filename; + $set = basename($filename, ".php"); + echo "importing set '$set'..." . PHP_EOL; + foreach ($metadata as $k => $v) { + echo "\t$k" . PHP_EOL; + $mdshp->addEntry($k, $set, $v); + } + } + } +} \ No newline at end of file -- GitLab