Exemplo n.º 1
0
 protected function loadBorders()
 {
     $borders = Config::get(['template', 'borders'], ['{', '}']);
     if (static::isValidBorders($borders)) {
         $this->borders = $borders;
     }
 }
Exemplo n.º 2
0
 /** @inheritdoc */
 public function render(ObjectInterface $handler)
 {
     /** @var HandlerInterface $handler */
     $templateStr = Config::get(['renderer', 'templates', $handler->getTemplate(), 'handler']);
     $template = new Template($templateStr);
     return $template->getString($this, $handler);
 }
Exemplo n.º 3
0
 /**
  * @param FormInterface $form
  *
  * @return string
  */
 public function result(FormInterface $form)
 {
     if ($form->getStatus() == Form::STATUS_SHOW_RESULT) {
         $templateStr = Config::get(['renderer', 'templates', $form->getTemplate(), 'result']);
         $template = new Template($templateStr);
         return $template->getString($this, $form);
     }
     return '';
 }
Exemplo n.º 4
0
 public function options(Field\ListField $field)
 {
     $templateStr = Config::get(['renderer', 'templates', $field->getTemplate(), 'checkSetOption']);
     $template = new Template($templateStr);
     $options = '';
     foreach ($field->options() as $option) {
         $options .= $template->getString($this, $field, $option);
     }
     return $options;
 }
Exemplo n.º 5
0
 /** @inheritdoc */
 public function render(ObjectInterface $block)
 {
     /** @var BlockInterface $block */
     if ($block->isRepeatable()) {
         $templateStr = Config::get(['renderer', 'templates', $block->getTemplate(), 'repeatBlock']);
     } elseif ($block->isRepeatableContainer()) {
         $templateStr = Config::get(['renderer', 'templates', $block->getTemplate(), 'repeatContainer']);
     } else {
         $templateStr = Config::get(['renderer', 'templates', $block->getTemplate(), 'block']);
     }
     $template = new Template($templateStr);
     return $template->getString($this, $block);
 }
Exemplo n.º 6
0
 public function render(ObjectInterface $attribute)
 {
     $template = null;
     /** @var KeyValuePair $attribute */
     if ($attribute->isCanBeShort()) {
         $template = new Template(Config::get(['renderer', 'templates', 'default', 'shortAttribute'], ''));
     } else {
         $template = new Template(Config::get(['renderer', 'templates', 'default', 'attribute'], ''));
     }
     if ($template === null) {
         return '';
     }
     return $template->getString($this, $attribute);
 }
Exemplo n.º 7
0
 /**
  * @param FormInterface|BlockInterface|FieldInterface $object
  *
  * @return string
  */
 public function errorsStr($object)
 {
     $errorDelimiter = Config::get(['renderer', 'errors', 'delimiter']);
     $errorsStr = implode($errorDelimiter, $object->getErrors());
     return $errorsStr;
 }
Exemplo n.º 8
0
 /**
  * @param FormInterface|BlockInterface|FieldInterface $object
  *
  * @return string
  */
 public function label($object)
 {
     $templateStr = Config::find(['renderer'], ['templates', $object->getTemplate(), 'label'], $object->getClass(), '');
     $template = new Template($templateStr);
     return $template->getString($this, $object);
 }
Exemplo n.º 9
0
 protected function generateInnerValidator($validatorName)
 {
     $validatorClassName = Config::get(['validator', $validatorName]);
     if (class_exists($validatorClassName) && in_array('NewInventor\\Form\\Validator\\ValidatorInterface', class_implements($validatorClassName))) {
         /** @var ValidatorInterface $validatorObj */
         $validatorObj = new $validatorClassName();
     } else {
         throw new ArgumentException('Класс для валидатора не найден.', 'validatorName');
     }
     return $validatorObj;
 }
Exemplo n.º 10
0
 public function testMerge()
 {
     Config::merge('status', ['array' => ['dfs', 'dfsdf'], 'asdasd']);
     self::assertEquals('asdasd', Config::get(['status', 0]));
 }
Exemplo n.º 11
0
 protected function addDefaultConfig($route, $config)
 {
     $customData = Config::get($route, []);
     Config::set($route, array_replace_recursive($config, $customData));
     unset($validatorData);
 }
Exemplo n.º 12
0
 public function getSelectorFromSettings($type = '')
 {
     if (empty($type)) {
         return '';
     }
     $selector = Config::get(['renderer', 'repeat', $type], '');
     TypeChecker::getInstance()->isString($selector, 'selector')->throwTypeErrorIfNotValid();
     return $selector;
 }