Permalink
Browse files

deprecate(views): Support for custom template handlers will end soon

This functionality was never really properly implemented anyways.
Even the docblock comments on the API functions says "experimental."

Refs #8440
  • Loading branch information...
ewinslow committed Jun 19, 2015
1 parent 642873b commit 0dc67698f6def5fa6cea32dd1171d1166e9c4e29
Showing with 43 additions and 30 deletions.
  1. +6 −0 docs/guides/views.rst
  2. +1 −0 engine/lib/deprecated-1.11.php
  3. +34 −0 engine/lib/deprecated-1.12.php
  4. +0 −30 engine/lib/views.php
  5. +2 −0 engine/load.php
View
@@ -326,6 +326,12 @@ In the first example, we are displaying a list of groups a user is a member of u
Using a different templating system
===================================
.. warning::
This functionality is deprecated as of Elgg 1.12. It will be removed in 2.0.
It affects the behavior of templates globally, which is almost sure to cause
breakages and therefore we suspect no one uses it in practice.
You can write your own templating system if you want to.
Before going through the motions of drawing views, Elgg checks the ``$CONFIG->template_handler`` variable to see if it contains the name of a callable function. If it does, the function will be passed the view name and template vars, and the return value of this function will be returned instead of the standard output:
@@ -0,0 +1 @@
<?php
@@ -0,0 +1,34 @@
<?php
/**
* Registers a function to handle templates.
*
* Alternative template handlers can be registered to handle
* all output functions. By default, {@link elgg_view()} will
* simply include the view file. If an alternate template handler
* is registered, the view name and passed $vars will be passed to the
* registered function, which is then responsible for generating and returning
* output.
*
* Template handlers need to accept two arguments: string $view_name and array
* $vars.
*
* @warning This is experimental.
*
* @param string $function_name The name of the function to pass to.
*
* @return bool
* @see elgg_view()
* @deprecated 1.12
*/
function set_template_handler($function_name) {
elgg_deprecated_notice("Support for custom template handlers will end soon.", "1.12");
global $CONFIG;
if (is_callable($function_name)) {
$CONFIG->template_handler = $function_name;
return true;
}
return false;
}
View
@@ -1457,36 +1457,6 @@ function elgg_view_access_collections($owner_guid) {
return elgg_view('core/friends/collections', array('collections' => $collections));
}
/**
* Registers a function to handle templates.
*
* Alternative template handlers can be registered to handle
* all output functions. By default, {@link elgg_view()} will
* simply include the view file. If an alternate template handler
* is registered, the view name and passed $vars will be passed to the
* registered function, which is then responsible for generating and returning
* output.
*
* Template handlers need to accept two arguments: string $view_name and array
* $vars.
*
* @warning This is experimental.
*
* @param string $function_name The name of the function to pass to.
*
* @return bool
* @see elgg_view()
*/
function set_template_handler($function_name) {
global $CONFIG;
if (is_callable($function_name)) {
$CONFIG->template_handler = $function_name;
return true;
}
return false;
}
/**
* Auto-registers views from a location.
*
View
@@ -74,6 +74,8 @@
'deprecated-1.8.php',
'deprecated-1.9.php',
'deprecated-1.10.php',
'deprecated-1.11.php',
'deprecated-1.12.php',
);
// isolate global scope

0 comments on commit 0dc6769

Please sign in to comment.