You are here

protected function AccessSchemeEntityController::attachLoad in Access Control Kit 7

Overrides DrupalDefaultEntityController::attachLoad().

Overrides DrupalDefaultEntityController::attachLoad

File

./access_scheme_entity_controller.inc, line 36
Contains the access scheme entity controller.

Class

AccessSchemeEntityController
Provides the entity controller for access schemes.

Code

protected function attachLoad(&$schemes, $revision_id = FALSE) {
  foreach ($schemes as $scheme) {

    // Make sure the settings property is an array.
    $scheme->settings = isset($scheme->settings) ? unserialize($scheme->settings) : array();

    // Attach scheme type definition.
    $scheme->info = access_scheme_info($scheme->type);

    // Load the callbacks' include file, if one exists.
    if (!empty($scheme->info['include file'])) {
      require_once DRUPAL_ROOT . '/' . $scheme->info['include file'];
    }

    // Attach realm information.
    $scheme->realm_field = field_info_field($scheme->realm_field_name);
    if (!empty($scheme->info['realms callback']) && function_exists($scheme->info['realms callback'])) {
      $scheme->realms = call_user_func_array($scheme->info['realms callback'], array(
        $scheme,
      ));
    }
    else {
      $scheme->realms = array();
    }

    // Attach the scheme's object access handlers.
    $scheme->handlers = array();
    $result = db_query('SELECT * FROM {access_handler} WHERE scheme = :scheme', array(
      ':scheme' => $scheme->machine_name,
    ));
    foreach ($result as $row) {
      $this
        ->attachHandler($scheme, $row->object_type, $row->handler, unserialize($row->settings));
    }
  }
  parent::attachLoad($schemes, $revision_id);
}