DOMNode PHP Class Code Examples

This page contains top rated real world PHP examples of class DOMNode extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: tag-stripper.php Project: zmwebdev/PHPcookbook-code-3ed
0
 protected function copyNodes(DOMNode $dirty, DOMNode $clean)
 {
     foreach ($dirty->attributes as $name => $valueNode) {
         /* Copy over allowed attributes */
         if (isset($this->allowed[$dirty->nodeName][$name])) {
             $attr = $clean->ownerDocument->createAttribute($name);
             $attr->value = $valueNode->value;
             $clean->appendChild($attr);
         }
     }
     foreach ($dirty->childNodes as $child) {
         /* Copy allowed elements */
         if ($child->nodeType == XML_ELEMENT_NODE && isset($this->allowed[$child->nodeName])) {
             $node = $clean->ownerDocument->createElement($child->nodeName);
             $clean->appendChild($node);
             /* Examine children of this allowed element */
             $this->copyNodes($child, $node);
         } else {
             if ($child->nodeType == XML_TEXT_NODE) {
                 $text = $clean->ownerDocument->createTextNode($child->textContent);
                 $clean->appendChild($text);
             }
         }
     }
 }
Example #2
Show file File: XmlEncoder.php Project: ccq18/EduSoho
0
 /**
  * Tests the value being passed and decide what sort of element to create.
  *
  * @param \DOMNode $node
  * @param mixed    $val
  *
  * @return bool
  */
 private function selectNodeType(\DOMNode $node, $val)
 {
     if (is_array($val)) {
         return $this->buildXml($node, $val);
     } elseif ($val instanceof \SimpleXMLElement) {
         $child = $this->dom->importNode(dom_import_simplexml($val), true);
         $node->appendChild($child);
     } elseif ($val instanceof \Traversable) {
         $this->buildXml($node, $val);
     } elseif (is_object($val)) {
         return $this->buildXml($node, $this->serializer->normalize($val, $this->format));
     } elseif (is_numeric($val)) {
         return $this->appendText($node, (string) $val);
     } elseif (is_string($val) && $this->needsCdataWrapping($val)) {
         return $this->appendCData($node, $val);
     } elseif (is_string($val)) {
         return $this->appendText($node, $val);
     } elseif (is_bool($val)) {
         return $this->appendText($node, (int) $val);
     } elseif ($val instanceof \DOMNode) {
         $child = $this->dom->importNode($val, true);
         $node->appendChild($child);
     }
     return true;
 }
Example #3
Show file File: Utilities.php Project: shirlei/simplesaml
0
 /**
  * This function checks if the DOMElement has the correct localName and namespaceURI.
  *
  * We also define the following shortcuts for namespaces:
  * - '@ds':      'http://www.w3.org/2000/09/xmldsig#'
  * - '@md':      'urn:oasis:names:tc:SAML:2.0:metadata'
  * - '@saml1':   'urn:oasis:names:tc:SAML:1.0:assertion'
  * - '@saml1md': 'urn:oasis:names:tc:SAML:profiles:v1metadata'
  * - '@saml1p':  'urn:oasis:names:tc:SAML:1.0:protocol'
  * - '@saml2':   'urn:oasis:names:tc:SAML:2.0:assertion'
  * - '@saml2p':  'urn:oasis:names:tc:SAML:2.0:protocol'
  *
  * @param $element The element we should check.
  * @param $name The localname the element should have.
  * @param $nsURI The namespaceURI the element should have.
  * @return TRUE if both namespace and localname matches, FALSE otherwise.
  */
 public static function isDOMElementOfType(DOMNode $element, $name, $nsURI)
 {
     assert('is_string($name)');
     assert('is_string($nsURI)');
     assert('strlen($nsURI) > 0');
     if (!$element instanceof DOMElement) {
         /* Most likely a comment-node. */
         return FALSE;
     }
     /* Check if the namespace is a shortcut, and expand it if it is. */
     if ($nsURI[0] == '@') {
         /* The defined shortcuts. */
         $shortcuts = array('@ds' => 'http://www.w3.org/2000/09/xmldsig#', '@md' => 'urn:oasis:names:tc:SAML:2.0:metadata', '@saml1' => 'urn:oasis:names:tc:SAML:1.0:assertion', '@saml1md' => 'urn:oasis:names:tc:SAML:profiles:v1metadata', '@saml1p' => 'urn:oasis:names:tc:SAML:1.0:protocol', '@saml2' => 'urn:oasis:names:tc:SAML:2.0:assertion', '@saml2p' => 'urn:oasis:names:tc:SAML:2.0:protocol', '@shibmd' => 'urn:mace:shibboleth:metadata:1.0');
         /* Check if it is a valid shortcut. */
         if (!array_key_exists($nsURI, $shortcuts)) {
             throw new Exception('Unknown namespace shortcut: ' . $nsURI);
         }
         /* Expand the shortcut. */
         $nsURI = $shortcuts[$nsURI];
     }
     if ($element->localName !== $name) {
         return FALSE;
     }
     if ($element->namespaceURI !== $nsURI) {
         return FALSE;
     }
     return TRUE;
 }
