/** * Proxy to parent Mad_Support_ArrayObject#toXml, except that * we know the explicit model type. */ public function toXml($options = array()) { if (!isset($options['root'])) { $options['root'] = Mad_Support_Inflector::pluralize(get_class($this->_model)); } return parent::toXml($options); }
public function testGetValuesReturnsArrayOfValuesInTheArray() { $o = new Mad_Support_ArrayObject(array('foo' => 1, 'bar' => 2)); $this->assertSame(array(1, 2), $o->getValues()); }
/** * Convert XML to an Mad_Model record * * @see Mad_Model_Base::toXml() * @param string $xml * @return Mad_Model_Base */ public function fromXml($xml) { $converted = Mad_Support_ArrayObject::fromXml($xml); $values = array_values($converted); $attributes = $values[0]; $this->setAttributes($attributes); return $this; }
public function testShouldHasManyArrayElementsShouldIncludeTypeWhenDifferentFromGuessedValue() { $xml = $this->companies('maintainable')->toXml(array('include' => 'Employees', 'indent' => 2)); $this->assertNotNull(Mad_Support_ArrayObject::fromXml($xml)); $this->assertContains('<employees type="array">', $xml); $this->assertContains('<employee type="User">', $xml); $this->assertContains('<employee type="Client">', $xml); }
/** * @param Mad_Model_Serializer_Attribute */ public function addTag($attribute) { $attrName = $this->dasherize($attribute->getName()); $attrValue = $attribute->getValue(); $attrDecos = $attribute->getDecorations(empty($this->_options['skipTypes'])); $builder = $this->getBuilder(); // check if attribute values need to be further serialized if (is_array($attrValue)) { $options = array_merge($this->_options, array('root' => $attrName)); $ao = new Mad_Support_ArrayObject($attrValue); $ao->toXml($options); } else { $builder->tag($attrName, $attrValue, $attrDecos); } }
/** * Parse XML into request params for active resource style requests * @return array */ protected function _parseFormattedRequestParameters() { if ($this->getContentLength() == 0) { return array(); } $mimeType = $this->getContentType(); if ($mimeType === null) { return array(); } // parse xml into params if ($mimeType->symbol == 'xml') { $body = $this->getBody(); return empty($body) ? array() : Mad_Support_ArrayObject::fromXml($body); // nothing else supported now } else { return array(); } }
/** * Each variable set through routing {@link Mad_Controller_Route_Path} is * availabie in controllers using the $params array. * * The controller also has access to GET/POST arrays using $params * * The action method to be performed is stored in $this->params[':action'] key */ private function _initParams() { $hash = $this->_request->getParameters(); $this->params = new Mad_Support_ArrayObject($hash); $this->_action = $this->params->get(':action'); }