public function actionCreateRemapValue($id) { if (!($remap = XpathRemap::model()->findByPk($id))) { throw new \CHttpException('404', 'Could not Xpath Remap'); } $model = new RemapValue(); $model->xpath_id = $remap->id; if (isset($_POST[\CHtml::modelName($model)])) { $model->attributes = $_POST[\CHtml::modelName($model)]; if ($model->save()) { \Audit::add('admin', 'create', serialize($model->attributes), false, array('module' => 'PASAPI', 'model' => '\\OEModule\\PASAPI\\models\\RemapValue')); \Yii::app()->user->setFlash('success', 'Remap Value added to ' . $remap->name); $this->redirect(array('viewRemapValues', 'id' => $id)); } } $this->render('update', array('model' => $model, 'title' => 'Add Xpath Remap', 'cancel_uri' => \Yii::app()->createUrl($this->module->getName() . '/admin/viewRemapValues', array('id' => $remap->id)))); }
/** * Create an instance from an XML string. * * @param $version * @param $xml * @param array $options * * @return null|BaseResource * * @throws \Exception */ public static function fromXml($version, $xml, $options = array()) { $doc = new \DOMDocument(); if (!$xml) { return static::errorInit($version, array('Missing Resource Body')); } libxml_use_internal_errors(true); if (!$doc->loadXML($xml)) { $errors = array(); foreach (libxml_get_errors() as $err) { $errors[] = $err->message; } $obj = static::errorInit($version, $errors); libxml_clear_errors(); return $obj; } static::remapValues($doc, XpathRemap::model()->findAllByXpath('/' . static::$resource_type)); $obj = static::fromXmlDom($version, $doc->documentElement, $options); $obj->addAuditData('input', \CHtml::encode($xml)); return $obj; }