本文整理汇总了PHP中Symfony\Component\HttpKernel\Profiler\Profile::addChild方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::addChild方法的具体用法?PHP Profile::addChild怎么用?PHP Profile::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpKernel\Profiler\Profile
的用法示例。
在下文中一共展示了Profile::addChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testChildren
public function testChildren()
{
$parentProfile = new Profile('token_parent');
$parentProfile->setIp('127.0.0.1');
$parentProfile->setUrl('http://foo.bar/parent');
$childProfile = new Profile('token_child');
$childProfile->setIp('127.0.0.1');
$childProfile->setUrl('http://foo.bar/child');
$parentProfile->addChild($childProfile);
self::$storage->write($parentProfile);
self::$storage->write($childProfile);
// Load them from storage
$parentProfile = self::$storage->read('token_parent');
$childProfile = self::$storage->read('token_child');
// Check child has link to parent
$this->assertNotNull($childProfile->getParent());
$this->assertEquals($parentProfile->getToken(), $childProfile->getParent()->getToken());
// Check parent has child
$children = $parentProfile->getChildren();
$this->assertCount(1, $children);
$this->assertEquals($childProfile->getToken(), $children[0]->getToken());
}
示例2: createProfileFromData
private function createProfileFromData($token, $data, $parent = null)
{
$profile = new Profile($token);
$profile->setIp($data['ip']);
$profile->setMethod($data['method']);
$profile->setUrl($data['url']);
$profile->setTime($data['time']);
$profile->setCollectors($data['data']);
if (!$parent && $data['parent']) {
$parent = $this->read($data['parent']);
}
if ($parent) {
$profile->setParent($parent);
}
foreach ($data['children'] as $token) {
if (!$token) {
continue;
}
if (!($childProfileData = $this->getValue($this->getItemName($token), self::REDIS_SERIALIZER_PHP))) {
continue;
}
$profile->addChild($this->createProfileFromData($token, $childProfileData, $profile));
}
return $profile;
}