Scalr\Stats\CostAnalytics\Entity\ReportEntity::save PHP Method

save() public method

See also: Scalr\Model\AbstractEntity::save()
public save ( )
    public function save()
    {
        if (empty($this->emails)) {
            throw new AnalyticsException(sprintf("Email must be set for the %s.", get_class($this)));
        }
        parent::save();
    }

Usage Example

コード例 #1
0
ファイル: Costcenters.php プロジェクト: mheydt/scalr
 /**
  * @param string $ccId
  * @param array  $settings
  * @throws AnalyticsException
  * @throws Scalr_UI_Exception_NotFound
  */
 private function saveReports($ccId, $settings)
 {
     $uuids = array();
     foreach ($settings['items'] as $item) {
         $report = new ReportEntity();
         if ($item['uuid']) {
             $report->findPk($item['uuid']);
         }
         $report->subjectType = $item['subjectType'];
         $subject = null;
         if ($report->subjectType == ReportEntity::SUBJECT_TYPE_CC) {
             $subject = $this->getContainer()->analytics->ccs->get($item['subjectId']);
         } elseif ($report->subjectType == ReportEntity::SUBJECT_TYPE_PROJECT) {
             $subject = $this->getContainer()->analytics->projects->get($item['subjectId']);
         } else {
             $report->subjectType = null;
             $report->subjectId = null;
         }
         if ($report->subjectType) {
             if ($item['subjectId'] && !$subject) {
                 throw new Scalr_UI_Exception_NotFound();
             }
             $report->subjectId = $item['subjectId'] ? $item['subjectId'] : null;
         }
         $report->period = $item['period'];
         $report->emails = $item['emails'];
         $report->status = $item['status'];
         $report->save();
         $uuids[] = $report->uuid;
     }
     foreach (ReportEntity::find([['subjectType' => ReportEntity::SUBJECT_TYPE_CC], ['subjectId' => $ccId]]) as $report) {
         if (!in_array($report->uuid, $uuids)) {
             $report->delete();
         }
     }
 }
All Usage Examples Of Scalr\Stats\CostAnalytics\Entity\ReportEntity::save