Example #4
Show file File: attribute_translator.cls.php Project: fredcido/simuweb
0
 static function append_style(DOMNode $node, $new_style)
 {
     $style = rtrim($node->getAttribute(self::$_style_attr), ";");
     $style .= $new_style;
     $style = ltrim($style, ";");
     $node->setAttribute(self::$_style_attr, $style);
 }
Example #5
Show file File: MergeIdenticalConditionalBranches.php Project: CryptArc/TextFormatter
0
 /**
  * Collect consecutive xsl:when elements that share the same kind of equality tests
  *
  * Will return xsl:when elements that test a constant part (e.g. a literal) against the same
  * variable part (e.g. the same attribute)
  *
  * @param  DOMNode      $node First node to inspect
  * @return DOMElement[]
  */
 protected static function collectCompatibleBranches(DOMNode $node)
 {
     $nodes = [];
     $key = null;
     $values = [];
     while ($node && self::isXslWhen($node)) {
         $branch = TemplateParser::parseEqualityExpr($node->getAttribute('test'));
         if ($branch === false || count($branch) !== 1) {
             // The expression is not entirely composed of equalities, or they have a different
             // variable part
             break;
         }
         if (isset($key) && key($branch) !== $key) {
             // Not the same variable as our branches
             break;
         }
         if (array_intersect($values, end($branch))) {
             // Duplicate values across branches, e.g. ".=1 or .=2" and ".=2 or .=3"
             break;
         }
         $key = key($branch);
         $values = array_merge($values, end($branch));
         // Record this node then move on to the next sibling
         $nodes[] = $node;
         $node = $node->nextSibling;
     }
     return $nodes;
 }
Example #6
Show file File: ForeignKey.php Project: dracony/forked-php-orm-benchmark
0
 /**
  * @see        XMLElement::appendXml(DOMNode)
  */
 public function appendXml(DOMNode $node)
 {
     $doc = $node instanceof DOMDocument ? $node : $node->ownerDocument;
     $fkNode = $node->appendChild($doc->createElement('foreign-key'));
     $fkNode->setAttribute('foreignTable', $this->getForeignTableName());
     $fkNode->setAttribute('name', $this->getName());
     if ($this->getPhpName()) {
         $fkNode->setAttribute('phpName', $this->getPhpName());
     }
     if ($this->getRefPhpName()) {
         $fkNode->setAttribute('refPhpName', $this->getRefPhpName());
     }
     if ($this->getDefaultJoin()) {
         $fkNode->setAttribute('defaultJoin', $this->getDefaultJoin());
     }
     if ($this->getOnDelete()) {
         $fkNode->setAttribute('onDelete', $this->getOnDelete());
     }
     if ($this->getOnUpdate()) {
         $fkNode->setAttribute('onUpdate', $this->getOnUpdate());
     }
     for ($i = 0, $size = count($this->localColumns); $i < $size; $i++) {
         $refNode = $fkNode->appendChild($doc->createElement('reference'));
         $refNode->setAttribute('local', $this->localColumns[$i]);
         $refNode->setAttribute('foreign', $this->foreignColumns[$i]);
     }
     foreach ($this->vendorInfos as $vi) {
         $vi->appendXml($fkNode);
     }
 }
Example #7
Show file File: domdocument.php Project: KVSun/core_api
0
 /**
  * Dynamically and seemingly magically build nodes and append to parent
  *
  * @param mixed    $key    Int or string to become tagname of new node
  * @param mixed    $value  String, array, sdtClass object, DOMNode
  * @param \DOMNode $parent Parent element to append to (defaults to $this)
  * @return void
  */
 protected final function _nodeBuilder($key, $value = null, \DOMNode &$parent = null)
 {
     if (is_null($parent)) {
         $parent = $this;
     }
     if (is_string($key)) {
         if (substr($key, 0, 1) === '@' and (is_string($value) or is_numeric($value))) {
             $parent->setAttribute(substr($key, 1), $value);
         } else {
             $node = $parent->appendChild($this->createElement($key));
             if (is_string($value)) {
                 $node->appendChild($this->createTextNode($value));
             } elseif ($value instanceof \DOMNode) {
                 $node->appendChild($content);
             } elseif (is_array($value) or is_object($value) and $value = get_object_vars($value)) {
                 foreach ($value as $k => $v) {
                     $this->{__FUNCTION__}($k, $v, $node);
                     unset($k, $v);
                 }
             }
         }
     } elseif (is_string($value)) {
         $parent->appendChild($this->createTextNode($value));
     } elseif ($value instanceof \DOMNode) {
         $parent->appendChild($value);
     } elseif (is_array($value) or is_object($value) and $value = get_object_vars($value)) {
         foreach ($value as $k => $v) {
             $this->{__FUNCTION__}($k, $v, $node);
             unset($k, $v);
         }
     }
 }
Example #8
Show file File: AppKitMenuConfigHandler.class.php Project: philippjenni/icinga-web
0
 private function parseMenuPoint(DOMNode $menupoint)
 {
     $def = array();
     $def["id"] = $menupoint->attributes->getNamedItem("id")->value;
     $this->parseMenuProperties($def, $menupoint);
     return $def;
 }
Example #9
Show file File: SC_Helper_Transform.php Project: casan/eccube-2_13
0
 /**
  * DOM Element / Document を走査し、name、class別に分類する
  *
  * @param  DOMNode $objDOMElement DOMNodeオブジェクト
  * @return void
  */
 protected function lfScanChild(DOMNode $objDOMElement, $parent_selector = '')
 {
     $objNodeList = $objDOMElement->childNodes;
     if (is_null($objNodeList)) {
         return;
     }
     foreach ($objNodeList as $element) {
         // DOMElementのみ取り出す
         if ($element instanceof DOMElement) {
             $arrAttr = array();
             $arrAttr[] = $element->tagName;
             if (method_exists($element, 'getAttribute')) {
                 // idを持っていればidを付加する
                 if ($element->hasAttribute('id')) {
                     $arrAttr[] = '#' . $element->getAttribute('id');
                 }
                 // classを持っていればclassを付加する(複数の場合は複数付加する)
                 if ($element->hasAttribute('class')) {
                     $arrClasses = preg_split('/\\s+/', $element->getAttribute('class'));
                     foreach ($arrClasses as $classname) {
                         $arrAttr[] = '.' . $classname;
                     }
                 }
             }
             // 親要素のセレクタを付けてツリーへ登録する
             $this_selector = $parent_selector . ' ' . implode('', $arrAttr);
             $this->arrElementTree[] = array($this_selector, $element);
             // エレメントが子孫要素を持っていればさらに調べる
             if ($element->hasChildNodes()) {
                 $this->lfScanChild($element, $this_selector);
             }
         }
     }
 }
Example #10
Show file File: Compiler.php Project: kidaa30/magento2-platformsh
0
 /**
  * The compilation of the template and filling in the data
  *
  * @param \DOMNode $node
  * @param DataObject $processedObject
  * @param DataObject $context
  * @return void
  */
 public function compile(\DOMNode $node, DataObject $processedObject, DataObject $context)
 {
     switch ($node->nodeType) {
         case XML_TEXT_NODE:
             $this->compilerText->compile($node, $processedObject);
             break;
         case XML_CDATA_SECTION_NODE:
             $this->compilerCdata->compile($node, $processedObject);
             break;
         case XML_COMMENT_NODE:
             $this->compilerComment->compile($node, $processedObject);
             break;
         default:
             /** @var \DomElement $node */
             if ($node->hasAttributes()) {
                 foreach ($node->attributes as $attribute) {
                     $this->compilerAttribute->compile($attribute, $processedObject);
                 }
             }
             $compiler = $this->getElementCompiler($node->nodeName);
             if (null !== $compiler) {
                 $compiler->compile($this, $node, $processedObject, $context);
             } else {
                 if ($node->hasChildNodes()) {
                     foreach ($this->getChildNodes($node) as $child) {
                         $this->compile($child, $processedObject, $context);
                     }
                 }
             }
     }
 }
Example #11
Show file File: Parser.php Project: shabbirvividads/magento2
0
 /**
  * Parse dom node
  *
  * @param \DOMNode $node
  * @return array
  */
 protected function _parseNode(\DOMNode $node)
 {
     $result = [];
     if (false === $node->hasChildNodes()) {
         $result = $this->_getSimpleNodeValue($node);
     } else {
         foreach ($node->childNodes as $childNode) {
             $sameNodesCount = $this->_getSameNodesCount($node->getElementsByTagName($childNode->nodeName), $childNode);
             /** @var array $nodeValue  */
             $nodeValue = $this->_parseNode($childNode);
             $siblingKey = $this->_getSiblingKey($childNode);
             if ($siblingKey !== 0) {
                 $nodeValue = isset($nodeValue[$childNode->nodeName]) ? $nodeValue[$childNode->nodeName] : $nodeValue;
             } elseif (empty($nodeValue)) {
                 continue;
             }
             // how many of these child nodes do we have?
             if ($sameNodesCount > 1) {
                 // more than 1 child - make numeric array
                 $result[$siblingKey][] = $nodeValue;
             } else {
                 $result[$siblingKey] = $nodeValue;
             }
         }
         // if the child is <foo>bar</foo>, the result will be array(bar)
         // make the result just 'bar'
         if (count($result) == 1 && isset($result[0])) {
             $result = current($result);
         }
     }
     $attributes = $this->_parseNodeAttributes($node);
     $result = array_merge($result, $attributes);
     return $result;
 }
Example #12
Show file File: Ezer_XmlVariable.php Project: codegooglecom/ezerphp
0
 public function parse(DOMNode $element)
 {
     if ($element->hasAttribute('name')) {
         $this->name = $element->getAttribute('name');
     }
     if ($element->hasAttribute('type')) {
         $this->type = $element->getAttribute('type');
     }
     for ($i = 0; $i < $element->childNodes->length; $i++) {
         $childElement = $element->childNodes->item($i);
         if ($childElement->parentNode !== $element) {
             continue;
         }
         if ($childElement instanceof DOMComment || $childElement instanceof DOMText) {
             continue;
         }
         switch ($childElement->nodeName) {
             case 'part':
                 $this->parts[] = new Ezer_XmlVariable($childElement);
                 break;
             default:
                 throw new Ezer_XmlPersistanceElementNotMappedException($childElement->nodeName);
         }
     }
 }
Example #13
Show file File: xmlMergerTask.php Project: philippjenni/icinga-web
0
 /**
  * Add prefix $prefix to $node
  * @param DOMNode $node 
  * @param string $prefix
  * @param DOMNode $newNode
  */
 protected function fixPrefix(DOMNode $node, $prefix, DOMNode $newNode = null)
 {
     if ($node->nodeName == $newNode->nodeName) {
         return $node;
     }
     $result = $this->getTargetDOM()->createElement($prefix . ":" . $node->nodeName);
     // Copy attributes
     foreach ($node->attributes as $att) {
         $attrNode = $this->getTargetDOM()->createAttribute($att->name);
         $attrNode->nodeValue = $att->value;
         $result->appendChild($attrNode);
     }
     // copy children
     foreach ($node->childNodes as $child) {
         $result->appendChild($child);
     }
     if ($newNode) {
         $target = $this->getTargetDOM();
         foreach ($newNode->childNodes as $child) {
             if ($child->nodeType != XML_TEXT_NODE) {
                 $result->appendChild($target->importNode($child, true));
             }
         }
     }
     return $result;
 }
Example #14
Show file File: Parser.php Project: xrstf/oeis-api
0
 private function parseBeginning(array $sequence, \DOMNode $container)
 {
     $numbers = $this->text($container, 'tr[4]//table//td[2]/tt', 1, true);
     $numbers = explode(', ', $numbers);
     $sequence['beginning'] = $numbers;
     return $sequence;
 }
