You are here

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

Class

AuthcacheP13nFragmentAssemblyBuilder
Content builder for personalized fragment assemblies.

Code

public function build($req, $context) {
  global $user;
  $result = array();
  foreach ($req['a'] as $paramname => $params) {

    // Skip when there is no handler present.
    if (empty($this->partials[$paramname]['renderer'])) {
      continue;
    }
    $partial = $this->partials[$paramname];

    // Run loader.
    if (!empty($partial['loader'])) {
      try {
        $params = $partial['loader']
          ->load($params, $context);
      } catch (AuthcacheP13nRequestNotFound $e) {
        unset($e);
        continue;
      }
    }
    foreach ($params as $key => $subject) {

      // Run access check.
      if (empty($partial['access']) || $partial['access']
        ->check($user, $key, $subject, $context)) {
        $result[$paramname][$key] = $partial['renderer']
          ->render($key, $subject, $context);
      }
    }
  }
  return $result;
}