| @@ 503-521 (lines=19) @@ | ||
| 500 | * @param PhoneUtils $phoneUtils |
|
| 501 | * @param string $method |
|
| 502 | */ |
|
| 503 | public static function register(PhoneUtils $phoneUtils, string $method = 'addPhone') |
|
| 504 | { |
|
| 505 | // Check for multiple registration |
|
| 506 | if (self::$registered) { |
|
| 507 | throw new Nette\InvalidStateException('Phone control already registered.'); |
|
| 508 | } |
|
| 509 | ||
| 510 | self::$registered = TRUE; |
|
| 511 | ||
| 512 | $class = function_exists('get_called_class') ? get_called_class() : __CLASS__; |
|
| 513 | Forms\Container::extensionMethod( |
|
| 514 | $method, function (Forms\Container $form, $name, $label = NULL, $maxLength = NULL) use ($class, $phoneUtils) { |
|
| 515 | $component = new $class($phoneUtils, $label, $maxLength); |
|
| 516 | $form->addComponent($component, $name); |
|
| 517 | ||
| 518 | return $component; |
|
| 519 | } |
|
| 520 | ); |
|
| 521 | } |
|
| 522 | } |
|
| 523 | ||
| @@ 198-216 (lines=19) @@ | ||
| 195 | * |
|
| 196 | * @return void |
|
| 197 | */ |
|
| 198 | public static function register(UI\ITemplateFactory $templateFactory, $method = 'addSlug') |
|
| 199 | { |
|
| 200 | // Check for multiple registration |
|
| 201 | if (static::$registered) { |
|
| 202 | throw new Exceptions\InvalidStateException('Slug control already registered.'); |
|
| 203 | } |
|
| 204 | ||
| 205 | static::$registered = TRUE; |
|
| 206 | ||
| 207 | $class = function_exists('get_called_class') ? get_called_class() : __CLASS__; |
|
| 208 | Forms\Container::extensionMethod( |
|
| 209 | $method, function (Forms\Container $form, $name, $label = NULL, $maxLength = NULL) use ($class, $templateFactory) { |
|
| 210 | $component = new $class($templateFactory, $label, $maxLength); |
|
| 211 | $form->addComponent($component, $name); |
|
| 212 | ||
| 213 | return $component; |
|
| 214 | } |
|
| 215 | ); |
|
| 216 | } |
|
| 217 | } |
|
| 218 | ||