Example #15
Show file File: Cube.php Project: fortuneteller/phpOlap
0
 /**
  * Hydrate Element
  *
  * @param DOMNode $node Node
  * @param Connection $connection Connection
  *
  */
 public function hydrate(\DOMNode $node, ConnectionInterface $connection)
 {
     $this->connection = $connection;
     $this->name = parent::getPropertyFromNode($node, 'CUBE_NAME', false);
     $this->description = parent::getPropertyFromNode($node, 'DESCRIPTION');
     $this->type = parent::getPropertyFromNode($node, 'CUBE_TYPE');
 }
Example #16
Show file File: ResultSet.php Project: fortuneteller/phpOlap
0
 /**
  * Hydrate Element
  *
  * @param DOMNode $node Node
  *
  */
 public function hydrate(\DOMNode $node)
 {
     $this->cubeName = MetadataBase::getPropertyFromNode($node, 'CubeName');
     $this->hierarchiesName = self::hydrateAxesInfos($node);
     $this->cellAxisSet = self::hydrateAxesSet($node);
     $this->cellDataSet = self::hydrateDataSet($node);
 }
Example #17
Show file File: CHPrimXMLEvenementsPatients.class.php Project: fbone/mediboard4
0
 /**
  * Sauvegarde des INSC
  *
  * @param CPatient $patient Patient
  * @param DOMNode  $node    Elément NumeroIdentifiantSante
  *
  * @return void
  */
 function storeINSC(CPatient $patient, DOMNode $node)
 {
     $xpath = new CHPrimXPath($node->ownerDocument);
     $list_insc = $xpath->query("insC", $node);
     $insc = new CINSPatient();
     $insc->type = "C";
     $insc->patient_id = $patient->_id;
     foreach ($list_insc as $_insc) {
         $ins = $xpath->queryTextNode("valeur", $_insc);
         $date = $xpath->queryTextNode("dateEffet", $_insc);
         if (!$ins) {
             continue;
         }
         $insc->ins_patient_id = null;
         $insc->date = null;
         $insc->provider = null;
         $insc->ins = $ins;
         $insc->loadMatchingObject();
         if ($insc->date < $date) {
             $insc->date = $date;
             $insc->provider = $this->_ref_sender->nom;
         }
         $insc->store();
     }
 }
Example #18
Show file File: AgaviXmlConfigSchematronProcessor.class.php Project: philippjenni/icinga-web
0
 /**
  * Sets the node that this processor will transform and validate.
  *
  * @param      DOMNode The node to use.
  *
  * @author     Noah Fontes <noah.fontes@bitextender.com>
  * @since      1.0.0
  */
 public function setNode(DOMNode $node)
 {
     if (self::$processors === null) {
         self::createProcessors();
     }
     $this->node = $node;
 }
Example #19
Show file File: Converter.php Project: artmouse/Umc_Base
0
 /**
  * Retrieve \DOMDocument as array
  *
  * @param \DOMNode $root
  * @return array|null
  */
 protected function convertDOMDocument(\DOMNode $root)
 {
     $result = $this->processAttributes($root);
     $children = $root->childNodes;
     $processedSubLists = [];
     for ($i = 0; $i < $children->length; $i++) {
         $child = $children->item($i);
         $childName = $child->nodeName;
         switch ($child->nodeType) {
             case XML_COMMENT_NODE:
                 continue 2;
                 break;
             case XML_TEXT_NODE:
                 if ($children->length && trim($child->nodeValue, "\n ") === '') {
                     continue 2;
                 }
                 $childName = 'value';
                 $convertedChild = $child->nodeValue;
                 break;
             case XML_CDATA_SECTION_NODE:
                 $childName = 'value';
                 $convertedChild = $child->nodeValue;
                 break;
             default:
                 $convertedChild = $this->convertDOMDocument($child);
                 break;
         }
         if (in_array($childName, $processedSubLists)) {
             $result = $this->addProcessedNode($convertedChild, $result, $childName);
         } else {
             if (array_key_exists($childName, $result)) {
                 if (in_array($childName, $this->idNodes)) {
                     $key = $convertedChild['id'];
                 } else {
                     $key = null;
                 }
                 if ($key) {
                     $result[$childName][$key] = $convertedChild;
                 } else {
                     $result[$childName][] = $convertedChild;
                 }
                 $processedSubLists[] = $childName;
             } else {
                 if (in_array($childName, $this->idNodes)) {
                     $key = $convertedChild['id'];
                     $result[$childName][$key] = $convertedChild;
                 } else {
                     $result[$childName] = $convertedChild;
                 }
             }
         }
     }
     if (count($result) == 1 && array_key_exists('value', $result)) {
         $result = $result['value'];
     }
     if ($result == []) {
         $result = null;
     }
     return $result;
 }
