1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
numberfieldassembler.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\Grid\Row\Assembler\Field;
4
5use Bitrix\Main\Context;
6use Bitrix\Main\Context\Culture;
7use Bitrix\Main\Grid\Row\FieldAssembler;
8use Bitrix\Main\Grid\Settings;
9
32{
33 private bool $isFloat;
34 private ?Culture $culture;
35
42 public function __construct(bool $isFloat, array $columnIds, ?Settings $settings = null, ?Culture $culture = null)
43 {
44 $this->isFloat = $isFloat;
45 $this->culture = $culture;
46
47 parent::__construct($columnIds, $settings);
48 }
49
60 public static function createForContext(bool $isFloat, array $columnIds, ?Settings $settings = null, Context $context = null): self
61 {
62 $context ??= Context::getCurrent();
63
64 return new static(
65 $isFloat,
66 $columnIds,
67 $settings,
68 $context?->getCulture()
69 );
70 }
71
79 protected function prepareColumn($value): string|int|float|null
80 {
81 if (is_null($value))
82 {
83 return null;
84 }
85 elseif (!is_numeric($value))
86 {
87 return $this->isFloat ? 0.0 : 0;
88 }
89
90 if ($this->isFloat)
91 {
92 $value = (float)$value;
93 }
94 else
95 {
96 $value = (int)$value;
97 }
98
99 if (isset($this->culture))
100 {
101 return number_format(
102 $value,
103 $this->culture->getNumberDecimals(),
104 $this->culture->getNumberDecimalSeparator(),
105 $this->culture->getNumberThousandsSeparator(),
106 );
107 }
108
109 return $value;
110 }
111}
static createForContext(bool $isFloat, array $columnIds, ?Settings $settings=null, Context $context=null)
Определения numberfieldassembler.php:60
__construct(bool $isFloat, array $columnIds, ?Settings $settings=null, ?Culture $culture=null)
Определения numberfieldassembler.php:42
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$context
Определения csv_new_setup.php:223
Определения culture.php:9
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393