/** * @param string|null $tableName * @return Omeka_Db_Table */ public function getTable($tableName = null) { if (!$tableName) { if (!$this->_defaultTable) { throw new InvalidArgumentException("Default table must be assigned."); } return $this->_defaultTable; } else { return $this->_db->getTable($tableName); } }
/** * For a given record, re-save the remote parent record, if one exists. * * @param Omeka_Record $record The record. * * @author David McClure <*****@*****.**> **/ public function resaveRemoteParent($record) { // Get the record type. $table = get_class($record); // Iterate over all addon fields. foreach ($this->addons as $addon) { foreach ($addon->fields as $field) { // Match remote fields that point to the record's type. if ($field->remote && $field->remote->table == $table) { $parentTable = $this->db->getTable($addon->table); $parentIdKey = $field->remote->key; // Load the parent and re-save. $parent = $parentTable->find($record->{$parentIdKey}); $parent->save(); } } } }
/** * This returns true if this addon (and none of its ancestors) are flagged. * * @param Omeka_Record $record The Omeka record to consider indexing. * @param SolrSearch_Addon_Addon $addon The addon for the record. * * @return bool $indexed A flag indicating whether to index the record. * @author Eric Rochester <*****@*****.**> **/ public function isRecordIndexed($record, $addon) { $indexed = true; if (is_null($record)) { } else { if (!is_null($addon->flag)) { $flag = $addon->flag; $indexed = $record->{$flag}; } else { if (!is_null($addon->parentAddon)) { $key = $addon->parentKey; $table = $this->db->getTable($addon->parentAddon->table); $parent = $table->find($record->{$key}); $indexed = $this->isRecordIndexed($parent, $addon->parentAddon); } } } return $indexed; }
/** * Set the record upon which this builder will act. * * @see Omeka_Record_Builder::getRecord() * @param Omeka_Record_AbstractRecord|integer|null $record * @return void */ public function setRecord($record = null) { if ($record === null) { $this->_record = new $this->_recordClass($this->_db); } else { if ($record instanceof Omeka_Record_AbstractRecord) { if (!$record instanceof $this->_recordClass) { throw new Omeka_Record_Builder_Exception("Incorrect record instance given. Must be instance of '{$this->_recordClass}'."); } $this->_record = $record; } else { if (is_int($record)) { $this->_record = $this->_db->getTable($this->_recordClass)->find($record); if (!$this->_record) { throw new Omeka_Record_Builder_Exception("Could not find record with ID = " . $record); } } else { throw new InvalidArgumentException("Argument passed to setRecord() must be Omeka_Record_AbstractRecord, integer, or null."); } } } }
/** * Return an Omeka file object. * * @param int $fileId * @return File|int */ private function _getFile($fileId) { return $this->_db->getTable('File')->find($fileId); }