You are here

function fontyourface_features_export_render in @font-your-face 7.2

Implements hook_features_export_render. [component hook]

This hook will be invoked in order to export Component hook. The hook should be implemented using the name ot the component, not the module, eg. [component]_features_export() rather than [module]_features_export().

Render one or more component objects to code.

Parameters

string $module_name: The name of the feature module to be exported.

array $data: An array of machine name identifiers for the objects to be rendered.

array $export: The full export array of the current feature being exported. This is only passed when hook_features_export_render() is invoked for an actual feature update or recreate, not during state checks or other operations.

Return value

array An associative array of rendered PHP code where the key is the name of the hook that should wrap the PHP code. The hook should not include the name of the module, e.g. the key for `hook_example` should simply be `example`.

File

./fontyourface.features.inc, line 93
Integrates Features for @font-your-face.

Code

function fontyourface_features_export_render($module, $data) {
  $fonts = fontyourface_get_fonts('enabled = 1');
  $code = array();
  foreach ($data as $name) {
    foreach ($fonts as $font) {
      if ($font->name == $name) {

        // We don't want to break the entity cache, so we need to clone the
        // font before unsetting the id.
        $font = clone $font;
        unset($font->fid);
        unset($font->tags);
        $code[$name] = $font;
      }
    }
  }
  $code = "  return " . features_var_export($code, '  ') . ";";
  return array(
    'fontyourface_features_default_font' => $code,
  );
}