当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayUtils::getValueOrDefault方法代码示例

本文整理汇总了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));
 }
开发者ID:acuba001,项目名称:Collaborative-Platform,代码行数:64,代码来源:AnalyticsController.php

示例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;
 }
开发者ID:acuba001,项目名称:Collaborative-Platform,代码行数:46,代码来源:UtilizationDashboardFilter.php


注:本文中的ArrayUtils::getValueOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。