You are here

class MigrateMetatagHandler in Metatag 7

Metatag destination handler.

Hierarchy

Expanded class hierarchy of MigrateMetatagHandler

1 string reference to 'MigrateMetatagHandler'
metatag_migrate_api in ./metatag.migrate.inc
Implements hook_migrate_api().

File

./metatag.migrate.inc, line 86

View source
class MigrateMetatagHandler extends MigrateDestinationHandler {

  /**
   * Identify a list of supported entity types.
   */
  public function __construct() {
    $entity_types = metatag_entity_supports_metatags();
    $entity_types = array_filter($entity_types);
    $entity_types = array_keys($entity_types);
    $this
      ->registerTypes($entity_types);
  }

  /**
   * Implements MigrateDestinationHandler::fields().
   */
  public function fields() {
    $fields = array();
    $elements = metatag_get_info();
    foreach ($elements['tags'] as $value) {
      $metatag_field = 'metatag_' . $value['name'];
      $fields[$metatag_field] = $value['description'];
    }
    return $fields;
  }

  /**
   * Implements MigrateDestinationHandler::prepare().
   */
  public function prepare($entity, stdClass $row) {
    $elements = metatag_get_info();
    foreach ($elements['tags'] as $value) {
      $metatag_field = 'metatag_' . $value['name'];
      if (isset($entity->{$metatag_field})) {
        $language = isset($entity->language) ? $entity->language : LANGUAGE_NONE;
        $entity->metatags[$language][$value['name']]['value'] = $entity->{$metatag_field};
        unset($entity->{$metatag_field});
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MigrateHandler::$dependencies protected property List of other handler classes which should be invoked before the current one.
MigrateHandler::$typesHandled protected property List of "types" handled by this handler. Depending on the kind of handler, these may be destination types, field types, etc.
MigrateHandler::getDependencies public function
MigrateHandler::getTypesHandled public function
MigrateHandler::handlesType public function Does this handler handle the given type? 1
MigrateHandler::registerTypes protected function Register a list of types handled by this class
MigrateMetatagHandler::fields public function Implements MigrateDestinationHandler::fields().
MigrateMetatagHandler::prepare public function Implements MigrateDestinationHandler::prepare().
MigrateMetatagHandler::__construct public function Identify a list of supported entity types. Overrides MigrateHandler::__construct