setDays() public method

Set days
public setDays ( integer $days ) : Newscoop\Entity\SubscriptionSection
$days integer
return Newscoop\Entity\SubscriptionSection
 public function setDays($days)
 {
     $this->__load();
     return parent::setDays($days);
 }
示例#2
0
 /**
  * Add sections
  *
  * @param array $values
  * @param Newscoop\Entity\Publication $publication
  * @return void
  */
 public function addSections(array $values, \Newscoop\Entity\Publication $publication)
 {
     $languages = array();
     if (!empty($values['individual_languages']) && $values['individual_languages']) {
         $languages = $values['languages'];
         if (empty($languages)) {
             throw new \InvalidArgumentException("No languages set for individual languages");
         }
     }
     foreach ($publication->getIssues() as $issue) {
         if (!empty($languages) && !in_array($issue->getLanguageId(), $languages)) {
             continue;
         }
         foreach ($issue->getSections() as $section) {
             if ($this->hasSection($section, $languages)) {
                 continue;
             }
             $subSection = new Section($this, $section->getNumber());
             $subSection->setStartDate(new \DateTime($values['start_date']));
             $subSection->setDays($values['days']);
             if ($this->isTrial() || $values['type'] === self::TYPE_PAID_NOW) {
                 $subSection->setPaidDays($values['days']);
             }
             if (!empty($languages)) {
                 $subSection->setLanguage($issue->getLanguage());
             }
         }
     }
 }