getMetadataSchema(); $recordMetadataSchema = $this->getMetadataSchema(); if ($descriptionMetadataSchema->getName() != $recordMetadataSchema->getName()) { return false; } // Check whether we already have a description for the same // application entity instance. $applicationEntityId = $this->getApplicationEntityIdFromMetadataDescription($metadataDescription); if (isset($this->_descriptions[$applicationEntityId]) && !$replace) { return false; } // Add the description $this->_descriptions[$applicationEntityId] = & $metadataDescription; } /** * Remove description. * * @param string $applicationEntityId consisting of 'assocType:assocId' * * @return bool true if the description was found and removed, otherwise false * * @see MetadataRecord::getApplicationEntityIdFromMetadataDescription() */ public function removeDescription($applicationEntityId) { // Remove the description if it exists if (isset($applicationEntityId) && isset($this->_descriptions[$applicationEntityId])) { unset($this->_descriptions[$applicationEntityId]); return true; } return false; } /** * Get all descriptions * * @return array statements */ public function &getDescriptions() { return $this->_descriptions; } /** * Get a specific description * * @param string $applicationEntityId consisting of 'assocType:assocId' * * @return ?bool true if the description was found and removed, otherwise false * * @see MetadataRecord::getApplicationEntityIdFromMetadataDescription() */ public function &getDescription($applicationEntityId) { assert(isset($applicationEntityId)); // Retrieve the description if (isset($this->_descriptions[$applicationEntityId])) { return $this->_descriptions[$applicationEntityId]; } else { $nullValue = null; return $nullValue; } } /** * Replace all descriptions at once. If one of the descriptions * is invalid then the meta-data record will be empty after this * operation. * * @param array $descriptions descriptions * * @return bool true if all descriptions could be added, false otherwise */ public function setDescriptions(&$descriptions) { // Delete existing statements $this->_descriptions = []; // Add descriptions one by one to validate them. foreach ($descriptions as $description) { if (!($this->addDescription($description, false))) { $this->_descriptions = []; } } return true; } } if (!PKP_STRICT_MODE) { class_alias('\PKP\metadata\MetadataRecord', '\MetadataRecord'); }