class EsiValidateRenderStrategy in Render cache 7.2
ESI Validate RenderStrategy - Provides esi processing for placeholders.
Hierarchy
- class \Drupal\render_cache\RenderCache\RenderStrategy\BaseRenderStrategy extends \Drupal\Component\Plugin\PluginBase implements RenderStrategyInterface
- class \Drupal\render_cache_esi_validate\RenderCache\RenderStrategy\EsiValidateRenderStrategy
Expanded class hierarchy of EsiValidateRenderStrategy
File
- modules/
renderer/ render_cache_esi_validate/ src/ RenderCache/ RenderStrategy/ EsiValidateRenderStrategy.php, line 16 - Contains \Drupal\render_cache_esi_validate\RenderCache\RenderStrategy\EsiValidateRenderStrategy
Namespace
Drupal\render_cache_esi_validate\RenderCache\RenderStrategyView source
class EsiValidateRenderStrategy extends BaseRenderStrategy {
/**
* {@inheritdoc}
*/
public function render(array $args) {
$placeholders = array();
// This will only work if the caller allows ESI.
if (empty($_SERVER['HTTP_X_DRUPAL_ESI_VALIDATE'])) {
return array();
}
foreach ($args as $placeholder => $ph_object) {
// If there is no cache ID, we can't ESI validate this.
if (empty($ph_object['cache_info']['cid'])) {
continue;
}
$base_esi = 'render-cache/esi-validate-render';
if (variable_get('render_cache_esi_use_php_script', FALSE)) {
$base_esi = drupal_get_path('module', 'esi_render_cache') . '/esi_validate.php';
}
// The markup is already cached, so just provide a Cache ID.
$url = url($base_esi, array(
'query' => array(
'cid' => $ph_object['cache_info']['cid'],
'bin' => $ph_object['cache_info']['bin'],
),
));
$placeholders[$placeholder] = array(
'#markup' => '<esi:include src="' . $url . '" />',
);
}
return $placeholders;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EsiValidateRenderStrategy:: |
public | function |
Overrides RenderStrategyInterface:: |