本文整理汇总了PHP中Node::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Node::getName方法的具体用法?PHP Node::getName怎么用?PHP Node::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node
的用法示例。
在下文中一共展示了Node::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteNode
/**
* @param Node $node
*/
public function deleteNode(Node $node)
{
if (isset($this->nodes[$node->getName()])) {
unset($this->nodes[$node->getName()]);
} else {
foreach ($this->nodes as $n) {
$n->deleteNode($node);
}
}
}
示例2: insertByPath
/**
* Recursively inserts a path of nodes
*
* @param Node $curr_node
* @param string $path a slash delimited path of node names
* @param array $array optional data array added to last node in the path
*/
public function insertByPath(&$curr_node, $path = '', $array = null)
{
if (is_string($path)) {
$p = explode('/', $path);
$n = array_shift($p);
if ($curr_node instanceof Node) {
$curr_name = $curr_node->getName();
}
if ($curr_name === $n) {
if (isset($p[0])) {
$n = $p[0];
}
if ($next_node = $curr_node->getNode($n)) {
$next_node = $next_node;
} else {
$next_node = $curr_node;
}
} else {
$new_node = self::build($n);
$new_node->setData($array);
$curr_node->insert($new_node);
$next_node = $new_node;
}
if ($n !== '') {
$remaining_path = implode('/', $p);
while (count($p) > 0) {
return $this->insertByPath($next_node, $remaining_path, $array);
}
}
}
}
示例3: processNodeResult
/**
* Process the result of the given node. Returns false if no other nodes
* should be run, or a string with the next node name.
*
* @param Node $node Node that was run
*
* @return string
*/
protected function processNodeResult(Node $node)
{
$result = null;
$name = $node->getName();
if (isset($this->nodeResults[$name])) {
foreach ($this->nodeResults[$name] as $resultInfo) {
if ($resultInfo->appliesTo($node)) {
if ($resultInfo->isActionHangup()) {
// hanging up after $name
$this->client->hangup();
} elseif ($resultInfo->isActionJumpTo()) {
$data = $resultInfo->getActionData();
if (isset($data['nodeEval'])) {
$callback = $data['nodeEval'];
$nodeName = $callback($node);
} else {
$nodeName = $data['nodeName'];
}
// jumping from $name to $nodeName
$result = $nodeName;
} elseif ($resultInfo->isActionExecute()) {
// executing callback after $name
$data = $resultInfo->getActionData();
$callback = $data['callback'];
$callback($node);
}
}
}
}
return $result;
}
示例4: __construct
public function __construct(Node $node, User $user, $action)
{
$this->user = $user;
$this->node = $node;
$this->name = $node->getName();
$this->description = $node->getDescription();
$this->descr = $node->getDescr();
$this->action = $action;
$this->action_time = new \DateTime();
}
示例5: buildXML
private function buildXML(Node $node, $xml)
{
$xml .= '<node name="' . htmlentities($node->getName(), ENT_QUOTES, 'UTF-8') . '">';
if ($node->hasProperties()) {
$xml = $this->buildXMLProperties($node, $xml);
}
if ($node->hasNodes()) {
$ni = $node->getNodes();
while ($ni->hasNext()) {
$temporaryNode = $ni->nextNode();
if ($temporaryNode->hasNodes()) {
$xml = $this->buildXML($temporaryNode, $xml);
} else {
$xml .= '<node name="' . htmlentities($temporaryNode->getName(), ENT_QUOTES, 'UTF-8') . '">';
if ($temporaryNode->hasProperties()) {
$xml = $this->buildXMLProperties($temporaryNode, $xml);
}
$xml .= '</node>';
}
}
}
return $xml .= '</node>';
}
示例6: _updateGraphPool
/**
* Updates the node pool of Graph
*
* @param Node $node Node to be added to the pool
* @return void
* @access protected
*/
public function _updateGraphPool(Node &$node)
{
$key = $this->_getKey($node->getName());
$this->_pool[$key] = $node;
}
示例7: nameAccessors
public function nameAccessors()
{
$n = new Node('node');
$n->setName('name');
$this->assertEquals('name', $n->getName());
}
示例8: hasNode
/**
* Return TRUE if the given node is registered for this application
*
* @param Node $node
* @return boolean
*/
public function hasNode(Node $node)
{
return isset($this->nodes[$node->getName()]);
}
示例9: writeTag
/**
* Write the given tag to the stream.
*
* @param resource $fPtr Stream pointer
* @param Node $node Tag to write
*
* @return bool
*/
private function writeTag($fPtr, Node $node)
{
return $this->dataHandler->putTAGByte($fPtr, $node->getType()) && $this->dataHandler->putTAGString($fPtr, $node->getName()) && $this->writeType($fPtr, $node->getType(), $node);
}
示例10: _unmarshall
/**
* Recursively deserialize data for the given node.
*
* @param xml.Node node
* @return var
* @throws lang.IllegalArgumentException if the data cannot be deserialized
* @throws lang.ClassNotFoundException in case a XP object's class could not be loaded
* @throws xml.XMLFormatException
*/
protected function _unmarshall(Node $node)
{
// value without type is supposed to be string (XML-RPC specs)
if ('value' == $node->getName() && !isset($node->children[0])) {
return (string) $node->getContent();
}
if (!isset($node->children[0])) {
throw new XMLFormatException('Tried to access nonexistant node.');
}
// Simple form: If no subnode indicating the type exists, the type
// is string, e.g. <value>Test</value>
if (!$node->hasChildren()) {
return (string) $node->getContent();
}
// Long form - with subnode, the type is derived from the node's name,
// e.g. <value><string>Test</string></value>.
$c = $node->nodeAt(0);
switch ($c->getName()) {
case 'struct':
$ret = array();
foreach ($c->getChildren() as $child) {
$data = array();
$data[$child->nodeAt(0)->getName()] = $child->nodeAt(0);
$data[$child->nodeAt(1)->getName()] = $child->nodeAt(1);
$ret[$data['name']->getContent()] = $this->_unmarshall($data['value']);
unset($data);
}
if (!isset($ret['__xp_class'])) {
return $ret;
}
// Check whether this is a XP object. If so, load the class and
// create an instance without invoking the constructor.
$fields = XPClass::forName($ret['__xp_class'])->getFields();
$cname = array_search($ret['__xp_class'], xp::$cn, TRUE);
$s = '';
$n = 0;
foreach ($fields as $field) {
if (!isset($ret[$field->getName()])) {
continue;
}
$m = $field->getModifiers();
if ($m & MODIFIER_STATIC) {
continue;
} else {
if ($m & MODIFIER_PUBLIC) {
$name = $field->getName();
} else {
if ($m & MODIFIER_PROTECTED) {
$name = "*" . $field->getName();
} else {
if ($m & MODIFIER_PRIVATE) {
$name = "" . array_search($field->getDeclaringClass()->getName(), xp::$cn, TRUE) . "" . $field->getName();
}
}
}
}
$s .= 's:' . strlen($name) . ':"' . $name . '";' . serialize($ret[$field->getName()]);
$n++;
}
return unserialize('O:' . strlen($cname) . ':"' . $cname . '":' . $n . ':{' . $s . '}');
case 'array':
$ret = array();
foreach ($c->nodeAt(0)->getChildren() as $child) {
$ret[] = $this->_unmarshall($child);
}
return $ret;
case 'int':
case 'i4':
return (int) $c->getContent();
case 'double':
return (double) $c->getContent();
case 'boolean':
return (bool) $c->getContent();
case 'string':
return (string) $c->getContent();
case 'dateTime.iso8601':
return Date::fromString($c->getContent());
case 'nil':
return NULL;
case 'base64':
return new Bytes(base64_decode($c->getContent()));
default:
throw new IllegalArgumentException('Could not decode node as its type is not supported: ' . $c->getName());
}
}
示例11: setNode
/**
* Sets a node in the $nodes array; uses the name of the node as index.
*
* Nodes can be retrieved by retrieving the property with the same name.
* Thus 'node1' can be retrieved by invoking: $graph->node1
*
* @param \phpDocumentor\GraphViz\Node $node The node to set onto this Graph.
*
* @see \phpDocumentor\GraphViz\Node::create()
*
* @return \phpDocumentor\GraphViz\Graph
*/
public function setNode(Node $node)
{
$this->nodes[$node->getName()] = $node;
return $this;
}
示例12: addNode
/**
* @param Node $node
*/
public function addNode(Node $node)
{
$this->nodes[$node->getName()] = $node;
}
示例13: testSetNameMethod
public function testSetNameMethod()
{
$this->object->setName('foo');
$this->assertEquals('foo', $this->object->getName());
}
示例14: inArray
/**
* @param Node $needle
* @param Node[] $haystack
* @return bool True if $needle is in $haystack
*/
private function inArray($needle, array $haystack)
{
foreach ($haystack as $straw) {
if ($straw->getName() === $needle->getName()) {
return true;
}
}
return false;
}
示例15: toArray
/**
* Returns an array representation of the given Node structure.
*
* @param Node $node
*
* @return array
*/
public function toArray(Node $node)
{
return array('name' => $node->getName(), 'value' => $node->getValue(), 'attributes' => $node->getAttributes(), 'children' => array_map(function (Node $child) {
return $this->toArray($child);
}, $node->getChildren()));
}