From 1a180b273147acfe0135e08a05e8872a6b4db3b6 Mon Sep 17 00:00:00 2001 From: LogMANOriginal Date: Sat, 24 Dec 2016 11:37:03 +0100 Subject: [PATCH] [BridgeAbstract] Add 'Queried Context' section --- BridgeAbstract.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/BridgeAbstract.md b/BridgeAbstract.md index 1bf8991..037bcde 100644 --- a/BridgeAbstract.md +++ b/BridgeAbstract.md @@ -193,6 +193,39 @@ This function returns the URI to the destination site of the bridge. It will be } ``` +## Queried context + +The queried context is defined via `PARAMETERS` and can be accessed via `$this->queriedContext`. +It provides a way to identify which context the bridge is called with. + +Example: + +```PHP +... + const PARAMETERS = array( + 'By user name' => array( + 'u' => array('name' => 'Username') + ), + 'By user ID' => array( + 'id' => array('name' => 'User ID') + ) + ); + +... +``` + +In this example `$this->queriedContext` will either return **By user name** or **By user ID**. The queried context might return no value, so the best way to handle it is by using a case-structure: + +```PHP +switch($this->queriedContext){ + case 'By user name': + break; + case 'By user ID': + break; + default: // Return default value +} +``` + # Helper functions Helper functions are independent function that help you to manage specific events in your bridges.