/** * Overrides setRecordMetadata() to allow giving the name of the element as * a string. * * @param string|array $metadata */ public function setRecordMetadata($metadata) { // Set the element set name if a string is provided. if (is_string($metadata)) { $metadata = array('name' => $metadata); } return parent::setRecordMetadata($metadata); }
/** * Overrides setRecordMetadata() to allow setting the item type by name * instead of ID. * * @param array $metadata * @return void */ public function setRecordMetadata(array $metadata) { // Determine the Item Type ID from the name. if (array_key_exists(self::ITEM_TYPE_NAME, $metadata)) { $itemType = $this->_db->getTable('ItemType')->findBySql('name = ?', array($metadata[self::ITEM_TYPE_NAME]), true); if (!$itemType) { throw new Omeka_Record_Builder_Exception("Invalid type named {$metadata[self::ITEM_TYPE_NAME]} provided!"); } $metadata[self::ITEM_TYPE_ID] = $itemType->id; } return parent::setRecordMetadata($metadata); }