/** * Add a node with fields specified in params. */ public function addOriginal($params) { try { // fetch node with #original out tag $node = $this->getNode($params); // will spit error if not found // get the source file (will spit if cant do) list($sourceFile, $sourceFileName) = $this->getSourceFile($params); // apply any required filters if (!isset($params['File']) && !isset($params['Url'])) { $sourceFile = $this->_applyFilters($params, $sourceFile); } // add the new file node $parentElement = $node->getNodeRef()->getElement(); $fileNode = $this->addFileNode($parentElement, $sourceFile, $sourceFileName); // build the new out tag $tag = new Tag($fileNode->getNodeRef(), '', '#original'); // and add tag $this->RegulatedNodeService->addOutTag($node->getNodeRef(), $tag); // we're done so delete source file @unlink($sourceFile); } catch (Exception $e) { // clean up @unlink($sourceFile); throw $e; } }