FeedEdit
extends BaseComponent
in package
uses
AdminComponentFormTrait, FormHelpersTrait, FormTrait, ParameterTreeTrait, GenerateTrait
Renders the feed add/edit form as the page content (not in a modal).
The form has two sections: base data and the parameter tree. Per-product-set overrides
(FeedParameterRel) live in the ProductSetEdit
feeds tab and category mappings
(FeedProductCategoryRel) in the category form.
Saving touches only the base fields and the parameter tree:
- base fields use the generic object-graph save;
categoryRelsis in the ApiFeedManager::$defaultSkipFields, otherwise the empty form collection would delete the mappings of all categories through orphan removal; parametersgo through a dedicated bridge action (FeedManager::saveParameterTree()) outside the generic save, in the same form submit (FormTrait::saveFeedForm()).
Table of Contents
Constants
- EDIT_INCLUDES : array<int, string> = ['language', 'currency']
- Category mappings are not included: the form does not edit them and the Api `defaultSkipFields` excludes them from the save path.
- GENERATE_LOCK_NAME : string = 'cron.eshop.feed.generate'
Properties
- $container : Container
- $routerDispatcher : RouterDispatcher
- $translator : ITranslator
- $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
- $adminLanguageManager : LanguageManager
- $cronLockManager : CronLockManager
- $currencyManager : CurrencyManager
- $editedFeed : Feed|null
- Edited feed (null when adding), set by {@see resolveEditedFeed()}.
- $feedCurrencies : array<int, Currency>
- $feedId : int|null
- Per-instance context from {@see FeedEditFactory::create()}; null when adding.
- $feedLanguages : array<int, Language>
- $feedManager : FeedManager
- $feedParameterActionManager : FeedParameterActionManager
- $feedParameterActionOptions : array<int, NotTranslate>
- $feedParameterTreeCache : array<int, array<string, mixed>>|null
- $formActionsFactory : FormActionsFactory
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
- handleGenerateNow() : void
- hasServiceByType() : bool
- Returns whether the container has a service of the given type.
- initializeAllContexts() : void
- injectDeviceDetector() : void
- onCreate() : void
- 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.
- createAdminComponentForm() : Form
- createComponentAdminFormActions() : FormActions
- createComponentEditForm() : Form
- frontPresenter() : BasePresenter|null
- Returns the front presenter the component is attached to (null outside the front end or when detached).
- getTranslator() : ITranslator
- intOrNull() : int|null
- setTemplateFile() : void
- setTranslator() : self
- str() : string
- strOrNull() : string|null
- addFeedBaseFields() : void
- addFeedParameterNodeControls() : void
- addFeedParameterTreeMultiplier() : void
- buildFeedEntity() : Feed
- buildParameterTreeDefaultRows() : array<int, array<string, mixed>>
- Converts the stored tree into nested default rows (two levels) for the multiplier, passed through `$form->setDefaults()` in {@see FormTrait::setFeedFormDefaults()}.
- 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).
- currentLangIdOrDefault() : int
- extractSubmittedTree() : array<int, array<string, mixed>>
- Converts the nested `$values->parameters` (multiplier) into the shape expected by {@see \App\UI\Admin\Eshop\Models\Managers\FeedManager::saveParameterTree()}.
- httpRequest() : IRequest
- Returns the HTTP request through the presenter; a control has no `getHttpRequest()`.
- isSignalRequest() : bool
- Tells whether a signal is being handled; a control has no `getSignal()`, only the presenter has.
- loadFeedParameterTree() : array<int, array<string, mixed>>
- Returns the feed parameter tree, memoized per request because `render()` and `createComponentEditForm()` can both ask for the prefill.
- loadFeedSelectData() : void
- Loads the select data (languages, currencies, actions) once per request.
- resolveEditedFeed() : Feed|null
- saveFeedForm() : bool
- setFeedFormDefaults() : void
- Prefills the base fields and the parameter tree multiplier (including the nested level) in a single `setDefaults()`.
Constants
EDIT_INCLUDES
Category mappings are not included: the form does not edit them and the Api `defaultSkipFields` excludes them from the save path.
public
array<int, string>
EDIT_INCLUDES
= ['language', 'currency']
GENERATE_LOCK_NAME
private
string
GENERATE_LOCK_NAME
= 'cron.eshop.feed.generate'
Properties
$container
public
Container
$container
Attributes
- #[Inject]
$routerDispatcher
public
RouterDispatcher
$routerDispatcher
$translator
public
ITranslator
$translator
Tags
$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
$translatorDomain
= 'admin.eshop.presenters.feed'
$adminLanguageManager read-only
private
LanguageManager
$adminLanguageManager
$cronLockManager read-only
private
CronLockManager
$cronLockManager
$currencyManager read-only
private
CurrencyManager
$currencyManager
$editedFeed
Edited feed (null when adding), set by {@see resolveEditedFeed()}.
private
Feed|null
$editedFeed
$feedCurrencies
private
array<int, Currency>
$feedCurrencies
= []
$feedId read-only
Per-instance context from {@see FeedEditFactory::create()}; null when adding.
private
int|null
$feedId
$feedLanguages
private
array<int, Language>
$feedLanguages
= []
$feedManager read-only
private
FeedManager
$feedManager
$feedParameterActionManager read-only
private
FeedParameterActionManager
$feedParameterActionManager
$feedParameterActionOptions
private
array<int, NotTranslate>
$feedParameterActionOptions
= []
id => translated action name (falls back to the raw action string).
$feedParameterTreeCache
private
array<int, array<string, mixed>>|null
$feedParameterTreeCache
= null
tree memoized per request (see loadFeedParameterTree())
$formActionsFactory read-only
private
FormActionsFactory
$formActionsFactory
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(FeedManager $feedManager, FeedParameterActionManager $feedParameterActionManager, LanguageManager $adminLanguageManager, CurrencyManager $currencyManager, FormActionsFactory $formActionsFactory, CronLockManager $cronLockManager, int|null $feedId) : mixed
Parameters
- $feedManager : FeedManager
- $feedParameterActionManager : FeedParameterActionManager
- $adminLanguageManager : LanguageManager
- $currencyManager : CurrencyManager
- $formActionsFactory : FormActionsFactory
- $cronLockManager : CronLockManager
- $feedId : int|null
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|nullhandleGenerateNow()
public
handleGenerateNow() : void
Attributes
- #[Requires]
- $methods: 'POST'
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
boolinitializeAllContexts()
public
initializeAllContexts() : void
injectDeviceDetector()
public
injectDeviceDetector(DeviceDetector $detector) : void
Parameters
- $detector : DeviceDetector
onCreate()
public
onCreate() : void
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
TcreateAdminComponentForm()
protected
createAdminComponentForm(callable(ArrayHash<string|int, mixed>, Form=): bool $processData[, callable(string): void|null $afterSave = null ]) : Form
Parameters
- $processData : callable(ArrayHash<string|int, mixed>, Form=): bool
-
Saves the data; returns success (handles its own flash).
- $afterSave : callable(string): void|null = null
-
When set, replaces the default backKey/redirect logic after a successful
$processData; the parameter is the clicked submit name (updateorsave). The hiddenbackKeystays in the form but is unused. For a component hosted in a modal shell, where a page redirect makes no sense (the modal is an AJAX shell over the presenter page).
Return values
FormcreateComponentAdminFormActions()
protected
createComponentAdminFormActions() : FormActions
Return values
FormActionscreateComponentEditForm()
protected
createComponentEditForm() : Form
Return values
FormfrontPresenter()
Returns the front presenter the component is attached to (null outside the front end or when detached).
protected
frontPresenter() : BasePresenter|null
Return values
BasePresenter|nullgetTranslator()
protected
getTranslator() : ITranslator
Return values
ITranslatorintOrNull()
protected
intOrNull(mixed $value) : int|null
Parameters
- $value : mixed
Return values
int|nullsetTemplateFile()
protected
setTemplateFile(string $dir, string $filename) : void
Parameters
- $dir : string
- $filename : string
setTranslator()
protected
setTranslator(ITranslator $translator) : self
Parameters
- $translator : ITranslator
Return values
selfstr()
protected
str(mixed $value) : string
Parameters
- $value : mixed
Return values
stringstrOrNull()
protected
strOrNull(mixed $value) : string|null
Parameters
- $value : mixed
Return values
string|nulladdFeedBaseFields()
private
addFeedBaseFields(Form $form) : void
Parameters
- $form : Form
addFeedParameterNodeControls()
private
addFeedParameterNodeControls(Container $node) : void
Parameters
- $node : Container
addFeedParameterTreeMultiplier()
private
addFeedParameterTreeMultiplier(Form $form) : void
Parameters
- $form : Form
buildFeedEntity()
private
buildFeedEntity(ArrayHash<string|int, mixed> $values) : Feed
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
FeedbuildParameterTreeDefaultRows()
Converts the stored tree into nested default rows (two levels) for the multiplier, passed through `$form->setDefaults()` in {@see FormTrait::setFeedFormDefaults()}.
private
buildParameterTreeDefaultRows() : array<int, array<string, mixed>>
IMPORTANT: never call Multiplier::addCopy() plus Container::setValues() on single
copies. addCopy(?int $number) is typed ?int (a string index throws a TypeError),
and the multiplier controls the number of copies itself in createCopies() from the
values set. The nested level (children) is passed as a plain nested array.
Return values
array<int, array<string, mixed>>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|nullcreateStandardComponent()
Creates a standard component (not a multiplier).
private
createStandardComponent(string $name) : IComponent|null
Parameters
- $name : string
Return values
IComponent|nullcurrentLangIdOrDefault()
private
currentLangIdOrDefault() : int
Return values
intextractSubmittedTree()
Converts the nested `$values->parameters` (multiplier) into the shape expected by {@see \App\UI\Admin\Eshop\Models\Managers\FeedManager::saveParameterTree()}.
private
extractSubmittedTree(mixed $rows) : array<int, array<string, mixed>>
Parameters
- $rows : mixed
Return values
array<int, array<string, mixed>>httpRequest()
Returns the HTTP request through the presenter; a control has no `getHttpRequest()`.
private
httpRequest() : IRequest
Return values
IRequestisSignalRequest()
Tells whether a signal is being handled; a control has no `getSignal()`, only the presenter has.
private
isSignalRequest() : bool
Return values
boolloadFeedParameterTree()
Returns the feed parameter tree, memoized per request because `render()` and `createComponentEditForm()` can both ask for the prefill.
private
loadFeedParameterTree() : array<int, array<string, mixed>>
Return values
array<int, array<string, mixed>>loadFeedSelectData()
Loads the select data (languages, currencies, actions) once per request.
private
loadFeedSelectData() : void
resolveEditedFeed()
private
resolveEditedFeed() : Feed|null
Return values
Feed|nullsaveFeedForm()
private
saveFeedForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
boolsetFeedFormDefaults()
Prefills the base fields and the parameter tree multiplier (including the nested level) in a single `setDefaults()`.
private
setFeedFormDefaults(Form $form) : void
IMPORTANT: the multiplier is filled only through nested arrays in the defaults, never
by addCopy()/setValues() on single copies; see
ParameterTreeTrait::buildParameterTreeDefaultRows().
Parameters
- $form : Form