本文整理汇总了PHP中Relation::getAllRelations方法的典型用法代码示例。如果您正苦于以下问题:PHP Relation::getAllRelations方法的具体用法?PHP Relation::getAllRelations怎么用?PHP Relation::getAllRelations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relation
的用法示例。
在下文中一共展示了Relation::getAllRelations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAffectedInvConjunctIds
public static function getAffectedInvConjunctIds($fullRelationSignature)
{
$allRelations = Relation::getAllRelations();
if (!array_key_exists($fullRelationSignature, $allRelations)) {
throw new Exception("Relation \\'{$fullRelationSignature}\\' does not exists in allRelations", 500);
}
return (array) $allRelations[$fullRelationSignature]['affectedInvConjunctIds'];
}
示例2: conjPerfStats
/**
* @url GET stats/performance/conjuncts
* @param string $groupBy
* @param int $from
* @param int $to
*/
public function conjPerfStats($groupBy = 'conjuncts', $from = 0, $to = 10)
{
try {
if (Config::get('productionEnv')) {
throw new Exception("Performance tests are not allowed in production environment", 403);
}
$performanceArr = array();
// run all conjuncts (from - to)
for ($i = $from; $i <= $to; $i++) {
$conj = RuleEngine::getConjunct('conj_' . $i);
$startTimeStamp = microtime(true);
// true means get as float instead of string
RuleEngine::checkConjunct('conj_' . $i, false);
$endTimeStamp = microtime(true);
$performanceArr['conj_' . $i] = array('id' => 'conj_' . $i, 'start' => $startTimeStamp, 'end' => $endTimeStamp, 'duration' => $endTimeStamp - $startTimeStamp, 'invariantRules' => implode(';', $conj['invariantRuleNames']), 'signalRules' => implode(';', $conj['signalRuleNames']));
}
switch ($groupBy) {
case 'conjuncts':
return array_values($performanceArr);
break;
case 'rules':
$ruleArr = array();
foreach (RuleEngine::getAllRules() as $rule) {
$duration = 0;
foreach ($rule['conjunctIds'] as $conj) {
$duration += $performanceArr[$conj]['duration'];
}
$ruleArr[] = array('ruleName' => $rule['name'], 'duration' => $duration, 'conjuncts' => implode(';', $rule['conjunctIds']));
}
return $ruleArr;
break;
case 'relations':
$relArr = array();
foreach (Relation::getAllRelations() as $sig => $rel) {
$duration = 0;
$conjuncts = array_merge($rel['affectedInvConjunctIds'], $rel['affectedSigConjunctIds']);
foreach ($conjuncts as $conj) {
$duration += $performanceArr[$conj]['duration'];
}
$relArr[] = array('relationSignature' => $sig, 'duration' => $duration, 'conjuncts' => implode(';', $conjuncts));
}
return $relArr;
break;
default:
throw new Exception("Unknown groupBy argument", 500);
break;
}
} catch (Exception $e) {
throw new RestException($e->getCode(), $e->getMessage());
}
}