Properties

$skip_page_style

$skip_page_style : boolean

Set this variable to true during the handle phase of your component to not show the site's style around the component output. This is mainly targeted at XML output like RSS feeds and similar things. The output handler of the site, excluding the style-init/-finish tags will be executed immediately after the handle phase, and midcom->finish() is called automatically afterwards, thus ending the request.

Changing this flag after the handle phase or for dynamically loaded components won't change anything.

Type

boolean

$serviceloader

$serviceloader : \midcom_helper_serviceloader

Type

\midcom_helper_serviceloader

$i18n

$i18n : \midcom_services_i18n

Type

\midcom_services_i18n

$componentloader

$componentloader : \midcom_helper__componentloader

Type

\midcom_helper__componentloader

$dbclassloader

$dbclassloader : \midcom_services_dbclassloader

Type

\midcom_services_dbclassloader

$dbfactory

$dbfactory : \midcom_helper__dbfactory

Type

\midcom_helper__dbfactory

$head

$head : \midcom_helper_head

Type

\midcom_helper_head

$style

$style : \midcom_helper__styleloader

Type

\midcom_helper__styleloader

$auth

$auth : \midcom_services_auth

Type

\midcom_services_auth

$permalinks

$permalinks : \midcom_services_permalinks

Type

\midcom_services_permalinks

$toolbars

$toolbars : \midcom_services_toolbars

Type

\midcom_services_toolbars

$uimessages

$uimessages : \midcom_services_uimessages

Type

\midcom_services_uimessages

$metadata

$metadata : \midcom_services_metadata

Type

\midcom_services_metadata

$rcs

$rcs : \midcom_services_rcs

Type

\midcom_services_rcs

$session

$session : \midcom_services__sessioning

Type

\midcom_services__sessioning

$indexer

$indexer : \midcom_services_indexer

Type

\midcom_services_indexer

$config

$config : \midcom_config

Type

\midcom_config

$cache

$cache : \midcom_services_cache

Type

\midcom_services_cache

$dispatcher

$dispatcher : \midcom\events\dispatcher

Type

\midcom\events\dispatcher

$debug

$debug : \midcom_debug

Type

\midcom_debug

$_cached_host_prefix

$_cached_host_prefix : string

Host prefix cache to avoid computing it each time.

Type

string

$_cached_page_prefix

$_cached_page_prefix : string

Page prefix cache to avoid computing it each time.

Type

string

$request

$request : \Symfony\Component\HttpFoundation\Request

Type

\Symfony\Component\HttpFoundation\Request

Methods

__construct()

__construct() 

__get()

__get(  $key) 

Magic getter for service loading

Parameters

$key

__set()

__set(  $key,   $value) 

Magic setter

Parameters

$key
$value

initialize()

initialize() 

Main MidCOM initialization.

Initialize the Application class. Sets all private variables to a predefined state.

codeinit()

codeinit() 

Initialize the URL parser and process the request.

This function must be called before any output starts.

dynamic_load()

dynamic_load(string  $url, array  $config = array(),   $pass_get = false) : integer

Dynamically execute a subrequest and insert its output in place of the function call.

Important Note As with the Midgard Parser, dynamic_load strips a trailing .html from the argument list before actually parsing it.

It tries to load the component referenced with the URL $url and executes it as if it was used as primary component. Additional configuration parameters can be appended through the parameter $config.

This is only possible if the system is in the Page-Style output phase. It cannot be used within code-init or during the output phase of another component.

Example code, executed on a site's homepage, it will load the news listing from the given URL and display it using a substyle of the node style that is assigned to the loaded one:

$blog = '/blog/latest/3/'; $substyle = 'homepage'; midcom::get()->dynamic_load("/midcom-substyle-{$substyle}/{$blog}");

Results of dynamic_loads are cached, by default with the system cache strategy but you can specify separate cache strategy for the DL in the config array like so midcom::get()->dynamic_load("/midcom-substyle-{$substyle}/{$newsticker}", ['cache_module_content_caching_strategy' => 'public'])

You can use only less specific strategy than the global strategy, ie basically you're limited to 'memberships' and 'public' as values if the global strategy is 'user' and to 'public' the global strategy is 'memberships', failure to adhere to this rule will result to weird cache behavior.

Parameters

string $url

The URL, relative to the Midgard Page, that is to be requested.

array $config

A key=>value array with any configuration overrides.

$pass_get

Returns

