Exemple #1
0
 /**
  * Get the best matching currency.
  *
  * @return Currency A currency.
  */
 protected function getCurrency()
 {
     $currencyService = $this->container->get('currencyService');
     //TODO: decouple price calculations from product, etc into a place where language/currency/etc are provided in a sane way!
     $session = Runtime::getContainer()->get('session');
     $currency = $currencyService->getCurrencyForCode($session->get('currency'));
     if (null == $currency) {
         Runtime::getLogging()->warn('no currency found - using default currency');
         $currency = $currencyService->getCurrencyForCode($this->container->get('settingsService')->get('defaultCurrency'));
     }
     return $currency;
 }
 /**
  * {@inheritDoc}
  */
 public function render($request, TemplateView $templateView)
 {
     if ($this->isMultiValue()) {
         Runtime::getLogging()->debug('multi-value: defaulting style to select');
         $this->set('style', 'select');
     }
     switch ($this->get('style')) {
         default:
             Runtime::getLogging()->debug('invalid style "' . $this->get('style') . '" - using default');
         case 'select':
             return $this->renderSelect($request);
         case 'radio':
             return $this->renderRadio($request);
     }
 }
Exemple #3
0
 /**
  * Render a widget.
  *
  * @param mixed widget Either a <code>Widget</code> instance or a widget bean definition.
  * @param string name Optional name; default is <code>null</code> for none.
  * @param string value Optional value; default is <code>null</code> for none.
  * @param mixed args Optional parameter; a map of widget properties;  default is <code>null</code>.
  * @return string The widget contents.
  */
 public function widget($widget, $name = null, $value = null, $args = null)
 {
     $wObj = $widget;
     if (is_string($widget)) {
         $wObj = Beans::getBean($widget);
     }
     if (!$wObj instanceof Widget) {
         Runtime::getLogging()->debug('invalid widget: ' . $widget);
         return '';
     }
     if (null !== $name) {
         $wObj->setName($name);
         if (null === $args || !array_key_exists('id', $args)) {
             // no id set, so default to name
             $wObj->setId($name);
         }
     }
     if (null !== $value) {
         $wObj->setValue($value);
     }
     if (null !== $args) {
         Beans::setAll($wObj, $args);
     }
     return $wObj->render($this->container->get('request'), $this->container->get('defaultView'));
 }
 /**
  * {@inheritDoc}
  */
 public function render($request, TemplateView $templateView)
 {
     switch ($this->get('style')) {
         default:
             Runtime::getLogging()->debug('invalid style "' . $this->get('style') . '" - using default');
         case 'checkbox':
             return $this->renderCheckbox($request);
         case 'radio':
             return $this->renderRadio($request);
         case 'select':
             return $this->renderSelect($request);
     }
 }