You are here

public function AuthcacheP13nSettingBuilder::build in Authenticated User Page Caching (Authcache) 7.2

Build and return the content defined by the input parameters.

When no appropriate content is present, implementations should throw an AuthcacheP13nRequsetNotFound exception.

Parameters

array $input: The GET parameters in key-value form

array $context: Additional run-time per-request context (key-value pairs).

Return value

array|string The built content suitable for passing to the content encoder.

Throws

AuthcacheP13nRequestNotFound

Overrides AuthcacheP13nContentBuilderInterface::build

File

modules/authcache_p13n/includes/AuthcacheP13nSettingBuilder.inc, line 50
Defines AuthcacheP13nSettingBuilder.

Class

AuthcacheP13nSettingBuilder
Content builder for personalized Drupal.settings.

Code

public function build($req, $context) {
  global $user;
  $data = array();
  foreach ($this->settings as $paramname => $setting) {
    $params = isset($req['a'][$paramname]) ? $req['a'][$paramname] : NULL;

    // Run access check.
    if (!empty($setting['access']) && !$setting['access']
      ->check($user, $params, $context)) {
      throw new AuthcacheP13nRequestAccessDenied();
    }

    // Render result.
    $data[] = array(
      $setting['target'] => $setting['renderer']
        ->get($params, $context),
    );
  }

  // Merge and return result of all settings.
  return drupal_array_merge_deep_array($data);
}