Example #20
Show file File: Element.php Project: ziyou-liu/1line
0
 protected static function wrapNode(\DOMNode $node, \DOMNode $wrapper)
 {
     if ($wrapper->hasChildNodes()) {
         $deepest = self::deepestNode($wrapper);
         $wrapper = $deepest[0];
     }
     $parent = $node->parentNode;
     $parent->insertBefore($wrapper, $node);
     $wrapper->appendChild($parent->removeChild($node));
 }
Example #21
Show file File: cachevalidator.php Project: pawelzielak/opencaching-pl
0
function appendSibling(DOMNode $newnode, DOMNode $ref)
{
    if ($ref->nextSibling) {
        // $ref has an immediate brother : insert newnode before this one
        return $ref->parentNode->insertBefore($newnode, $ref->nextSibling);
    } else {
        // $ref has no brother next to him : insert newnode as last child of his parent
        return $ref->parentNode->appendChild($newnode);
    }
}
Example #22
Show file File: dom_element_wrapper.class.php Project: google-code-backups/add-mvc-framework
0
 /**
  * Inserts an element on the start of the element
  *
  * @param DOMNode $newnode the new domnode to prepend
  * @param DOMNode $refnode the ref node
  *
  * @since ADD MVC 0.0
  */
 public function insertBefore(DOMNode $newnode, DOMNode $refnode = NULL)
 {
     if (is_string($newnode)) {
         $newnode = self::factory($newnode);
     } else {
         if (!$newnode instanceof DOMNode) {
         }
     }
 }
Example #23
Show file File: AbstractElementView.php Project: khanhdeux/typo3test
0
 /**
  * Replace the current node with a document fragment
  *
  * @param \DOMDocument $dom
  * @param \DOMNode $node Current Node
  * @param \DOMNode $value Value to import
  * @return void
  */
 public function replaceNodeWithFragment(\DOMDocument $dom, \DOMNode $node, \DOMNode $value)
 {
     $replaceNode = $dom->createDocumentFragment();
     $domNode = $dom->importNode($value, TRUE);
     $replaceNode->appendChild($domNode);
     $node->parentNode->insertBefore($replaceNode, $node);
 }
Example #24
Show file File: xmlappend.php Project: KVSun/core_api
0
 /**
  * Append any supported $content to $parent
  *
  * @param  DOMNode $parent  Node to append to
  * @param  mixed   $content Content to append
  * @return self
  */
 protected function XMLAppend(\DOMNode &$parent = null, $content = null)
 {
     if (is_null($parent)) {
         $parent = $this->root;
     }
     if (is_string($content) or is_numeric($content) or is_object($content) and method_exists($content, '__toString')) {
         $parent->appendChild($this->createTextNode("{$content}"));
     } elseif (is_object($content) and is_subclass_of($content, '\\DOMNode')) {
         $parent->appendChild($content);
     } elseif (is_array($content) or is_object($content) and $content = get_object_vars($content)) {
         array_map(function ($node, $value) use(&$parent) {
             if (is_string($node)) {
                 if (substr($node, 0, 1) === '@') {
                     $parent->setAttribute(substr($node, 1), $value);
                 } else {
                     $node = $parent->appendChild($this->createElement($node));
                     if (is_string($value)) {
                         $this->XMLAppend($node, $this->createTextNode($value));
                     } else {
                         $this->XMLAppend($node, $value);
                     }
                 }
             } else {
                 $this->XMLAppend($parent, $value);
             }
         }, array_keys($content), array_values($content));
     } elseif (is_bool($content)) {
         $parent->appendChild($this->createTextNode($content ? 'true' : 'false'));
     } else {
         throw new \InvalidArgumentException(sprintf('Unable to append unknown content [%s] to %s', get_class($content), get_class($this)));
     }
     return $this;
 }