File manager - Edit - /home/linknsbh/cecil-hotel.net/vendor/botble/platform/base/src/Forms/FormHelper.php
Back
<?php namespace Botble\Base\Forms; use Illuminate\Contracts\View\Factory as View; use Illuminate\Translation\Translator; use InvalidArgumentException; use Kris\LaravelFormBuilder\FormHelper as BaseFormHelper; class FormHelper extends BaseFormHelper { protected array $customTypes = []; public function __construct(View $view, Translator $translator, array $config = []) { parent::__construct($view, $translator, $config); $this->loadCustomTypes(); } protected function loadCustomTypes(): void { $customFields = (array)$this->getConfig('custom_fields'); if (! empty($customFields)) { foreach ($customFields as $fieldName => $fieldClass) { $this->addCustomField($fieldName, $fieldClass); } } } public function getFieldType($type) { $types = array_keys(static::$availableFieldTypes); if (! $type || trim($type) == '') { throw new InvalidArgumentException('Field type must be provided.'); } if ($this->hasCustomField($type)) { return $this->customTypes[$type]; } if (in_array($type, $types, true)) { $namespace = __NAMESPACE__ . '\\FieldTypes\\'; return $namespace . static::$availableFieldTypes[$type]; } if (class_exists($type)) { if (! is_subclass_of($type, FormField::class)) { throw new InvalidArgumentException(sprintf('Could not load type "%s": class is not a subclass of "%s".', $type, FormField::class)); } return $type; } throw new InvalidArgumentException( sprintf( 'Unsupported field type [%s]. Available types are: %s', $type, join(', ', array_merge($types, array_keys($this->customTypes))) ) ); } public function hasCustomField($name): bool { return array_key_exists($name, $this->customTypes); } public function addCustomField($name, $class) { if (! $this->hasCustomField($name)) { return $this->customTypes[$name] = $class; } throw new InvalidArgumentException('Custom field [' . $name . '] already exists on this form object.'); } }
| ver. 1.4 |
Github
|
.
| PHP 8.2.31 | Generation time: 0.55 |
proxy
|
phpinfo
|
Settings