本文整理汇总了PHP中Agent::getProperties方法的典型用法代码示例。如果您正苦于以下问题:PHP Agent::getProperties方法的具体用法?PHP Agent::getProperties怎么用?PHP Agent::getProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Agent
的用法示例。
在下文中一共展示了Agent::getProperties方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAgentEmail
/**
* Answer a email for an agent
*
* @param Agent $agent
* @return string
*/
protected function getAgentEmail(Agent $agent)
{
// print_r($agent->getProperties()); exit;
$propertiesIterator = $agent->getProperties();
while ($propertiesIterator->hasNext()) {
$properties = $propertiesIterator->next();
if (!is_null($properties->getProperty('EMail'))) {
return $properties->getProperty('EMail');
}
if (!is_null($properties->getProperty('email'))) {
return $properties->getProperty('email');
}
if (!is_null($properties->getProperty('Email'))) {
return $properties->getProperty('Email');
}
}
return null;
}
示例2: __construct
/**
* Constructor
*
* @param object Agent $agent
* @return void
* @access public
* @since 11/27/07
*/
public function __construct(Agent $agent)
{
$this->id = $agent->getId();
$this->name = $agent->getDisplayName();
try {
$propertiesIterator = $agent->getProperties();
while ($propertiesIterator->hasNext()) {
$properties = $propertiesIterator->next();
try {
if ($properties->getProperty('email')) {
$this->email = $properties->getProperty('email');
break;
}
} catch (Exception $e) {
}
}
} catch (Exception $e) {
}
}
示例3: agentMatches
/**
* Compare an Agent to an Agent XML description and determine if the two match.
*
* The current implementation of this method is kind of goofy. It should be
* re-worked to either use a more reliable comparison method or be made configurable
* for different comparrison methods.
*
* @param object Agent $agent
* @param object DOMElement $element
* @return boolean
* @access protected
* @since 1/28/08
*/
protected function agentMatches(Agent $agent, DOMElement $element)
{
// check some system-ids first as these will not have meaningful properties
// to compare and their IDs are hard coded into the system.
$sourceId = $element->getAttribute('id');
$systemIds = array("edu.middlebury.agents.everyone", "edu.middlebury.institute", "1", "edu.middlebury.agents.anonymous");
if (in_array($sourceId, $systemIds)) {
if ($sourceId == $agent->getId()->getIdString()) {
return true;
} else {
return false;
}
}
// Compare agent properties to make sure that the agent and the DOMElement
// are representing the same user.
$xmlPropertiesToCheck = array('email', 'username');
$agentPropertiesToCheck = array('email', 'username');
// How man properties must match
$threshold = 1;
$matches = 0;
$xmlValues = array();
foreach ($xmlPropertiesToCheck as $property) {
// printpre(htmlentities($this->doc->saveXMLWithWhitespace($element)));
$valueElements = $this->xpath->evaluate('./property[key = \'' . $property . '\']/string', $element);
if ($valueElements->length) {
$xmlValues[] = $this->getStringValue($valueElements->item(0));
}
// throw new Exception('test error');
}
$agentPropertiesIterator = $agent->getProperties();
while ($agentPropertiesIterator->hasNext()) {
$properties = $agentPropertiesIterator->next();
// printpre($properties->getKeys());
foreach ($agentPropertiesToCheck as $key) {
try {
$value = $properties->getProperty($key);
// printpre($value);
if (!is_null($value) && in_array($value, $xmlValues)) {
$matches++;
}
} catch (UnknownKeyException $e) {
}
}
}
if ($matches >= $threshold) {
return true;
} else {
return false;
}
}
示例4: getAgentEmail
/**
* Answer the email address of an agent
*
* @param Agent $agent
* @return string
* @access protected
* @since 2/19/09
*/
protected function getAgentEmail(Agent $agent)
{
$properties = $agent->getProperties();
$email = null;
while ($properties->hasNext()) {
$email = $properties->next()->getProperty("email");
if (preg_match('/^[^\\s@]+@[^\\s@]+$/', $email)) {
return $email;
}
}
throw new OperationFailedException("No email found for agent, '" . $agent->getDisplayName() . "'.");
}