WatchdogForm
extends BaseComponent
in package
uses
FormTrait, ModalTrait, InMultiplierTrait
Table of Contents
Constants
- DELETE_MODAL_TARGET : mixed = 'watchdogDeleteModal'
- FORM_MODAL_TARGET : mixed = 'watchdogFormModal'
- STATE_PARAMETER_KEY : string = 'state'
- Key of the parent parameter "state".
- TYPE_PARAMETER_KEY : string = 'type'
- Key of the parent parameter "type" (options = its children, the advert carries `value` = option id).
Properties
- $container : Container
- $routerDispatcher : RouterDispatcher
- $translator : ITranslator
- $watchdogId : int
- $appContext : AppContext
- $componentParameters : array<string, mixed>
- $currencyContext : CurrencyContext|null
- $deviceDetector : DeviceDetector|null
- $languageContext : LanguageContext|null
- $localizationContext : LocalizationContext|null
- $settingContext : SettingContext
- $themeContext : ThemeContext|null
- $translatorDomain : string|null
- $categoryManager : CategoryManager
- $categorySuggestFactory : CategorySuggestFactory
- $eventDispatcher : EventDispatcher
- $languageManager : LanguageManager
- $modalRegistry : ModalRegistry
- $parameterManager : ParameterManager
- $regionManager : RegionManager
- $regionSuggestFactory : RegionSuggestFactory
- $watchdogManager : WatchdogManager
Methods
- __call() : mixed
- Dispatches `renderXyz()` to `render('Xyz', ...$args)`.
- __construct() : mixed
- createComponent() : IComponent|null
- getAppContext() : AppContext
- getComponentParameter() : mixed
- Returns a component parameter, or null when it is not set.
- getContainer() : Container
- getCurrencyContext() : CurrencyContext|null
- getLanguageContext() : LanguageContext|null
- getLocalizationContext() : LocalizationContext|null
- getRouterDispatcher() : RouterDispatcher
- getSettingContext() : SettingContext
- getSettings() : array<int, array<string, mixed>>
- getThemeContext() : ThemeContext|null
- handleDelete() : void
- handleShowDeleteModal() : void
- handleShowFormModal() : void
- hasServiceByType() : bool
- Returns whether the container has a service of the given type.
- init() : self
- initializeAllContexts() : void
- injectDeviceDetector() : void
- onCreate() : void
- onError() : void
- Invalid form: the modal must be redrawn, otherwise the user does not see field errors (region from the suggest, e-mail). Errors without a field (CSRF) have no field in the template, so they go to a generic flash.
- onSuccess() : void
- onValidate() : void
- The category is required; typed text without a choice from the suggest is an error.
- render() : void
- setAppContext() : $this
- setComponentParameter() : void
- Sets a component parameter.
- setCurrencyContext() : $this
- setLanguageContext() : $this
- setLocalizationContext() : $this
- setSettingContext() : $this
- setThemeContext() : $this
- setup() : void
- setupAppContext() : void
- typedComponent() : T
- Returns a subcomponent with a verified type.
- createComponentCategorySuggest() : CategorySuggest
- Category suggest (shared component, source = the front `CategoryManager` of the module): a category of any level can be watched; matching with an advert goes through the subtree of the watchdog category.
- createComponentForm() : Form
- createComponentRegionSuggest() : RegionSuggest
- Region suggest: a watchdog may watch a country, region, district or municipality; matching goes through the ancestors of the advert region.
- frontPresenter() : BasePresenter|null
- Returns the front presenter the component is attached to (null outside the front end or when detached).
- getDeleteModalTarget() : string
- getFormModalTarget() : string
- getTranslator() : ITranslator
- prepareFormTemplate() : void
- setTemplateFile() : void
- setTranslator() : self
- createDeleteContent() : string
- createDeleteResultContent() : string
- createFormContent() : string
- createModalEvent() : ModalWindowEvent
- createMultiplierComponent() : Multiplier<string|int, IComponent>
- Creates a multiplier for the component.
- createNewComponentInstance() : IComponent|null
- Creates a new component instance without adding it to the presenter; used by the multiplier.
- createStandardComponent() : IComponent|null
- Creates a standard component (not a multiplier).
- createSuccessContent() : string
- getCategoryLabel() : string
- getParameterLabel() : string
- isSelectableCategory() : bool
- The chosen category exists, is active and is not admin-only (any tree level).
- isSelectableRegion() : bool
- The chosen region exists and is active (any tree level).
- isTyped() : bool
- The user typed something into the suggest field (regardless of a choice from the options).
- prepareLanguageList() : array<int, string>
- prepareStateList() : array<int, string>
- prepareTypeList() : array<int, string>
- resolveCategoryLabel() : string
- Label of the saved category for edit (suggest text); a non-existent one gives an empty text.
- resolveDefaultRegionId() : int|null
- Localization country (`cms_system_localizations.cms_system_regions_region_id`).
- resolveLanguageId() : int
- resolveRegionId() : int
- updateModalContent() : void
Constants
DELETE_MODAL_TARGET
private
mixed
DELETE_MODAL_TARGET
= 'watchdogDeleteModal'
FORM_MODAL_TARGET
private
mixed
FORM_MODAL_TARGET
= 'watchdogFormModal'
STATE_PARAMETER_KEY
Key of the parent parameter "state".
private
string
STATE_PARAMETER_KEY
= 'state'
TYPE_PARAMETER_KEY
Key of the parent parameter "type" (options = its children, the advert carries `value` = option id).
private
string
TYPE_PARAMETER_KEY
= 'type'
Properties
$container
public
Container
$container
Attributes
- #[Inject]
$routerDispatcher
public
RouterDispatcher
$routerDispatcher
$translator
public
ITranslator
$translator
Tags
$watchdogId
public
int
$watchdogId
= 0
Attributes
- #[Persistent]
$appContext
protected
AppContext
$appContext
$componentParameters
protected
array<string, mixed>
$componentParameters
= []
component parameters set by setComponentParameter()
$currencyContext
protected
CurrencyContext|null
$currencyContext
= NULL
$deviceDetector
protected
DeviceDetector|null
$deviceDetector
= NULL
$languageContext
protected
LanguageContext|null
$languageContext
= NULL
$localizationContext
protected
LocalizationContext|null
$localizationContext
= NULL
$settingContext
protected
SettingContext
$settingContext
$themeContext
protected
ThemeContext|null
$themeContext
= NULL
$translatorDomain
protected
string|null
$translatorDomain
= 'front.comcat.components.watchdogForm'
$categoryManager read-only
private
CategoryManager
$categoryManager
$categorySuggestFactory read-only
private
CategorySuggestFactory
$categorySuggestFactory
$eventDispatcher read-only
private
EventDispatcher
$eventDispatcher
$languageManager read-only
private
LanguageManager
$languageManager
$modalRegistry read-only
private
ModalRegistry
$modalRegistry
$parameterManager read-only
private
ParameterManager
$parameterManager
$regionManager read-only
private
RegionManager
$regionManager
$regionSuggestFactory read-only
private
RegionSuggestFactory
$regionSuggestFactory
$watchdogManager read-only
private
WatchdogManager
$watchdogManager
Methods
__call()
Dispatches `renderXyz()` to `render('Xyz', ...$args)`.
public
__call(string $name, array<string|int, mixed> $args) : mixed
Called only when the component has no renderXyz() method of its own.
Parameters
- $name : string
- $args : array<string|int, mixed>
__construct()
public
__construct(WatchdogManager $watchdogManager, CategoryManager $categoryManager, RegionManager $regionManager, LanguageManager $languageManager, ParameterManager $parameterManager, ModalRegistry $modalRegistry, EventDispatcher $eventDispatcher, RegionSuggestFactory $regionSuggestFactory, CategorySuggestFactory $categorySuggestFactory) : mixed
Parameters
- $watchdogManager : WatchdogManager
- $categoryManager : CategoryManager
- $regionManager : RegionManager
- $languageManager : LanguageManager
- $parameterManager : ParameterManager
- $modalRegistry : ModalRegistry
- $eventDispatcher : EventDispatcher
- $regionSuggestFactory : RegionSuggestFactory
- $categorySuggestFactory : CategorySuggestFactory
createComponent()
public
createComponent(string $name) : IComponent|null
Parameters
- $name : string
Return values
IComponent|nullgetAppContext()
public
getAppContext() : AppContext
Return values
AppContextgetComponentParameter()
Returns a component parameter, or null when it is not set.
public
getComponentParameter(string $name) : mixed
Parameters
- $name : string
getContainer()
public
getContainer() : Container
Return values
ContainergetCurrencyContext()
public
getCurrencyContext() : CurrencyContext|null
Return values
CurrencyContext|nullgetLanguageContext()
public
getLanguageContext() : LanguageContext|null
Return values
LanguageContext|nullgetLocalizationContext()
public
getLocalizationContext() : LocalizationContext|null
Return values
LocalizationContext|nullgetRouterDispatcher()
public
getRouterDispatcher() : RouterDispatcher
Return values
RouterDispatchergetSettingContext()
public
getSettingContext() : SettingContext
Return values
SettingContextgetSettings()
public
getSettings() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>getThemeContext()
public
getThemeContext() : ThemeContext|null
Return values
ThemeContext|nullhandleDelete()
public
handleDelete(int $watchdogId) : void
Parameters
- $watchdogId : int
handleShowDeleteModal()
public
handleShowDeleteModal(int $watchdogId) : void
Parameters
- $watchdogId : int
handleShowFormModal()
public
handleShowFormModal([int $watchdogId = 0 ]) : void
Parameters
- $watchdogId : int = 0
hasServiceByType()
Returns whether the container has a service of the given type.
public
hasServiceByType(string $className) : bool
The name is composed dynamically (module plus component), so class_exists() runs first, and
a true result guarantees a valid type.
Parameters
- $className : string
Tags
Return values
boolinit()
public
init([int $watchdogId = 0 ]) : self
Parameters
- $watchdogId : int = 0
Return values
selfinitializeAllContexts()
public
initializeAllContexts() : void
injectDeviceDetector()
public
injectDeviceDetector(DeviceDetector $detector) : void
Parameters
- $detector : DeviceDetector
onCreate()
public
onCreate() : void
onError()
Invalid form: the modal must be redrawn, otherwise the user does not see field errors (region from the suggest, e-mail). Errors without a field (CSRF) have no field in the template, so they go to a generic flash.
public
onError(Form $form) : void
Parameters
- $form : Form
onSuccess()
public
onSuccess(Form $form, ArrayHash $values) : void
Parameters
- $form : Form
- $values : ArrayHash
onValidate()
The category is required; typed text without a choice from the suggest is an error.
public
onValidate(Container $form) : void
Without a region the localization country is watched; when the localization has none, the region is required. Typed text without a choice is an error (otherwise "Brnoo" would store the whole country).
Parameters
- $form : Container
render()
public
render() : void
setAppContext()
public
setAppContext(AppContext $appContext) : $this
Parameters
- $appContext : AppContext
Return values
$thissetComponentParameter()
Sets a component parameter.
public
setComponentParameter(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
setCurrencyContext()
public
setCurrencyContext(CurrencyContext|null $currencyContext) : $this
Parameters
- $currencyContext : CurrencyContext|null
Return values
$thissetLanguageContext()
public
setLanguageContext(LanguageContext|null $languageContext) : $this
Parameters
- $languageContext : LanguageContext|null
Return values
$thissetLocalizationContext()
public
setLocalizationContext(LocalizationContext|null $localizationContext) : $this
Parameters
- $localizationContext : LocalizationContext|null
Return values
$thissetSettingContext()
public
setSettingContext(SettingContext $settingContext) : $this
Parameters
- $settingContext : SettingContext
Return values
$thissetThemeContext()
public
setThemeContext(ThemeContext|null $themeContext) : $this
Parameters
- $themeContext : ThemeContext|null
Return values
$thissetup()
public
setup(BasePresenter|BasePresenter $presenter) : void
Parameters
- $presenter : BasePresenter|BasePresenter
setupAppContext()
public
setupAppContext(AppContext $appContext) : void
Parameters
- $appContext : AppContext
typedComponent()
Returns a subcomponent with a verified type.
public
typedComponent(string $name, T> $type) : T
Use it instead of an inline @var above $this['x'] (which does not narrow the type) and
instead of the generic IComponent that $this['x'] returns. See
Form::typedComponent().
Parameters
- $name : string
- $type : T>
Tags
Return values
TcreateComponentCategorySuggest()
Category suggest (shared component, source = the front `CategoryManager` of the module): a category of any level can be watched; matching with an advert goes through the subtree of the watchdog category.
protected
createComponentCategorySuggest() : CategorySuggest
Return values
CategorySuggestcreateComponentForm()
protected
createComponentForm() : Form
Return values
FormcreateComponentRegionSuggest()
Region suggest: a watchdog may watch a country, region, district or municipality; matching goes through the ancestors of the advert region.
protected
createComponentRegionSuggest() : RegionSuggest
Return values
RegionSuggestfrontPresenter()
Returns the front presenter the component is attached to (null outside the front end or when detached).
protected
frontPresenter() : BasePresenter|null
Return values
BasePresenter|nullgetDeleteModalTarget()
protected
getDeleteModalTarget() : string
Return values
stringgetFormModalTarget()
protected
getFormModalTarget() : string
Return values
stringgetTranslator()
protected
getTranslator() : ITranslator
Return values
ITranslatorprepareFormTemplate()
protected
prepareFormTemplate() : void
setTemplateFile()
protected
setTemplateFile(string $dir, string $filename) : void
Parameters
- $dir : string
- $filename : string
setTranslator()
protected
setTranslator(ITranslator $translator) : self
Parameters
- $translator : ITranslator
Return values
selfcreateDeleteContent()
private
createDeleteContent() : string
Return values
stringcreateDeleteResultContent()
private
createDeleteResultContent(bool $success) : string
Parameters
- $success : bool
Return values
stringcreateFormContent()
private
createFormContent() : string
Return values
stringcreateModalEvent()
private
createModalEvent(string $content, string $target[, array<string, mixed> $extraOptions = [] ]) : ModalWindowEvent
Parameters
- $content : string
- $target : string
- $extraOptions : array<string, mixed> = []
Return values
ModalWindowEventcreateMultiplierComponent()
Creates a multiplier for the component.
private
createMultiplierComponent(string $name) : Multiplier<string|int, IComponent>
Parameters
- $name : string
Return values
Multiplier<string|int, IComponent>createNewComponentInstance()
Creates a new component instance without adding it to the presenter; used by the multiplier.
private
createNewComponentInstance(string $baseName[, int|string|null $uniqueKey = null ]) : IComponent|null
Parameters
- $baseName : string
- $uniqueKey : int|string|null = null
Return values
IComponent|nullcreateStandardComponent()
Creates a standard component (not a multiplier).
private
createStandardComponent(string $name) : IComponent|null
Parameters
- $name : string
Return values
IComponent|nullcreateSuccessContent()
private
createSuccessContent() : string
Return values
stringgetCategoryLabel()
private
getCategoryLabel(Category $category, int|null $langId) : string
Parameters
- $category : Category
- $langId : int|null
Return values
stringgetParameterLabel()
private
getParameterLabel(Parameter $parameter, int|null $langId) : string
Parameters
- $parameter : Parameter
- $langId : int|null
Return values
stringisSelectableCategory()
The chosen category exists, is active and is not admin-only (any tree level).
private
isSelectableCategory(mixed $value) : bool
Parameters
- $value : mixed
Return values
boolisSelectableRegion()
The chosen region exists and is active (any tree level).
private
isSelectableRegion(mixed $value) : bool
Parameters
- $value : mixed
Return values
boolisTyped()
The user typed something into the suggest field (regardless of a choice from the options).
private
isTyped(TextInput $display) : bool
Parameters
- $display : TextInput
Return values
boolprepareLanguageList()
private
prepareLanguageList() : array<int, string>
Return values
array<int, string>prepareStateList()
private
prepareStateList() : array<int, string>
Return values
array<int, string>prepareTypeList()
private
prepareTypeList() : array<int, string>
Return values
array<int, string>resolveCategoryLabel()
Label of the saved category for edit (suggest text); a non-existent one gives an empty text.
private
resolveCategoryLabel(int $categoryId) : string
Parameters
- $categoryId : int
Return values
stringresolveDefaultRegionId()
Localization country (`cms_system_localizations.cms_system_regions_region_id`).
private
resolveDefaultRegionId() : int|null
Return values
int|nullresolveLanguageId()
private
resolveLanguageId() : int
Return values
intresolveRegionId()
private
resolveRegionId(mixed $value) : int
Parameters
- $value : mixed
Return values
intupdateModalContent()
private
updateModalContent(string $content, string $target) : void
Parameters
- $content : string
- $target : string