示例#1
0
 /**
  * Update other configs to not be Active.
  *
  * @throws ValidationException
  * @throws null
  */
 public function onAfterWrite()
 {
     if ($this->Active) {
         foreach (StreakConfig::get()->exclude('ID', $this->ID) as $otherConfig) {
             $otherConfig->Active = false;
             $otherConfig->write();
         }
     }
 }
示例#2
0
 /**
 * Returns the one or more active DiscountTypes (site, member, product) in order of preference (or an empty array if none found).
 *
 *@return array
 */
 public function resolveDiscountTypes()
 {
     $discountTypes = array();
     if (StreakConfig::streak_config()->StreakSiteWideDiscountID) {
         $discountTypes['SiteWide'] = StreakDiscountType::get()->byID(StreakConfig::streak_config()->StreakSiteWideDiscountID);
     }
     if (Member::currentUserID()) {
         $discountTypes['Member'] = StreakDiscountType::get()->byID(Member::currentUser()->StreakDiscountTypeID);
     }
     if ($this->owner->StreakDiscountTypeID) {
         $discountTypes['Product'] = $this->owner->StreakDiscountType();
     }
     return array_filter($discountTypes);
 }