Uploaded image for project: 'In-Portal CMS'
  1. In-Portal CMS
  2. INP-1203

OOP unit config creation

    XMLWordPrintable

    Details

    • Change Log Group:
      Changed
    • Change Log Message:
      Allow defining unit config contents in OOP format (using "kUnitConfig" class) in addition to existing array format. Replaced "kApplication::getUnitOption" and "kApplication::setUnitOption" methods with "kApplication::getUnitConfig" method.
    • Story Points:
      2
    • Copy Issue Key:
    • Patch Instructions:

      Patches must be submitted through Phabricator.

    • BC Break Details:
      Hide

      Method scope reduced:

      • "FormsEventHandler::getForms" (was "public", now "protected")

      Renamed methods:

      • "FormSubmissionsEventHandler::getFieldByRole" into "FormSubmissionsEventHandler::getFieldNameByRole"

      Removed methods:

      • "kUnitConfigReader::iterateConfigs"

      Reborn methods:

      • "kUnitConfigReader::getUnitOption" as "kUnitConfigReader::getUnitConfig"
      • "kUnitConfigReader::getUnitOptions" as "kUnitConfigReader::getUnitConfig"
      • "kUnitConfigReader::setUnitOption" as "kUnitConfigReader::getUnitConfig"
      • "kApplication::getUnitOption" as "kApplication::getUnitConfig"
      • "kApplication::getUnitOptions" as "kApplication::getUnitConfig"
      • "kApplication::setUnitOption" as "kApplication::getUnitConfig"
      • "kDBItem::getStatusField" as "kUnitConfig::getStatusField"

      Method signature changed:

      • "FileHelper::_createCustomFields" (the "&$virtual_fields" parameter replaced with "kUnitConfig $config" parameter)
      • "RelationshipEventHandler::getTitleField" (the "$prefix" parameter replaced with "kUnitConfig $config" parameter)
      • "ReportsEventHandler::GetMetricOptions" (the "&$a_config_options" parameter replaced with "kUnitConfig $config" parameter)

      Solution

      1. add "kUnitConfigReader::getUnitOption" method, that will:
        • have "@see kUnitConfigReader::getUnitConfig" tag
        • return "$this->getUnitConfig($prefix)->getSetting($name, $default)" call result
      2. add "kUnitConfigReader::setUnitOption" method, that will:
        • have "@see kUnitConfigReader::getUnitConfig" tag
        • call "$this->getUnitConfig($prefix)->setSetting($name, $value)" code
      3. add "kUnitConfigReader::getUnitOptions" method, that will:
        • have "@see kUnitConfigReader::getUnitConfig" tag
        • return "$this->getUnitConfig($prefix)->getRaw()" call result
      4. add "kApplication::getUnitOption" method, that will:
        • have "@see kApplication::getUnitConfig" tag
        • return "$this->UnitConfigReader->getUnitOption($prefix, $name, $default)" call result
      5. add "kApplication::setUnitOption" method, that will:
        • have "@see kApplication::getUnitConfig" tag
        • return "$this->UnitConfigReader->setUnitOption($prefix, $name, $value)" call result
      6. add "kApplication::getUnitOptions" method, that will:
        • have "@see kApplication::getUnitConfig" tag
        • return "$this->UnitConfigReader->getUnitOptions($prefix)" call result
      7. add "FormSubmissionsEventHandler::getFieldByRole" method, that will:
        • have "@deprecated" tag
        • have "@see FormSubmissionsEventHandler::getFieldNameByRole" tag
        • trigger silenced user deprecation notice
        • return "$this->getFieldNameByRole($form_id, $role)" call result
      8. add "kDBItem::getStatusField" method, that will:
        • have "@deprecated" tag
        • have "@see kUnitConfig::getStatusField" tag
        • trigger silenced user deprecation notice
        • return "$this->getUnitConfig()->getStatusField(true)" call result
      9. add "FormSubmissionsEventHandler::getFieldByRole" method, that will:
        • have "@deprecated" tag
        • trigger silenced user deprecation notice
        • return result of calling "FormSubmissionsEventHandler::getFieldNameByRole" method
      Show
      Method scope reduced: "FormsEventHandler::getForms" (was "public", now "protected") Renamed methods: "FormSubmissionsEventHandler::getFieldByRole" into "FormSubmissionsEventHandler::getFieldNameByRole" Removed methods: "kUnitConfigReader::iterateConfigs" Reborn methods: "kUnitConfigReader::getUnitOption" as "kUnitConfigReader::getUnitConfig" "kUnitConfigReader::getUnitOptions" as "kUnitConfigReader::getUnitConfig" "kUnitConfigReader::setUnitOption" as "kUnitConfigReader::getUnitConfig" "kApplication::getUnitOption" as "kApplication::getUnitConfig" "kApplication::getUnitOptions" as "kApplication::getUnitConfig" "kApplication::setUnitOption" as "kApplication::getUnitConfig" "kDBItem::getStatusField" as "kUnitConfig::getStatusField" Method signature changed: "FileHelper::_createCustomFields" (the "&$virtual_fields" parameter replaced with "kUnitConfig $config" parameter) "RelationshipEventHandler::getTitleField" (the "$prefix" parameter replaced with "kUnitConfig $config" parameter) "ReportsEventHandler::GetMetricOptions" (the "&$a_config_options" parameter replaced with "kUnitConfig $config" parameter) Solution add "kUnitConfigReader::getUnitOption" method, that will: have "@see kUnitConfigReader::getUnitConfig" tag return "$this->getUnitConfig($prefix)->getSetting($name, $default)" call result add "kUnitConfigReader::setUnitOption" method, that will: have "@see kUnitConfigReader::getUnitConfig" tag call "$this->getUnitConfig($prefix)->setSetting($name, $value)" code add "kUnitConfigReader::getUnitOptions" method, that will: have "@see kUnitConfigReader::getUnitConfig" tag return "$this->getUnitConfig($prefix)->getRaw()" call result add "kApplication::getUnitOption" method, that will: have "@see kApplication::getUnitConfig" tag return "$this->UnitConfigReader->getUnitOption($prefix, $name, $default)" call result add "kApplication::setUnitOption" method, that will: have "@see kApplication::getUnitConfig" tag return "$this->UnitConfigReader->setUnitOption($prefix, $name, $value)" call result add "kApplication::getUnitOptions" method, that will: have "@see kApplication::getUnitConfig" tag return "$this->UnitConfigReader->getUnitOptions($prefix)" call result add "FormSubmissionsEventHandler::getFieldByRole" method, that will: have "@deprecated" tag have "@see FormSubmissionsEventHandler::getFieldNameByRole" tag trigger silenced user deprecation notice return "$this->getFieldNameByRole($form_id, $role)" call result add "kDBItem::getStatusField" method, that will: have "@deprecated" tag have "@see kUnitConfig::getStatusField" tag trigger silenced user deprecation notice return "$this->getUnitConfig()->getStatusField(true)" call result add "FormSubmissionsEventHandler::getFieldByRole" method, that will: have "@deprecated" tag trigger silenced user deprecation notice return result of calling "FormSubmissionsEventHandler::getFieldNameByRole" method

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alex Alex
                Reporter:
                alex Alex
                Developer:
                Alex
                Reviewer:
                Dmitry Andrejev [Intechnic]
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: