Пример #1
0
 /**
  * @param CM_Frontend_Environment $environment
  * @return DateTimeZone
  */
 protected function _getTimeZone(CM_Frontend_Environment $environment)
 {
     if (null === $this->_timeZone) {
         return $environment->getTimeZone();
     }
     return $this->_timeZone;
 }
Пример #2
0
 public function testSetNull()
 {
     $environment = new CM_Frontend_Environment();
     $this->assertEquals(CM_Site_Abstract::factory(), $environment->getSite());
     $this->assertNull($environment->getViewer());
     $this->assertNull($environment->getLanguage());
     $this->assertSame('en', $environment->getLocale());
     $this->assertEquals(CM_Bootloader::getInstance()->getTimeZone(), $environment->getTimeZone());
     $this->assertSame(CM_Bootloader::getInstance()->isDebug(), $environment->isDebug());
     $this->assertNull($environment->getLocation());
 }
Пример #3
0
 public function testSetNull()
 {
     $defaultCurrency = CM_Model_Currency::create('840', 'USD');
     $environment = new CM_Frontend_Environment();
     $this->assertEquals(CM_Site_Abstract::factory(), $environment->getSite());
     $this->assertNull($environment->getViewer());
     $this->assertNull($environment->getLanguage());
     $this->assertSame('en', $environment->getLocale());
     $this->assertEquals(CM_Bootloader::getInstance()->getTimeZone(), $environment->getTimeZone());
     $this->assertSame(CM_Bootloader::getInstance()->isDebug(), $environment->isDebug());
     $this->assertNull($environment->getLocation());
     $this->assertEquals($defaultCurrency, $environment->getCurrency());
     $this->assertNull($environment->getClientDevice());
 }
Пример #4
0
 public function prepare(CM_Params $renderParams, CM_Frontend_Environment $environment, CM_Frontend_ViewResponse $viewResponse)
 {
     $viewResponse->set('class', $renderParams->has('class') ? $renderParams->getString('class') : null);
     $years = range($this->_yearFirst, $this->_yearLast);
     $months = range(1, 12);
     $days = range(1, 31);
     $viewResponse->set('years', array_combine($years, $years));
     $viewResponse->set('months', array_combine($months, $months));
     $viewResponse->set('days', array_combine($days, $days));
     /** @var DateTime|null $value */
     $value = $this->getValue();
     $year = $month = $day = null;
     if (null !== $value) {
         $value->setTimezone($environment->getTimeZone());
         $year = $value->format('Y');
         $month = $value->format('n');
         $day = $value->format('j');
     }
     $viewResponse->set('yy', $year);
     $viewResponse->set('mm', $month);
     $viewResponse->set('dd', $day);
 }