You are here

public function AuthcacheP13nFragmentBuilder::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/AuthcacheP13nFragmentBuilder.inc, line 70
Defines AuthcacheP13nFragmentBuilder

Class

AuthcacheP13nFragmentBuilder
Content builder for personalized content fragments.

Code

public function build($req, $context) {
  global $user;
  $params = $req['a'];

  // Run loader.
  if ($this->loader) {
    $params = $this->loader
      ->load($params, $context);
  }
  $key = key($params);
  $subject = current($params);

  // Run access check.
  if ($this->access && !$this->access
    ->check($user, $key, $subject, $context)) {
    throw new AuthcacheP13nRequestAccessDenied();
  }
  else {
    return $this->fragment
      ->render($key, $subject, $context);
  }
}