CoolCMS API

ImportCodebookLoader
in package

FinalYes

Loads all code lists once per run and builds {@see ImportCodebooks} (id maps) from them.

Manager-tier collaborator: injects only Api managers, no service, repository or EntityManagerInterface.

IMPORTANT: entities are not returned from the methods; they are discarded once the maps are built. The code lists are small (units to hundreds of rows), so keeping them whole in memory is cheaper than querying per item (same pattern as FeedXmlGenerator::FEED_INCLUDES: a constant number of queries regardless of catalog size).

Table of Contents

Properties

$currencyManager  : CurrencyManager
$languageManager  : LanguageManager
$parameterManager  : ParameterManager
$producerManager  : ProducerManager
$productCategoryManager  : ProductCategoryManager
$productStateManager  : ProductStateManager
$productTagManager  : ProductTagManager
$productTypeManager  : ProductTypeManager
$unitManager  : UnitManager
$userGroupManager  : UserGroupManager
$vatManager  : VatManager
$warehouseManager  : WarehouseManager

Methods

__construct()  : mixed
load()  : ImportCodebooks
buildCategoryPath()  : string|null
loadCategories()  : array{array, array}
Categories are matched by `href` (default language) or by the path of names. The path is built from the `parentId` chain, so the whole tree is loaded at once (otherwise every path would cost N queries upward).
loadCurrencies()  : array<string, int>
loadLanguages()  : array<string, int>
loadParameters()  : array{array, array>, array>}
Parameters and their options are the same entity ({@see Parameter}): an option is a child row.
loadProducers()  : array<string, int>
loadTranslatedNames()  : array<string, int>
Code list matched by name in the default language (type, state, tag). All three entities have the same shape (id + `translations` with `name`), so they share one method.
loadUnits()  : array{array, array}
loadVats()  : array{array, array}
Besides the "percents => id" map (matching `<vat>`) it builds the reverse "id => percents": the price-without-VAT calculation from `<amountWithVat>` needs the VAT rate of the set, which is known only as an FK id.
loadWarehouses()  : array{array, int|null}
Without a `warehouse` attribute the single active warehouse applies. With two or more active warehouses there is no default (`null`) and the validator requires an explicit `warehouse`.

Properties

Methods

__construct()

public __construct(LanguageManager $languageManager, ProductCategoryManager $productCategoryManager, ProducerManager $producerManager, ProductTypeManager $productTypeManager, ProductStateManager $productStateManager, ProductTagManager $productTagManager, ParameterManager $parameterManager, UnitManager $unitManager, CurrencyManager $currencyManager, VatManager $vatManager, WarehouseManager $warehouseManager, UserGroupManager $userGroupManager) : mixed
Parameters
$languageManager : LanguageManager
$productCategoryManager : ProductCategoryManager
$producerManager : ProducerManager
$productTypeManager : ProductTypeManager
$productStateManager : ProductStateManager
$productTagManager : ProductTagManager
$parameterManager : ParameterManager
$unitManager : UnitManager
$currencyManager : CurrencyManager
$vatManager : VatManager
$warehouseManager : WarehouseManager
$userGroupManager : UserGroupManager

buildCategoryPath()

private buildCategoryPath(int $id, array<int, ProductCategory> $categories, array<int, string> $names) : string|null
Parameters
$id : int
$categories : array<int, ProductCategory>
$names : array<int, string>
Return values
string|null

loadCategories()

Categories are matched by `href` (default language) or by the path of names. The path is built from the `parentId` chain, so the whole tree is loaded at once (otherwise every path would cost N queries upward).

private loadCategories(int $defaultLanguageId) : array{array, array}
Parameters
$defaultLanguageId : int
Return values
array{array, array}

loadCurrencies()

private loadCurrencies() : array<string, int>
Return values
array<string, int>

loadLanguages()

private loadLanguages() : array<string, int>
Return values
array<string, int>

loadParameters()

Parameters and their options are the same entity ({@see Parameter}): an option is a child row.

private loadParameters(int $defaultLanguageId) : array{array, array>, array>}

One findAll() therefore returns both and they are split by parentId.

Parameters
$defaultLanguageId : int
Return values
array{array, array>, array>}

loadProducers()

private loadProducers() : array<string, int>
Return values
array<string, int>

loadTranslatedNames()

Code list matched by name in the default language (type, state, tag). All three entities have the same shape (id + `translations` with `name`), so they share one method.

private loadTranslatedNames(array<int, BaseEntity> $entities, int $defaultLanguageId) : array<string, int>

NOTE: findAll() of the Api managers is typed only as BaseEntity (the generic parameter of the base manager is the service, not the entity; see the module phpstan baseline), so narrowing to the concrete type here is a real type gate, not a redundant instanceof.

Parameters
$entities : array<int, BaseEntity>
$defaultLanguageId : int
Return values
array<string, int>

loadUnits()

private loadUnits() : array{array, array}
Return values
array{array, array} —

[normalized code => id, id => canonical code]

loadVats()

Besides the "percents => id" map (matching `<vat>`) it builds the reverse "id => percents": the price-without-VAT calculation from `<amountWithVat>` needs the VAT rate of the set, which is known only as an FK id.

private loadVats() : array{array, array}
Return values
array{array, array}

loadWarehouses()

Without a `warehouse` attribute the single active warehouse applies. With two or more active warehouses there is no default (`null`) and the validator requires an explicit `warehouse`.

private loadWarehouses() : array{array, int|null}
Return values
array{array, int|null}
On this page

Search results