コード例 #1
0
ファイル: Address.php プロジェクト: kingsj/core
 /**
  * testGetCountry
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testGetCountry()
 {
     $address = new \XLite\Model\Address();
     $address->map($this->addressFields);
     $address->setCountry(\XLite\Core\Database::getRepo('XLite\\Model\\Country')->find('US'));
     $this->assertInstanceOf('\\XLite\\Model\\Country', $address->getCountry(), 'Country checking');
 }
コード例 #2
0
ファイル: ACustomer.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Filter schema fields
  *
  * @param array $fields Schema fields to filter
  *
  * @return array
  */
 protected function getFilteredSchemaFields($fields)
 {
     if (!isset($fields['country_code'])) {
         // Country code field is disabled
         // We need leave oonly one state field: selector or text field
         $deleteStateSelector = true;
         $address = new \XLite\Model\Address();
         if ($address && $address->getCountry() && $address->getCountry()->hasStates()) {
             $deleteStateSelector = false;
         }
         if ($deleteStateSelector && isset($fields['state_id'])) {
             unset($fields['state_id']);
             if (isset($fields['custom_state'])) {
                 $fields['custom_state']['additionalClass'] = 'single-state-field';
             }
         } elseif (!$deleteStateSelector && isset($fields['custom_state'])) {
             unset($fields['custom_state']);
             if (isset($fields['state_id'])) {
                 $fields['state_id'][\XLite\View\FormField\Select\State::PARAM_COUNTRY] = $address->getCountry()->getCode();
                 $fields['state_id']['additionalClass'] = 'single-state-field';
             }
         }
     }
     return $fields;
 }