diff -r bd595ad770fc -r 1c2f13fd785c web/enmi/Zend/InfoCard/Xml/Security/Transform.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/enmi/Zend/InfoCard/Xml/Security/Transform.php Thu Jan 20 19:30:54 2011 +0100 @@ -0,0 +1,116 @@ +_findClassbyURI($uri); + + $this->_transformList[] = array('uri' => $uri, + 'class' => $class); + return $this; + } + + /** + * Return the list of transforms to perform + * + * @return array The list of transforms + */ + public function getTransformList() + { + return $this->_transformList; + } + + /** + * Apply the transforms in the transform list to the input XML document + * + * @param string $strXmlDocument The input XML + * @return string The XML after the transformations have been applied + */ + public function applyTransforms($strXmlDocument) + { + foreach($this->_transformList as $transform) { + if (!class_exists($transform['class'])) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($transform['class']); + } + + $transformer = new $transform['class']; + + // We can't really test this check because it would require logic changes in the component itself + // @codeCoverageIgnoreStart + if(!($transformer instanceof Zend_InfoCard_Xml_Security_Transform_Interface)) { + require_once 'Zend/InfoCard/Xml/Security/Exception.php'; + throw new Zend_InfoCard_Xml_Security_Exception("Transforms must implement the Transform Interface"); + } + // @codeCoverageIgnoreEnd + + $strXmlDocument = $transformer->transform($strXmlDocument); + } + + return $strXmlDocument; + } +}