本文整理汇总了PHP中Node::fromObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::fromObject方法的具体用法?PHP Node::fromObject怎么用?PHP Node::fromObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node::fromObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serialize
/**
* Serialize
*
* @param var value
* @return string
*/
public function serialize($payload)
{
$t = new Tree();
$t->setEncoding('UTF-8');
if ($payload instanceof Payload) {
$root = isset($payload->properties['name']) ? $payload->properties['name'] : 'root';
$payload = $payload->value;
} else {
$root = 'root';
}
if ($payload instanceof Generic) {
$t->root = Node::fromObject($payload, $root);
} else {
if (is_array($payload)) {
$t->root = Node::fromArray($payload, $root);
} else {
$t->root = new Node($root, $payload);
}
}
return $t->getDeclaration() . "\n" . $t->getSource(INDENT_NONE);
}
示例2: addFormError
/**
* Adds an error. The XML representation will look like this:
* <xmp>
* <error
* checker="foo.bar.wrapper.MyLoginDataChecker"
* type="user_nonexistant"
* field="username"
* />
* </xmp>
*
* @param string checker The class checking the input
* @param string type The error type
* @param string field default '*' The form field corresponding
* @param var info default NULL
* @return bool FALSE
*/
public function addFormError($checker, $type, $field = '*', $info = NULL)
{
if (is_array($info)) {
$c = Node::fromArray($info, 'error');
} else {
if (is_object($info)) {
$c = Node::fromObject($info, 'error');
} else {
$c = new Node('error', $info);
}
}
$c->setAttributes(array('type' => $type, 'field' => $field, 'checker' => $checker));
$this->document->formerrors->addChild($c);
return FALSE;
}
示例3: fromObject
public function fromObject()
{
$this->assertEquals("<node>\n" . " <id>1549</id>\n" . " <color>green</color>\n" . " <name>Name goes here</name>\n" . " <__id/>\n" . "</node>", $this->sourceOf(Node::fromObject(newinstance('lang.Object', array(), '{
public $id= 1549;
public $color= "green";
public $name;
public function __construct() {
$this->name= new String("Name goes here");
}
}'), 'node')));
}
示例4: dateFormatCallbackWithoutTZ
public function dateFormatCallbackWithoutTZ()
{
$date = new Date('2009-09-20 21:33:00');
$this->assertEquals($date->toString('Y-m-d H:i:s T'), $this->runTransformation(Node::fromObject($date, 'date')->getSource(), 'xp.date::format', array('string(/date/value)', "'Y-m-d H:i:s T'")));
}
示例5: writeInterfaces
public function writeInterfaces($description, $output)
{
static $purposes = array(HOME_INTERFACE => 'home', REMOTE_INTERFACE => 'remote');
foreach ($description->getInterfaces() as $type => $interface) {
$node = Node::fromObject($interface, 'interface');
$node->setAttribute('purpose', $purposes[$type]);
$node->addChild(new Node('jndiName', $this->jndi));
$this->processor->setXMLBuf($node->getSource(INDENT_NONE));
$this->processor->run();
$output->append(strtr($interface->getClassName(), '.', '/') . xp::CLASS_FILE_EXT, $this->processor->output());
}
}