integer —

The ID of the newly created context.

serve_attachment()

serve_attachment(\midcom_db_attachment  $attachment, integer  $expires = -1) 

Deliver a blob to the client. It will add the following HTTP Headers:

  • Cache-Control: public max-age=$expires
  • Expires: GMT Date $now+$expires
  • Last-Modified: GMT Date of the last modified timestamp of the Attachment
  • Content-Length: The Length of the Attachment in Bytes
  • Accept-Ranges: none

This should enable caching of browsers for Navigation images and so on. You can influence the expiration of the served attachment with the parameter $expires. It is the time in seconds till the client should refetch the file. The default for this is 24 hours. If you set it to "0" caching will be prohibited by changing the sent headers like this:

  • Pragma: no-cache
  • Cache-Control: no-cache
  • Expires: Current GMT Date

If expires is set to -1, no expires header gets sent.

Parameters

\midcom_db_attachment $attachment

The attachment to be delivered.

integer $expires

HTTP-Expires timeout in seconds, set this to 0 for uncacheable pages, or to -1 for no Expire header.

finish()

finish() 

Exit from the framework, execute after all output has been made.

Does all necessary clean-up work. Must be called after output is completed as the last call of any MidCOM Page.

WARNING: Anything done after calling this method will be lost.

get_host_name()

get_host_name() : string

Retrieves the name of the current host, fully qualified with protocol and port.

Returns

string —

Full Hostname (http[s]://www.my.domain.com[:1234])

get_page_prefix()

get_page_prefix() : string

Return the prefix required to build relative links on the current site.

This includes the http[s] prefix, the hosts port (if necessary) and the base url of the Midgard Page. Be aware, that this does not point to the base host of the site.

e.g. something like http[s]://www.domain.com[:8080]/host_prefix/page_prefix/

Returns

string —

The current MidCOM page URL prefix.

get_host_prefix()

get_host_prefix() : string

Return the prefix required to build relative links on the current site.

This includes the http[s] prefix, the hosts port (if necessary) and the base url of the main host. This is not necessarily the currently active MidCOM Page however, use the get_page_prefix() function for that.

e.g. something like http[s]://www.domain.com[:8080]/host_prefix/

Returns

string —

The host's root page URL prefix.

header()

header(string  $header, integer  $response_code = null) 

Sends a header out to the client.

This function is syntactically identical to the regular PHP header() function, but is integrated into the framework. Every Header you sent must go through this function or it might be lost later on; this is especially important with caching.

Parameters

string $header

The header to send.

integer $response_code

HTTP response code to send with the header

relocate()

relocate(string  $url, string  $response_code = 302) 

Relocate to another URL.

The helper actually can distinguish between site-local, absolute redirects and external redirects. If the url does not start with http[s] or /, it is taken as a URL relative to the current anchor prefix, which gets prepended automatically (no other characters as the anchor prefix get inserted).

Fully qualified urls (starting with http[s]) are used as-is.

Note, that this function automatically makes the page uncacheable, calls midcom_finish and exit, so it will never return. If the headers have already been sent, this will leave you with a partially completed page, so beware.

Parameters

string $url

The URL to redirect to, will be preprocessed as outlined above.

string $response_code

HTTP response code to send with the relocation, from 3xx series

disable_limits()

disable_limits() 

Raise some PHP limits for resource-intensive tasks

_process()

_process(\midcom_core_context  $context) : \midcom_response

Process the request

Basically this method will parse the URL and search for a component that can handle the request. If one is found, it will process the request, if not, it will report an error, depending on the situation.

Details: The logic will traverse the node tree, and for the last node it will load the component that is responsible for it. This component gets the chance to accept the request, which is basically a call to can_handle. If the component declares to be able to handle the call, its handle function is executed. Depending if the handle was successful or not, it will either display an HTTP error page or prepares the content handler to display the content later on.

If the parsing process doesn't find any component that declares to be able to handle the request, an HTTP 404 - Not Found error is triggered.

Parameters

\midcom_core_context $context

Returns

\midcom_response

_output()

_output(\midcom_core_context  $context,   $include_template, \midcom_response  $response) 

Execute the output callback.

Launches the output of the currently selected component. It is collected in an output buffer to allow for relocates from style elements.

It executes the content_handler that has been determined during the handle phase. It fetches the content_handler from the Component Loader class cache.

Parameters

\midcom_core_context $context
$include_template
\midcom_response $response