コード例 #1
0
 public function listStaticTimeZone()
 {
     if ($data = $this->getCache()->load('static_timezone')) {
         return $data;
     }
     // Using PHP time zone list
     $list = \DateTimeZone::listIdentifiers();
     foreach ($list as &$item) {
         $item = array('id' => $item, 'name' => $item, 'gmt' => \App_Util_Date::getTimezoneGmt($item));
     }
     $this->getCache()->save($list, 'static_timezone');
     return $list;
 }
コード例 #2
0
 protected function _mapToModel(array $data, $usePreset = true)
 {
     $data = parent::_mapToModel($data, $usePreset);
     if (isset($data['billingCycleStart']) && !is_array($data['billingCycleStart'])) {
         $regex = '/^\\-\\-\\-(?P<dayOfMonth>\\d{2,2})(?P<timezone>.*)$/';
         if (preg_match($regex, $data['billingCycleStart'], $matches)) {
             $tz = App_Util_Date::getTimezoneValue($matches['timezone']);
             $matches['dayOfMonth'] = intval($matches['dayOfMonth']);
             $enumService = Application\Service\EnumeratedService::getInstance();
             $timezones = $enumService->getEnum(Application\Service\EnumeratedService::TIME_ZONE_ENUM_NAME);
             foreach ($timezones as $exmpl) {
                 if ($exmpl['offset'] == $matches['timezone']) {
                     $tz = $exmpl['id'];
                     break;
                 }
             }
             $matches['timezone'] = $tz;
             $data['billingCycleStart'] = $matches;
         } else {
             $data['billingCycleStart'] = array();
         }
     }
     if (isset($data['defaultBillingAccount']['contact'])) {
         $data['defaultBillingAccount']['contactIsPrimaryContact'] = false;
     }
     if (isset($data['defaultBillingAccount']['address'])) {
         $data['defaultBillingAccount']['addressIsCompanyAddress'] = false;
     }
     if (isset($data['shippingAddress'])) {
         $data['shippingAddressIsCompanyAddress'] = false;
     }
     if (isset($data['billingContact'])) {
         $data['billingContactIsPrimaryContact'] = false;
     }
     if (isset($data['billingContactAddress'])) {
         $data['billingContactAddressIsCompanyAddress'] = false;
     }
     if (isset($data['primaryContactAddress'])) {
         $data['primaryContactAddressIsCompanyAddress'] = false;
     }
     if ($usePreset && !isset($data['parentId'])) {
         $data['parentId'] = \App::getOrgUserLogged()->getId();
     }
     return $data;
 }