Ejemplo n.º 1
0
 /**
  * Overrides LinkitSearchPlugin::__construct().
  *
  * Initialize this plugin with the plugin, profile, and entity specific
  * variables.
  *
  * @param array $plugin
  *   The plugin array.
  *
  * @param LinkitProfile object $profile
  *   The Linkit profile to use.
  */
 function __construct($plugin, LinkitProfile $profile)
 {
     parent::__construct($plugin, $profile);
     // Load the corresponding entity info.
     $this->entity_info = entity_get_info($this->plugin['entity_type']);
     // Set bundle key name.
     if (isset($this->entity_info['entity keys']['bundle']) && !isset($this->entity_key_bundle)) {
         $this->entity_key_bundle = $this->entity_info['entity keys']['bundle'];
     }
     // Set the label field name.
     if (!isset($this->entity_field_label)) {
         // Check that the entity has a label in entity keys.
         // If not, Linkit don't know what to search for.
         if (!isset($this->entity_info['entity keys']['label'])) {
             // This is only used when building the plugin list.
             $this->unusable = TRUE;
         } else {
             $this->entity_field_label = $this->entity_info['entity keys']['label'];
         }
     }
     // Make a shortcut for the profile data settings for this plugin.
     $this->conf = isset($this->profile->data[$this->plugin['name']]) ? $this->profile->data[$this->plugin['name']] : array();
 }