/** * @see AbstractObject::models */ protected function modelsMagicProperty($function, $value) { switch ($function) { case 'get': $models = array(); $rels_models = $this->relationships->get(FEDORA_MODEL_URI, 'hasModel'); foreach ($rels_models as $model) { $models[] = $model['object']['value']; } if (!in_array('fedora-system:FedoraObject-3.0', $models)) { $models[] = 'fedora-system:FedoraObject-3.0'; } return $models; break; case 'isset': $rels_models = $this->relationships->get(FEDORA_MODEL_URI, 'hasModel'); return count($rels_models) > 0; break; case 'set': if (!is_array($value)) { $models = array($value); } else { $models = $value; } if (!in_array('fedora-system:FedoraObject-3.0', $models)) { $models[] = 'fedora-system:FedoraObject-3.0'; } foreach ($models as $model) { if (!in_array($model, $this->models)) { $this->relationships->add(FEDORA_MODEL_URI, 'hasModel', $model); } } break; case 'unset': $this->relationships->remove(FEDORA_MODEL_URI, 'hasModel'); break; } }
$password = '******'; // set up connection and repository variables $connection = new RepositoryConnection($url, $username, $password); $api = new FedoraApi($connection); $repository = new FedoraRepository($api, new SimpleCache()); // try to fetch PID from repo try { // drush_print("Attempting to access $objectPID from repository"); $object = $repository->getObject($objectPID); } catch (Exception $e) { drush_print("\n\n**********####### ERROR #######**********"); drush_print("***Could not get object {$objectPID} from repo***\n\n"); return; } drush_print("*************Object relationships before changes*************"); $object_content_models = $object->relationships->get('info:fedora/fedora-system:def/model#', 'hasModel'); print_r($object_content_models); /** * THIS IS FOR CHANGING PDF MODEL -> THESIS MODEL * * Change the third argument to the 'add' and 'remove' methods to reflect the changes you need **/ $fedrelsext = new FedoraRelsExt($object); // add this relationship to all objects in the Research Collection $fedrelsext->add("info:fedora/fedora-system:def/model#", "hasModel", "ir:thesisCModel"); // delete this relationship from all objects in the Research Collection $fedrelsext->remove("info:fedora/fedora-system:def/model#", "hasModel", "islandora:sp_pdf"); drush_print("*************Object relationships AFTER changes*************"); $object_content_models = $object->relationships->get('info:fedora/fedora-system:def/model#', 'hasModel'); print_r($object_content_models); drush_print("\nAll operations complete\n");