本文整理汇总了PHP中ArrayUtils::getValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtils::getValueOrDefault方法的具体用法?PHP ArrayUtils::getValueOrDefault怎么用?PHP ArrayUtils::getValueOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayUtils
的用法示例。
在下文中一共展示了ArrayUtils::getValueOrDefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionPullFrecuentMenteeSubdomains
public function actionPullFrecuentMenteeSubdomains()
{
$associationFilter = new AssociationFilter();
if (isset($_POST['AssociationFilter'])) {
$associationFilter->attributes = $_POST['AssociationFilter'];
if (!is_numeric($associationFilter->lowerBoundMinSupport)) {
$associationFilter->lowerBoundMinSupport = 0.1;
}
if (!is_numeric($associationFilter->numRulesToFind)) {
$associationFilter->numRulesToFind = 10;
}
if (!is_numeric($associationFilter->uppperBoundMinSupport)) {
$associationFilter->uppperBoundMinSupport = 1.0;
}
} else {
$associationFilter->setDefaultValues();
}
// echo $associationFilter->lowerBoundMinSupport;
//1 pull all the attributes (Dinstinct SubDomains used)
$subdomainsUsedCol = Subdomain::getAllSubdomainsInUse();
//2 build the attributes collection
$attributeCol = array();
$attributeMap = array();
$lastAttribIndex = count($subdomainsUsedCol) - 1;
for ($i = 0; $i <= $lastAttribIndex; $i++) {
$attribKey = $subdomainsUsedCol[$i]->name;
$attribute = new Attribute($attribKey, $i);
$attributeCol[] = $attribute;
$attributeMap[$attribKey] = $attribute;
}
//3 pull all the item sets (relation of Subdomains with mentee)
$subdomainsPerMenteeCol = AssociationFilter::retrieveSubDomainsUsedPerMentee();
//4 build the instances
$instancesCol = array();
$currentCreatorID = NULL;
$currentInstance = NULL;
foreach ($subdomainsPerMenteeCol as $data) {
if ($currentInstance == NULL || $currentCreatorID != ArrayUtils::getValueOrDefault($data, "MenteeUserID", 0)) {
$currentCreatorID = ArrayUtils::getValueOrDefault($data, "MenteeUserID", 0);
$currentInstance = new Instance($lastAttribIndex + 1);
$instancesCol[] = $currentInstance;
}
$attribKey = ArrayUtils::getValueOrDefault($data, "SubDomainName", 0);
$currentInstance->setValue($attributeMap[$attribKey], 1);
}
$instances = new Instances($attributeCol, $instancesCol);
//5 calculate the association rules
$fpGrowth = new FPGrowth();
$fpGrowth->m_numRulesToFind = $associationFilter->numRulesToFind;
$fpGrowth->m_upperBoundMinSupport = $associationFilter->uppperBoundMinSupport;
$fpGrowth->lowerBoundMinSupport = $associationFilter->lowerBoundMinSupport;
$fpGrowth->buildAssociations($instances);
//6 render the association rules
$rules = $fpGrowth->getRules();
$associations = array();
$id = 0;
foreach ($rules as $rule) {
$associations[] = array("id" => $id, "Operator" => " ==> ", "Premise" => $this->renderBinaryItemsCommaSeparated($rule->getPremise()), "Consequence" => $this->renderBinaryItemsCommaSeparated($rule->getConsequence()));
//echo $this->renderBinaryItemsCommaSeparated($rule->getPremise()). " ==> ".$this->renderBinaryItemsCommaSeparated($rule->getConsequence()). "</br>";
$id++;
}
$dataProvider = new CArrayDataProvider($associations, array('pagination' => false));
$this->render("frecuentMenteeSubdomains", array('dataprovider' => $dataProvider, 'filter' => $associationFilter));
}
示例2: retrieveUnansweredTicketsDashboardData
public function retrieveUnansweredTicketsDashboardData()
{
//retrieve tha data
$ticketsCreatedData = $this->retrieveUnansweredTicketsData();
$chartData = "";
foreach ($ticketsCreatedData as $data) {
$countPart = ArrayUtils::getValueOrDefault($data, "EventCount", 0);
if (DimensionType::isTimeDimension($this->dim2ID)) {
$currentReadingYear = ArrayUtils::getValueOrDefault($data, "Year", 1);
$currentReadingMonth = ArrayUtils::getValueOrDefault($data, "Month", 1);
$currentReadingDay = ArrayUtils::getValueOrDefault($data, "Day", 1);
$chartData = $chartData . sprintf('[new Date(%s, %s, %s), %s],', $currentReadingYear, $currentReadingMonth - 1, $currentReadingDay, $countPart);
} else {
switch ($this->dim2ID) {
case DimensionType::TicketAssignedMentor:
$mentorName = ArrayUtils::getValueOrDefault($data, "MentorName", 0);
$chartData = $chartData . sprintf("['%s', %s],", $mentorName, $countPart);
break;
case DimensionType::Mentee:
$menteeName = ArrayUtils::getValueOrDefault($data, "MenteeName", 0);
$chartData = $chartData . sprintf("['%s', %s],", $menteeName, $countPart);
break;
case DimensionType::DomainExclusive:
$domainExclusive = ArrayUtils::getValueOrDefault($data, "Domain", 0);
$chartData = $chartData . sprintf("['%s', %s],", $domainExclusive, $countPart);
break;
case DimensionType::DomainAggregated:
$domainAggregated = ArrayUtils::getValueOrDefault($data, "Domain", 0);
$chartData = $chartData . sprintf("['%s', %s],", $domainAggregated, $countPart);
break;
case DimensionType::SubDomain:
$subDomain = ArrayUtils::getValueOrDefault($data, "SubDomain", 0);
$chartData = $chartData . sprintf("['%s', %s],", $subDomain, $countPart);
break;
case DimensionType::Project:
$project = ArrayUtils::getValueOrDefault($data, "Project", 0);
$chartData = $chartData . sprintf("['%s', %s],", $project, $countPart);
break;
}
}
}
//format the data
$chartFormatedData = "[" . $chartData . "]";
// "[[new Date(2015, 2, 1),1],[new Date(2015, 3, 1),1]]";// json_encode($monthData);
return $chartFormatedData;
}