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

Use "Router" concept instead of "Rewrite Listener" concept

    XMLWordPrintable

    Details

    • Change Log Group:
      Changed
    • Change Log Message:
      Dramatically simplify process of creating custom SEO urls by using the "Router" concept.
    • Story Points:
      2
    • External issue ID:
      1315
    • Patch Instructions:

      Patches must be submitted through Phabricator.

    • BC Break Details:
      Hide

      Delete unit config settings:

      • "RewritePriority"
      • "RewriteListener"

      Reborn classes:

      • "CategoryItemRewrite" into "AbstractCategoryItemRouter" and "AbstractReviewRouter"

      Reborn properties:

      • "kApplication::$RewriteListeners" into "kApplication::$routers"
      • "kRewriteUrlProcessor::$rewriteListeners" into "kRewriteUrlProcessor::$routers"

      Reborn methods:

      • "CategoriesEventHandler::CategoryRewriteListener" into "MainRouter" class
      • "CategoriesEventHandler::_buildMainUrl" into "MainRouter::build"
      • "CategoriesEventHandler::_parseCategory" into "MainRouter::parseCategory"
      • "CategoriesEventHandler::_parseFriendlyUrl" into "MainRouter::parseFriendlyUrl"
      • "kRewriteUrlProcessor::_initRewriteListeners" into "kRewriteUrlProcessor::initRouters"
      • "kRewriteUrlProcessor::_processRewriteListeners" into "kRewriteUrlProcessor::processRouters"
      • "WidgetEventHandler::WidgetRewriteBuilder" into "WidgetRouter::build"
      • "WidgetEventHandler::WidgetRewriteListener" into "WidgetRouter" class
      • "WidgetEventHandler::WidgetRewriteParser" into "WidgetRouter::parse"
      Show
      Delete unit config settings: "RewritePriority" "RewriteListener" Reborn classes: "CategoryItemRewrite" into "AbstractCategoryItemRouter" and "AbstractReviewRouter" Reborn properties: "kApplication::$RewriteListeners" into "kApplication::$routers" "kRewriteUrlProcessor::$rewriteListeners" into "kRewriteUrlProcessor::$routers" Reborn methods: "CategoriesEventHandler::CategoryRewriteListener" into "MainRouter" class "CategoriesEventHandler::_buildMainUrl" into "MainRouter::build" "CategoriesEventHandler::_parseCategory" into "MainRouter::parseCategory" "CategoriesEventHandler::_parseFriendlyUrl" into "MainRouter::parseFriendlyUrl" "kRewriteUrlProcessor::_initRewriteListeners" into "kRewriteUrlProcessor::initRouters" "kRewriteUrlProcessor::_processRewriteListeners" into "kRewriteUrlProcessor::processRouters" "WidgetEventHandler::WidgetRewriteBuilder" into "WidgetRouter::build" "WidgetEventHandler::WidgetRewriteListener" into "WidgetRouter" class "WidgetEventHandler::WidgetRewriteParser" into "WidgetRouter::parse"

      Description

      Routing is a way for application decide what content to show based on provided request data:

      • url
      • headers
      • form data

      It is implemented in one or another form in all major frameworks, like: Symphony, Zend Framework.

      Right now in 5.1.x and 5.2.0-B3 we have rewrite listeners concept. It's a method inside event handler class, that knows how to build/parse urls.

      There are several problems that needs to be solved in current implementation:

      • small build/parse methods are located in usually big class (event handler) and just to build/parse url you create that class instance and eat lot of memory
      • no way to create custom url caching key, since rewrite listeners don't put custom data into caching key
      • rewrite listeners always create kModRewriteHelper class instance to use common function for url processing
      • if you need to pass some custom parameter to rewrite builder to build a valid link (e.g. filename), then you need to create 2 copies of code
        • in event handler: to ensure correct link after executing event on item detail page
        • in tag processor: to ensure correct link when printing a list of items

      I'm proposing to create base class kRouter with these methods:
      1. build(...) - builds an url
      2. parse(...) - parses an url
      3. getLinkParams($object) - returns extra url parameters, extracted from object, that are required to successfully build a link
      4. processParams(&$params) - get parameters, associated with given unit and remove it from global scope (like 5. kModRewriteHelper::getProcessedParams method now)
      5. patchCachingKey($caching_key) - get caching key as input and return patched version (allows to put header values into caching key, used to cache parsed url)

      Then in unit config you can register router using this code:

      'RouterClass' => Array ('class' => 'WidgetRouter', 'file' => 'widget_router.php', 'build_event' => 'OnBuild'),

      And class, who right now processes all that stuff called kRewriteProcessor would be renamed to kRoutingManager (maybe not a first) to make it all sound good.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alex Alex
                Reporter:
                alex Alex
                Developer:
                Alex
                Reviewer:
                Gleb Sinkovskiy [Intechnic]
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: