当前位置: 首页>>代码示例>>PHP>>正文


PHP Converter::getInstance方法代码示例

本文整理汇总了PHP中XLite\Core\Converter::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Converter::getInstance方法的具体用法?PHP Converter::getInstance怎么用?PHP Converter::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XLite\Core\Converter的用法示例。


在下文中一共展示了Converter::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCreate

 /**
  * testCreate
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testCreate()
 {
     $c = new \XLite\Model\Country();
     foreach ($this->entityData as $field => $testValue) {
         $setterMethod = 'set' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
         $getterMethod = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
         $c->{$setterMethod}($testValue);
         $value = $c->{$getterMethod}();
         $this->assertEquals($testValue, $value, 'Creation checking (' . $field . ')');
     }
     $s = new \XLite\Model\State();
     $s->setState('test state');
     $s->setCode('ttt');
     $c->addStates($s);
     $em = \XLite\Core\Database::getEM();
     $em->persist($c);
     $em->flush();
     $em->clear();
     $c = \XLite\Core\Database::getEM()->merge($c);
     foreach ($this->entityData as $field => $testValue) {
         $getterMethod = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
         $this->assertEquals($testValue, $c->{$getterMethod}(), 'Creation checking (' . $field . ') #2');
     }
     $this->assertEquals($s->getStateId(), $c->getStates()->get(0)->getStateId(), 'check state');
     $em->remove($c);
     $em->flush();
 }
开发者ID:kingsj,项目名称:core,代码行数:35,代码来源:Country.php

示例2: getFieldValue

 /**
  * Get field value
  *
  * @param string  $fieldName    Field name
  * @param boolean $processValue Process value flag OPTIONAL
  *
  * @return string
  */
 public function getFieldValue($fieldName, $processValue = false)
 {
     $result = '';
     $address = $this->getAddressInfo();
     if ($this->getCart() && $this->getCart()->getProfile() && 'email' == $fieldName) {
         $result = $this->getCart()->getProfile()->getLogin();
     } elseif ($this->getCart() && $this->getCart()->getProfile() && 'password' == $fieldName) {
         $result = \XLite\Core\Session::getInstance()->createProfilePassword;
     } elseif (isset($address)) {
         $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($fieldName);
         // $methodName assembled from 'get' + camelized $fieldName
         $result = $address->{$methodName}();
         if ($result && false !== $processValue) {
             switch ($fieldName) {
                 case 'state_id':
                     $result = $address->getCountry()->hasStates() ? $address->getState()->getState() : null;
                     break;
                 case 'custom_state':
                     $result = $address->getCountry()->hasStates() ? null : $result;
                     break;
                 case 'country_code':
                     $result = $address->getCountry()->getCountry();
                     break;
                 case 'type':
                     $result = $address->getTypeName();
                     break;
                 default:
             }
         }
     } elseif (in_array($fieldName, array('country_code', 'state_id', 'custom_state', 'zipcode'))) {
         $result = \XLite\Model\Address::getDefaultFieldPlainValue($fieldName);
     }
     return $result;
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:42,代码来源:AAddressBlock.php

示例3: testCreate

 /**
  * testCreate
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testCreate()
 {
     $c = new \XLite\Model\Category();
     foreach ($this->categoryData as $field => $testValue) {
         $setterMethod = 'set' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
         $getterMethod = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
         $c->{$setterMethod}($testValue);
         $value = $c->{$getterMethod}();
         $this->assertEquals($testValue, $value, 'Creation checking (' . $field . ')');
     }
     $qf = new \XLite\Model\Category\QuickFlags();
     $qf->setCategory($c);
     $c->setQuickFlags($qf);
     $this->assertEquals($qf, $c->getQuickFlags(), 'test quick flags');
     $m = \XLite\Core\Database::getRepo('XLite\\Model\\Membership')->findAll();
     $c->setMembership($m[0]);
     $this->assertEquals($m[0], $c->getMembership(), 'check membership');
     $i = new \XLite\Model\Image\Category\Image();
     $c->setImage($i);
     $this->assertEquals($i, $c->getImage(), 'check image');
     $cp = new \XLite\Model\CategoryProducts();
     $c->addCategoryProducts($cp);
     $this->assertEquals($cp, $c->getCategoryProducts()->get(0), 'check category products');
     $this->assertEquals(1, count($c->getCategoryProducts()), 'check category products length');
     $child = new \XLite\Model\Category();
     $c->addChildren($child);
     $child->setParent($c);
     $this->assertEquals($child, $c->getChildren()->get(0), 'check childs');
     $this->assertEquals(1, count($c->getChildren()), 'check childs length');
     $this->assertEquals($c, $child->getParent(), 'check parent');
 }
开发者ID:kingsj,项目名称:core,代码行数:39,代码来源:Category.php

示例4: getTitle

 /**
  * Return the current page title (for the content area)
  *
  * @return string
  */
 public function getTitle()
 {
     if ($this->checkAccess()) {
         $title = static::t('Order #X, Y', array('id' => $this->getOrderNumber(), 'date' => \XLite\Core\Converter::getInstance()->formatTime($this->getOrder()->getDate())));
     } else {
         $title = static::t('Order not found');
     }
     return $title;
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:14,代码来源:Order.php

示例5: testCreate

 /**
  * testCreate
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testCreate()
 {
     $c = new \XLite\Model\Membership();
     foreach ($this->entityData as $field => $testValue) {
         $setterMethod = 'set' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
         $getterMethod = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
         $c->{$setterMethod}($testValue);
         $value = $c->{$getterMethod}();
         $this->assertEquals($testValue, $value, 'Creation checking (' . $field . ')');
     }
 }
开发者ID:kingsj,项目名称:core,代码行数:19,代码来源:Membership.php

示例6: testCreate

 /**
  * testCreate
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testCreate()
 {
     $c = new \XLite\Model\ViewList();
     foreach ($this->entityData as $field => $testValue) {
         $setterMethod = 'set' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
         $getterMethod = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
         $c->{$setterMethod}($testValue);
         $value = $c->{$getterMethod}();
         $this->assertEquals($testValue, $value, 'Creation checking (' . $field . ')');
     }
     \XLite\Core\Database::getEM()->persist($c);
     \XLite\Core\Database::getEM()->flush();
     $this->assertTrue(0 < $c->getListId(), 'check list id');
     \XLite\Core\Database::getEM()->remove($c);
     \XLite\Core\Database::getEM()->flush();
 }
开发者ID:kingsj,项目名称:core,代码行数:24,代码来源:ViewList.php

示例7: testCreate

 /**
  * testCreate
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.17
  */
 public function testCreate()
 {
     $p = new \XLite\Model\DataSource\Parameter();
     foreach ($this->entityData as $field => $testValue) {
         $setterMethod = 'set' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
         $getterMethod = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
         $p->{$setterMethod}($testValue);
         $value = $p->{$getterMethod}();
         $this->assertEquals($testValue, $value, 'Creation checking (' . $field . ')');
     }
     $em = \XLite\Core\Database::getEM();
     $em->persist($p);
     $em->flush();
     $this->assertTrue(0 < $p->getId(), 'check parameter id');
     $em->remove($p);
     $em->flush();
 }
开发者ID:kingsj,项目名称:core,代码行数:25,代码来源:Parameter.php

示例8: getFieldValue

 /**
  * getFieldValue
  *
  * @param string  $fieldName    Field name
  * @param boolean $processValue Process value flag OPTIONAL
  *
  * @return string
  */
 public function getFieldValue($fieldName, $processValue = false)
 {
     $result = '';
     $address = $this->getParam(self::PARAM_ADDRESS);
     $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($fieldName);
     if (method_exists($address, $methodName)) {
         // $methodName assembled from 'get' + camelized $fieldName
         $result = $address->{$methodName}();
         if (false !== $processValue) {
             switch ($fieldName) {
                 case 'state_id':
                     $result = $address->getState()->getState();
                     break;
                 case 'country_code':
                     $result = $address->getCountry()->getCountry();
                     break;
                 default:
             }
         }
     }
     return $result;
 }
开发者ID:kingsj,项目名称:core,代码行数:30,代码来源:Address.php

示例9: testCheckAddress

 public function testCheckAddress()
 {
     // Prepare address and save it in database
     $origAddress = new \XLite\Model\Address();
     $origAddress->map($this->addressFields);
     $origAddress->setState(\XLite\Core\Database::getRepo('XLite\\Model\\State')->findOneByCountryAndCode('US', 'NY'));
     $origAddress->setCountry(\XLite\Core\Database::getRepo('XLite\\Model\\Country')->find('US'));
     $origAddress->setProfile(\XLite\Core\Database::getRepo('XLite\\Model\\Profile')->find(1));
     $address = $origAddress->cloneEntity();
     $origAddress->create();
     // Test: new address should not be created as it is identical
     $this->assertFalse($address->create(), "Check that address is not created (all fields are identical)");
     foreach (\XLite\Model\Address::getAddressFields() as $field) {
         $address = $origAddress->cloneEntity();
         if ('state_id' == $field) {
             $address->setState(\XLite\Core\Database::getRepo('XLite\\Model\\State')->findOneByCountryAndCode('US', 'CA'));
         } elseif ('country_code' == $field) {
             $address->setCountry(\XLite\Core\Database::getRepo('XLite\\Model\\Country')->find('GB'));
         } elseif ('custom_state' != $field) {
             $address->map($this->addressFields);
             $methodName = 'set' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
             $this->assertTrue(method_exists($address, $methodName), "Check if method exists ({$methodName})");
             $modifiedField = $this->addressFields[$field] . '2';
             $address->{$methodName}($modifiedField);
         }
         // Test: new address must be created as one of fields is modified
         $this->assertTrue($address->create(), "Check if address is created ({$field})");
     }
 }
开发者ID:kingsj,项目名称:core,代码行数:29,代码来源:Address.php

示例10: getTitle

 /**
  * Return the current page title (for the content area)
  *
  * @return string
  */
 public function getTitle()
 {
     return static::t('Invoice #{{orderId}}, {{time}}', array('orderId' => $this->getOrderId(), 'time' => \XLite\Core\Converter::getInstance()->formatTime($this->getOrder()->getDate())));
 }
开发者ID:kingsj,项目名称:core,代码行数:9,代码来源:Invoice.php

示例11: preprocessDate

 /**
  * Preprocess "date" field
  *
  * @param integer                                          $date   Date
  * @param array                                            $column Column data
  * @param \XLite\Module\XC\CanadaPost\Model\ProductsReturn $entity Canada Post return model
  *
  * @return string
  */
 protected function preprocessDate($date, array $column, \XLite\Module\XC\CanadaPost\Model\ProductsReturn $entity)
 {
     return $date ? \XLite\Core\Converter::getInstance()->formatTime($date) : static::t('Unknown');
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:13,代码来源:ProductsReturn.php

示例12: defineFindSameAddressQuery

 /**
  * defineFindSameAddressQuery
  *
  * @return \Doctrine\ORM\QueryBuilder
  */
 protected function defineFindSameAddressQuery($address)
 {
     $params = array();
     $qb = $this->createQueryBuilder();
     $qb->innerJoin('a.profile', 'p')->andWhere('p.profile_id = :profile_id');
     $params['profile_id'] = $address->getProfile()->getProfileId();
     if ($address->getAddressId()) {
         $qb->andWhere($qb->expr()->not('a.address_id = :address_id'));
         $params['address_id'] = $address->getAddressId();
     }
     $fields = $address->getAddressFields();
     foreach ($fields as $field) {
         if ('state_id' == $field) {
             if ($address->getStateId()) {
                 $qb->innerJoin('a.state', 's')->andWhere('s.state_id = :state_id');
                 $params[$field] = $address->getStateId();
             } else {
                 $qb->leftJoin('a.state', 's')->andWhere('s.state_id IS NULL');
             }
         } elseif ('country_code' == $field) {
             $qb->innerJoin('a.country', 'c')->andWhere('c.code = :country_code');
             $params[$field] = $address->getCountryCode();
         } else {
             $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($field);
             if (method_exists($address, $methodName)) {
                 $qb->andWhere(sprintf('a.%s = :%s', $field, $field));
                 // Assign value from address
                 $params[$field] = $address->{$methodName}();
             }
         }
     }
     $qb->setParameters($params);
     return $qb;
 }
开发者ID:kingsj,项目名称:core,代码行数:39,代码来源:Address.php

示例13: testUpdate

 /**
  * testUpdate
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testUpdate()
 {
     // Test #1
     $profile1 = $this->getTestProfile(1, 0);
     $profile1->map($this->testProfileData[2]);
     $profile1->setMembership(null);
     $profile1->setPendingMembership(null);
     $result = $profile1->update();
     // Update result must be true
     $this->assertTrue($result, 'update() must return true');
     // Get updated profile from the database
     $profile2 = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->find($profile1->getProfileId());
     // Check if profile properties are correctly updated
     foreach ($this->testProfileData[2] as $key => $value) {
         $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($key);
         // membership_id must be null after updating if it has a zero value initially
         if (in_array($key, array('membership_id', 'pending_membership_id')) && 0 === $value) {
             $this->assertNull($profile2->{$methodName}(), 'Wrong property (' . $key . ')');
         } else {
             $this->assertEquals($value, $profile2->{$methodName}(), 'Wrong property (' . $key . ')');
         }
     }
     $this->assertTrue(is_null($profile2->getMembership()), 'Membership is expected to be null');
     // Test #2: update user with login that is used by other user, check for duplicate login
     $profile3 = $this->getTestProfile(0, 0);
     $profile4 = $this->getTestProfile(1, 0);
     $origLogin = $profile4->getLogin();
     $origProfileId = $profile4->getProfileId();
     $profile4->setLogin($profile3->getLogin());
     $result = $profile4->update();
     $this->assertFalse($result, 'update() must return false');
     $profile5 = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->find($origProfileId);
     // TODO: check why this test failed
     //$this->assertEquals($origLogin, $profile5->getLogin(), 'Checking for duplicate login');
 }
开发者ID:kingsj,项目名称:core,代码行数:43,代码来源:Profile.php

示例14: getFieldValue

 /**
  * Get field value
  *
  * @param string               $fieldName    Field name
  * @param \XLite\Model\Address $address      Field name
  *
  * @return string
  */
 protected function getFieldValue($fieldName, \XLite\Model\Address $address)
 {
     $result = '';
     if (isset($address)) {
         $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($fieldName);
         // $methodName assembled from 'get' + camelized $fieldName
         $result = $address->{$methodName}();
         if ($result) {
             switch ($fieldName) {
                 case 'state_id':
                     $result = $address->getCountry()->hasStates() ? $address->getState()->getState() : null;
                     break;
                 case 'custom_state':
                     $result = $address->getCountry()->hasStates() ? null : $result;
                     break;
                 case 'country_code':
                     $result = $address->getCountry()->getCountry();
                     break;
                 default:
             }
         }
     }
     return $result;
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:32,代码来源:SelectAddressOrder.php

示例15: getModelObjectValue

 /**
  * Retrieve property from the model object
  *
  * @param mixed $name Field/property name
  *
  * @return mixed
  */
 protected function getModelObjectValue($name)
 {
     $methodName = 'get' . \XLite\Core\Converter::getInstance()->convertToCamelCase($name);
     $value = null;
     if (method_exists($this->getModelObject(), $methodName)) {
         // Call the corresponded method
         $value = $this->getModelObject()->{$methodName}();
     }
     return $value;
 }
开发者ID:kingsj,项目名称:core,代码行数:17,代码来源:AModel.php


注:本文中的XLite\Core\Converter::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。