CoolCMS API

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 are its children, an advert stores the option id in `value`).

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
Handles an invalid form: the modal must be redrawn, otherwise the user does not see the field errors (region, e-mail). Errors without a field (CSRF) have no place in the template, so they go to a generic flash.
onSuccess()  : void
onValidate()  : void
Validates the form: the category is required and text typed without a suggestion selected is an error. Without a region the localization country is watched; when the localization has none, the region is required. Typed region text without a selection is an error (otherwise a typo would save the whole country).
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
Creates the category suggest (shared component, source = the module's Front `CategoryManager`).
createComponentForm()  : Form
createComponentRegionSuggest()  : RegionSuggest
Creates the region suggest. A watchdog can watch a country, county, 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
Checks that the selected category exists, is active and is not admin-only (any tree level).
isSelectableRegion()  : bool
Checks that the selected region exists and is active (any tree level).
isTyped()  : bool
Checks that the user typed something into the suggest field (regardless of a selection).
prepareLanguageList()  : array<int, string>
prepareStateList()  : array<int, string>
prepareTypeList()  : array<int, string>
resolveCategoryLabel()  : string
Returns the saved category label for editing (suggest text); empty text when it does not exist.
resolveDefaultRegionId()  : int|null
Returns the website 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 are its children, an advert stores the option id in `value`).

private string TYPE_PARAMETER_KEY = 'type'

Properties

$watchdogId

public int $watchdogId = 0
Attributes
#[Persistent]

$componentParameters

protected array<string, mixed> $componentParameters = []

component parameters set by setComponentParameter()

$translatorDomain

protected string|null $translatorDomain = 'front.bazaar.components.watchdogForm'

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|null

getComponentParameter()

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
Container

getSettings()

public getSettings() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>

handleDelete()

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
phpstan-assert-if-true

class-string $className

Return values
bool

init()

public init([int $watchdogId = 0 ]) : self
Parameters
$watchdogId : int = 0
Return values
self

onError()

Handles an invalid form: the modal must be redrawn, otherwise the user does not see the field errors (region, e-mail). Errors without a field (CSRF) have no place 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()

Validates the form: the category is required and text typed without a suggestion selected is an error. Without a region the localization country is watched; when the localization has none, the region is required. Typed region text without a selection is an error (otherwise a typo would save the whole country).

public onValidate(Container $form) : void
Parameters
$form : Container

setComponentParameter()

Sets a component parameter.

public setComponentParameter(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed

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
template
Return values
T

createComponentCategorySuggest()

Creates the category suggest (shared component, source = the module's Front `CategoryManager`).

protected createComponentCategorySuggest() : CategorySuggest

A category of any level can be watched; matching with an advert goes through the watchdog category subtree.

Return values
CategorySuggest

createComponentRegionSuggest()

Creates the region suggest. A watchdog can watch a country, county, district or municipality; matching goes through the ancestors of the advert region.

protected createComponentRegionSuggest() : RegionSuggest
Return values
RegionSuggest

frontPresenter()

Returns the front presenter the component is attached to (null outside the front end or when detached).

protected frontPresenter() : BasePresenter|null
Return values
BasePresenter|null

getDeleteModalTarget()

protected getDeleteModalTarget() : string
Return values
string

getFormModalTarget()

protected getFormModalTarget() : string
Return values
string

getTranslator()

protected getTranslator() : ITranslator
Return values
ITranslator

prepareFormTemplate()

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
self

createDeleteContent()

private createDeleteContent() : string
Return values
string

createDeleteResultContent()

private createDeleteResultContent(bool $success) : string
Parameters
$success : bool
Return values
string

createFormContent()

private createFormContent() : string
Return values
string

createModalEvent()

private createModalEvent(string $content, string $target[, array<string, mixed> $extraOptions = [] ]) : ModalWindowEvent
Parameters
$content : string
$target : string
$extraOptions : array<string, mixed> = []
Return values
ModalWindowEvent

createMultiplierComponent()

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|null

createStandardComponent()

Creates a standard component (not a multiplier).

private createStandardComponent(string $name) : IComponent|null
Parameters
$name : string
Return values
IComponent|null

createSuccessContent()

private createSuccessContent() : string
Return values
string

getCategoryLabel()

private getCategoryLabel(Category $category, int|null $langId) : string
Parameters
$category : Category
$langId : int|null
Return values
string

getParameterLabel()

private getParameterLabel(Parameter $parameter, int|null $langId) : string
Parameters
$parameter : Parameter
$langId : int|null
Return values
string

isSelectableCategory()

Checks that the selected category exists, is active and is not admin-only (any tree level).

private isSelectableCategory(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

isSelectableRegion()

Checks that the selected region exists and is active (any tree level).

private isSelectableRegion(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

isTyped()

Checks that the user typed something into the suggest field (regardless of a selection).

private isTyped(TextInput $display) : bool
Parameters
$display : TextInput
Return values
bool

prepareLanguageList()

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()

Returns the saved category label for editing (suggest text); empty text when it does not exist.

private resolveCategoryLabel(int $categoryId) : string
Parameters
$categoryId : int
Return values
string

resolveDefaultRegionId()

Returns the website localization country (`cms_system_localizations.cms_system_regions_region_id`).

private resolveDefaultRegionId() : int|null
Return values
int|null

resolveLanguageId()

private resolveLanguageId() : int
Return values
int

resolveRegionId()

private resolveRegionId(mixed $value) : int
Parameters
$value : mixed
Return values
int

updateModalContent()

private updateModalContent(string $content, string $target) : void
Parameters
$content : string
$target : string
On this page

Search results