Child pages
  • [unit configs] OOP unit config creation [5.3.0-B1]
Skip to end of metadata
Go to start of metadata

Imported From: http://groups.google.com/group/in-portal-dev/browse_thread/thread/e22dcd02a4ee266a#

One of key concepts used in In-Portal are Unit Configs.

They are large arrays, that hold all unit related configuration. Because of large setting count it's pretty hard to keep unit config as readable and clean as first time it was created.

Also some settings always defaults to same values and typing (copy/pasting) them each time also is a waste of time.

I'm proposing to create a class, that would represent a unit config with basic methods for setting entry and "dump" method, that will create resulting unit config file as we see now.

This way from one side we have all flexibility of OOP (object oriented programming) with IDE assisted auto-complete on unit config definition stage and, thanks to "dump" method, we don't have performance degradation because in fact only dumped (complied) unit configs will be used.

At the end compiled unit configs will be located under /system/cache folder.

Related Tasks

INP-1203 - Getting issue details... STATUS

12 Comments

  1. I like this idea :)

    Envoy

  2. I've created a prototype and here is example usage and output.

    *Usage:*
    $unit_config = new kUnitConfig('p');

    // overwrite current title presets with given ones
    $unit_config->setTitlePresets(Array (
    'options_combinations' => Array ('prefixes' => Array ('p'), 'format' =>
    "#p_status# '#p_titlefield#' - !la_title_ManagingOptionCombinations!"),
     'shipping_options' => Array ('prefixes' => Array ('p'), 'format' =>
    "#p_status# '#p_titlefield#' - !la_title_ManagingShippingOptions!"),
    ));

    // add multiple presets in 1 turn
    $unit_config->addTitlePresets(Array (
     'relations_edit' => Array (
    'prefixes' => Array ('p', 'rel'),
     'new_status_labels' => Array ('rel' =>"!la_title_Adding_Relationship!
    '!la_title_New_Relationship!'"),
     'edit_status_labels' => Array ('rel' => '!la_title_Editing_Relationship!'),
    'format' => "#p_status# '#p_titlefield#' - #rel_status#",
     ),
    'reviews_edit' => Array (
     'prefixes' => Array ('p', 'rev'),
    'new_status_labels' => Array ('rev' =>"!la_title_Adding_Review!
    '!la_title_New_Review!'"),
     'edit_status_labels' => Array ('rev' => '!la_title_Editing_Review!'),
    'format' => "#p_status# '#p_titlefield#' - #rev_status#",
     ),
    ));

    // add title preset one by one
    $unit_config->addTitlePreset('product_list', Array (
    'prefixes' => Array ('c_List', 'p_List'),
     'tag_params' => Array ('c' => Array ('per_page' =>-1)),
    'format' => "!la_title_Categories! (#c_recordcount#) - !la_title_Products!
    (#p_recordcount#)",
    ));

    // remove title preset one by one
    $unit_config->removeTitlePreset('shipping_options');

    // remove all title presets
    //$unit_config->removeTitlePresets();

    // add one calculated field by special
    $unit_config->addCalculatedFieldBySpecial('Price', 'COALESCE(pricing.Price,
    0)', '');

    // add multiple calculated fields by special
    $unit_config->addCalculatedFieldsBySpecial(Array (
     'SameImages' => 'img.SameImages',
    'LocalThumb' => 'img.LocalThumb',
     'ThumbPath' => 'img.ThumbPath',
    ), '');

    // replace current calculated fields with given ones
    $unit_config->setCalculatedFieldsBySpecial(Array (
     'CategoryId' => TABLE_PREFIX.'%3$sCategoryItems.CategoryId',
    'ParentPath' => TABLE_PREFIX.'Categories.ParentPath',
    ), 'some-special');

    // remove individual calculated fields
    $unit_config->removeCalculatedFieldBySpecial('LocalThumb', '');

    // update scalar setting (non array)
    $unit_config->setItemType(12);
    $unit_config->setItemType($unit_config->getItemType() + 5);

    $unit_config->dump();

    *Result:*
    Array
    (
        [TitlePresets] => Array
            (
                [options_combinations] => Array
                    (
                        [prefixes] => Array
                            (
                                [0] => p
                            )

                        [format] => #p_status# '#p_titlefield#' -
    !la_title_ManagingOptionCombinations!
                    )

                [relations_edit] => Array
                    (
                        [prefixes] => Array
                            (
                                [0] => p
                                [1] => rel
                            )

                        [new_status_labels] => Array
                            (
                                [rel] => !la_title_Adding_Relationship!
    '!la_title_New_Relationship!'
                            )

                        [edit_status_labels] => Array
                            (
                                [rel] => !la_title_Editing_Relationship!
                            )

                        [format] => #p_status# '#p_titlefield#' - #rel_status#
                    )

                [reviews_edit] => Array
                    (
                        [prefixes] => Array
                            (
                                [0] => p
                                [1] => rev
                            )

                        [new_status_labels] => Array
                            (
                                [rev] => !la_title_Adding_Review!
    '!la_title_New_Review!'
                            )

                        [edit_status_labels] => Array
                            (
                                [rev] => !la_title_Editing_Review!
                            )

                        [format] => #p_status# '#p_titlefield#' - #rev_status#
                    )

                [product_list] => Array
                    (
                        [prefixes] => Array
                            (
                                [0] => c_List
                                [1] => p_List
                            )

                        [tag_params] => Array
                            (
                                [c] => Array
                                    (
                                        [per_page] => -1
                                    )

                            )

                        [format] => !la_title_Categories! (#c_recordcount#) -
    !la_title_Products! (#p_recordcount#)
                    )

            )

        [CalculatedFields] => Array
            (
                [] => Array
                    (
                        [Price] => COALESCE(pricing.Price, 0)
                        [SameImages] => img.SameImages
                        [ThumbPath] => img.ThumbPath
                    )

                [some-special] => Array
                    (
                        [CategoryId] => 53x_%3$sCategoryItems.CategoryId
                        [ParentPath] => 53x_Categories.ParentPath
                    )

            )

        [ItemType] => 17
    )

    As you can see usage of automatically completed methods, like
    getTitlePreset, addCalculatedFieldBySpecial eliminates a need of
    understanding complex array structure of values within unit config. Also
    because automatic method auto-complete developer no longer needs to know
    how exactly each of unit config settings is typed (spelling).

  3. Magic "get*Specials" method will allow developers to get all specials
    defined for a given unit config setting and act on them, e.g. by adding a
    calculated field to every special defined like this:

    // add for all specials
    foreach ($unit_config->getCalculatedFieldSpecials() as $special) {
    $unit_config->addCalculatedFieldBySpecial('MSpecialAdd', '%1$s.TestField',
    $special);

    }

  4. As an evolution of this we can use
    $this->Application->getUnitConfig($prefix) method instead of
    $this->Application->getUnitOption(...)/$this->Application->setUnitOption(.. .)

  5. Here are method names for using 69 unique setting names found in unit
    configs across all In-Portal.

    /**
     * @method Array getFilterMenu(mixed $default = false)
     * @method void setFilterMenu(Array $value)
     *
     * @method Array getConfigMapping(mixed $default = false)
     * @method void setConfigMapping(Array $value)
     *
     *
     * @method string getModuleFolder(mixed $default = false)
     * @method void setModuleFolder(string $value)
     *
     * @method string getBasePath(mixed $default = false)
     * @method void setBasePath(string $value)
     *
     * @method Array getEventHandlerClass(mixed $default = false)
     * @method void setEventHandlerClass(Array $value)
     *
     * @method Array getTagProcessorClass(mixed $default = false)
     * @method void setTagProcessorClass(Array $value)
     *
     * @method Array getItemClass(mixed $default = false)
     * @method void setItemClass(Array $value)
     *
     * @method Array getListClass(mixed $default = false)
     * @method void setListClass(Array $value)
     *
     * @method Array getValidatorClass(mixed $default = false)
     * @method void setValidatorClass(Array $value)
     *
     * @method Array getQueryString(mixed $default = false)
     * @method void setQueryString(Array $value)
     *
     * @method string getPermItemPrefix(mixed $default = false)
     * @method void setPermItemPrefix(string $value)
     *
     * @method string getPermTabText(mixed $default = false)
     * @method void setPermTabText(string $value)
     *
     * @method Array getPermSection(mixed $default = false)
     * @method void setPermSection(Array $value)
     *
     * @method bool getAutoLoad(mixed $default = false)
     * @method void setAutoLoad(bool $value)
     *
     * @method string getIDField(mixed $default = false)
     * @method void setIDField(string $value)
     *
     * @method string getTableName(mixed $default = false)
     * @method void setTableName(string $value)
     *
     * @method string getCustomDataTableName(mixed $default = false)
     * @method void setCustomDataTableName(string $value)
     *
     * @method Array getStatusField(mixed $default = false)
     * @method void setStatusField(Array $value)
     *
     * @method string getTitleField(mixed $default = false)
     * @method void setTitleField(string $value)
     *
     * @method string getOrderField(mixed $default = false)
     * @method void setOrderField(string $value)
     *
     * @method string getOwnerField(mixed $default = false)
     * @method void setOwnerField(string $value)
     *
     * @method int getConfigPriority(mixed $default = false)
     * @method void setConfigPriority(int $value)
     *
     * @method bool getCatalogItem(mixed $default = false)
     * @method void setCatalogItem(bool $value)
     *
     * @method string getCatalogSelectorName(mixed $default = false)
     * @method void setCatalogSelectorName(string $value)
     *
     * @method string getAdminTemplatePath(mixed $default = false)
     * @method void setAdminTemplatePath(string $value)
     *
     * @method string getAdminTemplatePrefix(mixed $default = false)
     * @method void setAdminTemplatePrefix(string $value)
     *
     * @method string getSearchConfigPostfix(mixed $default = false)
     * @method void setSearchConfigPostfix(string $value)
     *
     * @method string getTitlePhrase(mixed $default = false)
     * @method void setTitlePhrase(string $value)
     *
     * @method int getItemType(mixed $default = false)
     * @method void setItemType(int $value)
     *
     * @method Array getStatisticsInfo(mixed $default = false)
     * @method void setStatisticsInfo(Array $value)
     *
     * @method string getViewMenuPhrase(mixed $default = false)
     * @method void setViewMenuPhrase(string $value)
     *
     * @method string getCatalogTabIcon(mixed $default = false)
     * @method void setCatalogTabIcon(string $value)
     *
     * @method bool getCacheModRewrite(mixed $default = false)
     * @method void setCacheModRewrite(bool $value)
     *
     * @method mixed getParentTableKey(mixed $default = false)
     * @method void setParentTableKey(mixed $value)
     *
     * @method mixed getForeignKey(mixed $default = false)
     * @method void setForeignKey(mixed $value)
     *
     * @method bool getAutoDelete(mixed $default = false)
     * @method void setAutoDelete(bool $value)
     *
     * @method bool getAutoClone(mixed $default = false)
     * @method void setAutoClone(bool $value)
     *
     * @method string getParentPrefix(mixed $default = false)
     * @method void setParentPrefix(string $value)
     *
     * @method bool getCheckSimulatniousEdit(mixed $default = false)
     * @method void setCheckSimulatniousEdit(bool $value)
     *
     * @method bool getPortalStyleEnv(mixed $default = false)
     * @method void setPortalStyleEnv(bool $value)
     *
     * @method int getRewritePriority(mixed $default = false)
     * @method void setRewritePriority(int $value)
     *
     * @method Array getRewriteListener(mixed $default = false)
     * @method void setRewriteListener(Array $value)
     *
     * @method bool getForceDontLogChanges(mixed $default = false)
     * @method void setForceDontLogChanges(bool $value)
     *
     * @method Array getUserProfileMapping(mixed $default = false)
     * @method void setUserProfileMapping(Array $value)
     *
     * @method bool getUsePendingEditing(mixed $default = false)
     * @method void setUsePendingEditing(bool $value)
     *
     *
     * @method Array getRegisterClasses(mixed $default = false)
     * @method void setRegisterClasses(Array $value)
     * @method void addRegisterClasses(Array $value)
     * @method void removeRegisterClasses()
     * @method void addRegisterClass(string $name, Array $value)
     * @method void removeRegisterClass(string $name)
     *
     * @method Array getScheduledTasks(mixed $default = false)
     * @method void setScheduledTasks(Array $value)
     * @method void addScheduledTasks(Array $value)
     * @method void removeScheduledTasks()
     * @method void addScheduledTask(string $name, Array $value)
     * @method void removeScheduledTask(string $name)
     *
     * @method Array getTitlePresets(mixed $default = false)
     * @method void setTitlePresets(Array $value)
     * @method void addTitlePresets(Array $value)
     * @method void removeTitlePresets()
     * @method void addTitlePreset(string $name, Array $value)
     * @method void removeTitlePreset(string $name)
     *
     * @method Array getSections(mixed $default = false)
     * @method void setSections(Array $value)
     * @method void addSections(Array $value)
     * @method void removeSections()
     * @method void addSection(string $name, Array $value)
     * @method void removeSection(string $name)
     *
     * @method Array getFields(mixed $default = false)
     * @method void setFields(Array $value)
     * @method void addFields(Array $value)
     * @method void removeFields()
     * @method void addField(string $name, Array $value)
     * @method void removeField(string $name)
     *
     * @method Array getVirtualFields(mixed $default = false)
     * @method void setVirtualFields(Array $value)
     * @method void addVirtualFields(Array $value)
     * @method void removeVirtualFields()
     * @method void addVirtualField(string $name, Array $value)
     * @method void removeVirtualField(string $name)
     *
     * @method Array getGrids(mixed $default = false)
     * @method void setGrids(Array $value)
     * @method void addGrids(Array $value)
     * @method void removeGrids()
     * @method void addGrid(string $name, Array $value)
     * @method void removeGrid(string $name)
     *
     * @method Array getHooks(mixed $default = false)
     * @method void setHooks(Array $value)
     * @method void addHooks(Array $value)
     * @method void removeHooks()
     * @method void addHook(string $name, Array $value)
     * @method void removeHook(string $name)
     *
     * @method Array getAggregateTags(mixed $default = false)
     * @method void setAggregateTags(Array $value)
     * @method void addAggregateTags(Array $value)
     * @method void removeAggregateTags()
     * @method void addAggregateTag(string $name, Array $value)
     * @method void removeAggregateTag(string $name)
     *
     * @method Array getEditTabPresets(mixed $default = false)
     * @method void setEditTabPresets(Array $value)
     * @method void addEditTabPresets(Array $value)
     * @method void removeEditTabPresets()
     * @method void addEditTabPreset(string $name, Array $value)
     * @method void removeEditTabPreset(string $name)
     *
     * @method Array getSubItems(mixed $default = false)
     * @method void setSubItems(Array $value)
     * @method void addSubItems(Array $value)
     * @method void removeSubItems()
     * @method void addSubItem(string $name, Array $value)
     * @method void removeSubItem(string $name)
     *
     * @method Array getCustomFields(mixed $default = false)
     * @method void setCustomFields(Array $value)
     * @method void addCustomFields(Array $value)
     * @method void removeCustomFields()
     * @method void addCustomField(string $name, Array $value)
     * @method void removeCustomField(string $name)
     *
     * @method Array getClones(mixed $default = false)
     * @method void setClones(Array $value)
     * @method void addClones(Array $value)
     * @method void removeClones()
     * @method void addClone(string $name, Array $value)
     * @method void removeClone(string $name)
     *
     * @method Array getProcessPrefixes(mixed $default = false)
     * @method void setProcessPrefixes(Array $value)
     * @method void addProcessPrefixes(Array $value)
     * @method void removeProcessPrefixes()
     * @method void addProcessPrefix(string $name, Array $value)
     * @method void removeProcessPrefix(string $name)
     *
     * @method Array getForms(mixed $default = false)
     * @method void setForms(Array $value)
     * @method void addForms(Array $value)
     * @method void removeForms()
     * @method void addForm(string $name, Array $value)
     * @method void removeForm(string $name)
     *
     * @method Array getReplacementTemplates(mixed $default = false)
     * @method void setReplacementTemplates(Array $value)
     * @method void addReplacementTemplates(Array $value)
     * @method void removeReplacementTemplates()
     * @method void addReplacementTemplate(string $name, Array $value)
     * @method void removeReplacementTemplate(string $name)
     *
     * @method Array getItemPropertyMappings(mixed $default = false)
     * @method void setItemPropertyMappings(Array $value)
     * @method void
    ...

  6. After talking with Dmitry (over Skype) we decided, that redundant methods
    for method for adding/removing single and multiple settings can be combined
    into a single method result twice less methods.

    I've also rearranged parameters the way, that:

       - $special parameter is now at first place for method, which names end
       up with "BySpecial"
       - $name parameter is now last and optional for all methods, where it was
       used
       - $name parameter was used by mistake instead of $special in some methods

    *Here Version 2 of magic method declarations:*

    /**
     * @method Array getFilterMenu(mixed $default = false)
     * @method void setFilterMenu(Array $value)
     *
     * @method Array getConfigMapping(mixed $default = false)
     * @method void setConfigMapping(Array $value)
     *
     *
     * @method string getModuleFolder(mixed $default = false)
     * @method void setModuleFolder(string $value)
     *
     * @method string getBasePath(mixed $default = false)
     * @method void setBasePath(string $value)
     *
     * @method Array getEventHandlerClass(mixed $default = false)
     * @method void setEventHandlerClass(Array $value)
     *
     * @method Array getTagProcessorClass(mixed $default = false)
     * @method void setTagProcessorClass(Array $value)
     *
     * @method Array getItemClass(mixed $default = false)
     * @method void setItemClass(Array $value)
     *
     * @method Array getListClass(mixed $default = false)
     * @method void setListClass(Array $value)
     *
     * @method Array getValidatorClass(mixed $default = false)
     * @method void setValidatorClass(Array $value)
     *
     * @method Array getQueryString(mixed $default = false)
     * @method void setQueryString(Array $value)
     *
     * @method string getPermItemPrefix(mixed $default = false)
     * @method void setPermItemPrefix(string $value)
     *
     * @method string getPermTabText(mixed $default = false)
     * @method void setPermTabText(string $value)
     *
     * @method Array getPermSection(mixed $default = false)
     * @method void setPermSection(Array $value)
     *
     * @method bool getAutoLoad(mixed $default = false)
     * @method void setAutoLoad(bool $value)
     *
     * @method string getIDField(mixed $default = false)
     * @method void setIDField(string $value)
     *
     * @method string getTableName(mixed $default = false)
     * @method void setTableName(string $value)
     *
     * @method string getCustomDataTableName(mixed $default = false)
     * @method void setCustomDataTableName(string $value)
     *
     * @method Array getStatusField(mixed $default = false)
     * @method void setStatusField(Array $value)
     *
     * @method string getTitleField(mixed $default = false)
     * @method void setTitleField(string $value)
     *
     * @method string getOrderField(mixed $default = false)
     * @method void setOrderField(string $value)
     *
     * @method string getOwnerField(mixed $default = false)
     * @method void setOwnerField(string $value)
     *
     * @method int getConfigPriority(mixed $default = false)
     * @method void setConfigPriority(int $value)
     *
     * @method bool getCatalogItem(mixed $default = false)
     * @method void setCatalogItem(bool $value)
     *
     * @method string getCatalogSelectorName(mixed $default = false)
     * @method void setCatalogSelectorName(string $value)
     *
     * @method string getAdminTemplatePath(mixed $default = false)
     * @method void setAdminTemplatePath(string $value)
     *
     * @method string getAdminTemplatePrefix(mixed $default = false)
     * @method void setAdminTemplatePrefix(string $value)
     *
     * @method string getSearchConfigPostfix(mixed $default = false)
     * @method void setSearchConfigPostfix(string $value)
     *
     * @method string getTitlePhrase(mixed $default = false)
     * @method void setTitlePhrase(string $value)
     *
     * @method int getItemType(mixed $default = false)
     * @method void setItemType(int $value)
     *
     * @method Array getStatisticsInfo(mixed $default = false)
     * @method void setStatisticsInfo(Array $value)
     *
     * @method string getViewMenuPhrase(mixed $default = false)
     * @method void setViewMenuPhrase(string $value)
     *
     * @method string getCatalogTabIcon(mixed $default = false)
     * @method void setCatalogTabIcon(string $value)
     *
     * @method bool getCacheModRewrite(mixed $default = false)
     * @method void setCacheModRewrite(bool $value)
     *
     * @method mixed getParentTableKey(mixed $default = false)
     * @method void setParentTableKey(mixed $value)
     *
     * @method mixed getForeignKey(mixed $default = false)
     * @method void setForeignKey(mixed $value)
     *
     * @method bool getAutoDelete(mixed $default = false)
     * @method void setAutoDelete(bool $value)
     *
     * @method bool getAutoClone(mixed $default = false)
     * @method void setAutoClone(bool $value)
     *
     * @method string getParentPrefix(mixed $default = false)
     * @method void setParentPrefix(string $value)
     *
     * @method bool getCheckSimulatniousEdit(mixed $default = false)
     * @method void setCheckSimulatniousEdit(bool $value)
     *
     * @method bool getPortalStyleEnv(mixed $default = false)
     * @method void setPortalStyleEnv(bool $value)
     *
     * @method int getRewritePriority(mixed $default = false)
     * @method void setRewritePriority(int $value)
     *
     * @method Array getRewriteListener(mixed $default = false)
     * @method void setRewriteListener(Array $value)
     *
     * @method bool getForceDontLogChanges(mixed $default = false)
     * @method void setForceDontLogChanges(bool $value)
     *
     * @method Array getUserProfileMapping(mixed $default = false)
     * @method void setUserProfileMapping(Array $value)
     *
     * @method bool getUsePendingEditing(mixed $default = false)
     * @method void setUsePendingEditing(bool $value)
     *
     *
     * @method Array getRegisterClasses(mixed $default = false)
     * @method void setRegisterClasses(Array $value)
     * @method void addRegisterClasses(Array $value, string $name = null)
     * @method void removeRegisterClasses(string $name = null)
     *
     * @method Array getScheduledTasks(mixed $default = false)
     * @method void setScheduledTasks(Array $value)
     * @method void addScheduledTasks(Array $value, string $name = null)
     * @method void removeScheduledTasks(string $name = null)
     *
     * @method Array getTitlePresets(mixed $default = false)
     * @method void setTitlePresets(Array $value)
     * @method void addTitlePresets(Array $value, string $name = null)
     * @method void removeTitlePresets(string $name = null)
     *
     * @method Array getSections(mixed $default = false)
     * @method void setSections(Array $value)
     * @method void addSections(Array $value, string $name = null)
     * @method void removeSections(string $name = null)
     *
     * @method Array getFields(mixed $default = false)
     * @method void setFields(Array $value)
     * @method void addFields(Array $value, string $name = null)
     * @method void removeFields(string $name = null)
     *
     * @method Array getVirtualFields(mixed $default = false)
     * @method void setVirtualFields(Array $value)
     * @method void addVirtualFields(Array $value, string $name = null)
     * @method void removeVirtualFields(string $name = null)
     *
     * @method Array getGrids(mixed $default = false)
     * @method void setGrids(Array $value)
     * @method void addGrids(Array $value, string $name = null)
     * @method void removeGrids(string $name = null)
     *
     * @method Array getHooks(mixed $default = false)
     * @method void setHooks(Array $value)
     * @method void addHooks(Array $value, string $name = null)
     * @method void removeHooks(string $name = null)
     *
     * @method Array getAggregateTags(mixed $default = false)
     * @method void setAggregateTags(Array $value)
     * @method void addAggregateTags(Array $value, string $name = null)
     * @method void removeAggregateTags(string $name = null)
     *
     * @method Array getEditTabPresets(mixed $default = false)
     * @method void setEditTabPresets(Array $value)
     * @method void addEditTabPresets(Array $value, string $name = null)
     * @method void removeEditTabPresets(string $name = null)
     *
     * @method Array getSubItems(mixed $default = false)
     * @method void setSubItems(Array $value)
     * @method void addSubItems(string $value, string $name = null)
     * @method void removeSubItems(string $name = null)
     *
     * @method Array getCustomFields(mixed $default = false)
     * @method void setCustomFields(Array $value)
     * @method void addCustomFields(Array $value, string $name = null)
     * @method void removeCustomFields(string $name = null)
     *
     * @method Array getClones(mixed $default = false)
     * @method void setClones(Array $value)
     * @method void addClones(Array $value, string $name = null)
     * @method void removeClones(string $name = null)
     *
     * @method Array getProcessPrefixes(mixed $default = false)
     * @method void setProcessPrefixes(Array $value)
     * @method void addProcessPrefixes(string $value, string $name = null)
     * @method void removeProcessPrefixes(string $name = null)
     *
     * @method Array getForms(mixed $default = false)
     * @method void setForms(Array $value)
     * @method void addForms(Array $value, string $name = null)
     * @method void removeForms(string $name = null)
     *
     * @method Array getReplacementTemplates(mixed $default = false)
     * @method void setReplacementTemplates(Array $value)
     * @method void addReplacementTemplates(string $value, string $name = null)
     * @method void removeReplacementTemplates(string $name = null)
     *
     * @method Array getItemPropertyMappings(mixed $default = false)
     * @method void setItemPropertyMappings(Array $value)
     * @method void addItemPropertyMappings(string $value, string $name = null)
     * @method void removeItemPropertyMappings(string $name = null)
     *
     * @method Array getSectionAdjustments(mixed $default = false)
     * @method void setSectionAdjustments(Array $value)
     * @method void addSectionAdjustments(mixed $value, string $name = null)
     * @method void removeSectionAdjustments(string $name = null)
     *
     *
     * @method Array getCalculatedFieldSpecials(mixed $default = Array ())
     * @method Array getCalculatedFieldsBySpecial(string $special, mixed
    $default = Array ())
     * @method void setCalculatedFieldsBySpecial(string
    ...

  7. *Here is how unit config used to look like:*

    $config = Array (
    'Prefix' => 'm',
     'EventHandlerClass' => Array ('class' => 'kEventHandler', 'file' => '',
    'build_event' => 'OnBuild'),
     'TagProcessorClass' => Array ('class' => 'kMainTagProcessor', 'file' =>
    '../../kernel/processors/main_processor.php', 'build_event' => 'OnBuild'),

    'QueryString' => Array (
    1 => 'cat_id',
     2 => 'cat_page',
    3 => 'lang',
     4 => 'theme',
    5 => 'opener',
     6 => 'wid',
    ),

    'TitleField' => 'CachedNavbar',
    'TitlePhrase' => 'la_Text_Category',
     'CatalogTabIcon' => 'icon16_section.png',
    'ItemType' => 1,
     'TableName' => TABLE_PREFIX . 'Categories',

     'CatalogItem' => true,

    'PortalStyleEnv' => true,

    'RewritePriority' => 100,
    'RewriteListener' => 'c_EventHandler:CategoryRewriteListener',

    'PermTabText' => 'In-Portal',
    'PermSection' => Array ('search' => 'in-portal:configuration_search',
    'custom' => 'in-portal:configuration_custom'),
    );

    *Here is how unit config will look like:*
    $config = new kUnitConfig('m');
    $config->setEventHandlerClass(Array ('class' => 'kEventHandler', 'file' =>
    '', 'build_event' => 'OnBuild'));
    $config->setTagProcessorClass(Array ('class' => 'kMainTagProcessor', 'file'
    => '../../kernel/processors/main_processor.php', 'build_event' =>
    'OnBuild'));
    $config->setQueryString(Array (
    1 => 'cat_id',
    2 => 'cat_page',
     3 => 'lang',
    4 => 'theme',
     5 => 'opener',
    6 => 'wid',
    ));
    $config->setTitleField('CachedNavbar');
    $config->setTitlePhrase('la_Text_Category');
    $config->setCatalogTabIcon('icon16_section.png');
    $config->setItemType(1);
    $config->setTableName(TABLE_PREFIX . 'Categories');
    $config->setCatalogItem(true);
    $config->setPortalStyleEnv(true);
    $config->setRewritePriority(100);
    $config->setRewriteListener('c_EventHandler:CategoryRewriteListener');
    $config->setPermTabText('In-Portal');
    $config->setPermSection(Array (
    'search' => 'in-portal:configuration_search',
     'custom' => 'in-portal:configuration_custom'
    ));

  8. Hi Alex,

    Thanks for your research and examples - everything here looks promising.

    *2 Questions at this points:*

    1. What about speed and performance of this change. Consider we adding more
    PHP processing to register/build Config dump for the unit. How much we are
    loosing?

    2. Let's say we agree to go with this format in 5.3.0 - what's going to be
    the plan for converting or not converting current Units Configs to this
    format? What's your opinion and why.

    PS. As we talked we might want to create a patch for this to actually try
    it on the LIVE projects in 5.2.x before committing to this kind of change
    in 5.3.0.

    DA

  9. I see no performance loss, because in production we will include dumped
    unit config in place of original unit config at all times.
    Besides dumping part isn't completely implemented. Also I plan to store
    dumped unit configs at /system/cache/unit_configs (as proposed in
    https://groups.google.com/d/topic/in-portal-dev/SuG1MUwOivg/discussion).

    I'm for complete transformation of all unit configs. While doing a patch
    for https://groups.google.com/d/topic/in-portal-dev/6VnUdTJLhV0/discussionI've
    normalized all 130 unit configs using a few regular expressions, so it
    will be much easier to convert all unit configs into OOP form.

  10. Okay, I think we are in the right path then.

    It's time to create a new task for this. Would you please do it and fully
    describe what we are doing (including Patch for 5.2.0/5.2.1 so we can test
    the idea)

    DA

  11. I've been trying to use new OOP way of changing existing unit configs and
    between these 2 ways of adding a single field I choose last one:

    *Code Example #1:*
    $config->addFields(Array (
    'formatter' => 'kOptionsFormatter',
     'options' => Array (1 => 'la_OnlineStore', 2 => 'la_eBayMarketplace'),
    'use_phrases' => 1,
     'default' => 1
    ), 'Marketplace');

    *Code Example #2:*
    $config->addFields(Array (
    'Marketplace' => Array (
     'formatter' => 'kOptionsFormatter',
    'options' => Array (1 => 'la_OnlineStore', 2 => 'la_eBayMarketplace'),
    'use_phrases' => 1,
     'default' => 1
    )
    ));

    I know, that example #1 is specially designed for adding one field, but
    example #2 still looks nicer for me.

  12. I agree - 2nd way is more practical and straight forward so I guess we
    should go this route.

    DA