You are here

function pmpapi_pull_find_mapped_entity in Public Media Platform API Integration 7

Finds the mapped entity for a given PMP profile.

Parameters

$profile string: The name of a PMP profile

Return value

array The entity type and bundle name of the mapped entity

4 calls to pmpapi_pull_find_mapped_entity()
PMPAPIDrupalPull::alterMappedValues in pmpapi_pull/classes/PMPAPIDrupalPull.php
Alter values just prior to mapping.
PMPAPIDrupalPull::saveEntity in pmpapi_pull/classes/PMPAPIDrupalPull.php
Saves a PMP doc as an entity.
pmpapi_pull_parse_doc_metadata in pmpapi_pull/pmpapi_pull.pages.inc
Parses out metadata from PMP docs.
pmpapi_pull_preview in pmpapi_pull/pmpapi_pull.pages.inc
Page callback: Previews a pulled doc without creating a node.

File

pmpapi_pull/pmpapi_pull.module, line 133
Allows admins to pull content from the PMP API, and turn PMP docs into (locally-stored, independent) drupal entities.

Code

function pmpapi_pull_find_mapped_entity($profile) {
  foreach (entity_get_info() as $entity_type => $entity) {
    $bundles = $entity['bundles'];
    foreach ($bundles as $bundle_name => $bundle) {
      $uname = $entity_type . '__' . $bundle_name;
      $mapped_profile = variable_get('pmpapi_pull_' . $uname . '_profile');
      if ($mapped_profile == $profile) {
        return array(
          'entity_type' => $entity_type,
          'bundle_name' => $bundle_name,
        );
      }
    }
  }
}