Skip to content

Instantly share code, notes, and snippets.

@sprklinginfo
Forked from adam-vessey/collection.php
Last active August 29, 2015 14:10
Show Gist options
  • Save sprklinginfo/599fc208a3e4ed70b15e to your computer and use it in GitHub Desktop.
Save sprklinginfo/599fc208a3e4ed70b15e to your computer and use it in GitHub Desktop.
<?php
/*
They're stored in the COLLECTION_POLICY datastream, on the collection object. You can use the
CollectionPolicy class (https://github.com/Islandora/islandora_solution_pack_collection/blob/7.x/includes/collection_policy.inc)
to help parse this datastream, in particular, the getContentModels() method
(https://github.com/Islandora/islandora_solution_pack_collection/blob/7.x/includes/collection_policy.inc#L75-L105)should be of use to you.
Could probably use some error handling, but something like this: https://gist.github.com/adam-vessey/731c415cf822dd9f9f65
*/
// Load the collection object.
$object = islandora_object_load('the:pid');
// Instantiate a CollectionPolicy object with our policy.
$collection_policy = new CollectionPolicy($object['COLLECTION_POLICY']->content);
// Grab the models.
$models = $collection_policy->getContentModels();
// Grab the desired namespace.
// For sanity, may want to pass this through islandora_get_namespace(), as we've not always
// written only the namespace itself... Occasionally, it may look like a full PID.:
// @see https://github.com/Islandora/islandora/blob/fd95c8dce72a8c6fbb7e36021b448781a3055909/includes/utilities.inc#L256-L276
$namespace = $models['the:relevantCModel']['namespace'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment