/**
  * Get a dictionary entry for a bundle. Entries are matched first on bundle name, and then filtered on any restrict_to_types
  * and restrict_to_relationship_types settings in the $pa_settings parameter. This allows you to have different dictionary entries
  * for the same bundle name subject to type restrictions set in the user interface. For example, if you have a ca_entities bundle (related
  * entities) you can have different dictionary entries return when ca_entities is restricted to authors vs. publishers.
  *
  * @param string $ps_bundle_name The bundle name to find a dictionary entry for. 
  * @param array $pa_settings Bundle settings to use when matching definitions. The bundle settings restrict_to_types and restrict_to_relationship_types will be used, when present, to find type-restricted dictionary entries.
  * @param array $pa_options Options include:
  *		noCache = Bypass cache (typically loaded using ca_metadata_dictionary_entries::preloadDefinitions()) and check entry directly. [Default=false]
  *
  * @return array An array with entry data. Keys are entry field names. The 'settings' key contains the label, definition text and any type restrictions. Returns null if no entry is defined.
  */
 public static function getEntry($ps_bundle_name, $pa_settings = null, $pa_options = null)
 {
     if (caGetOption('noCache', $pa_options, false)) {
         ca_metadata_dictionary_entries::preloadDefinitions(array($ps_bundle_name));
     }
     if (!is_array($va_types = caGetOption('restrict_to_types', $pa_settings, null)) && $va_types) {
         $va_types = array($va_types);
     }
     if (!is_array($va_types)) {
         $va_types = array();
     }
     if (sizeof($va_types = array_filter($va_types, 'strlen'))) {
         $va_types = ca_lists::itemIDsToIDNOs($va_types);
     }
     if (!is_array($va_relationship_types = caGetOption('restrict_to_relationship_types', $pa_settings, null)) && $va_relationship_types) {
         $va_relationship_types = array($va_relationship_types);
     }
     if (!is_array($va_relationship_types)) {
         $va_relationship_types = array();
     }
     if (sizeof($va_relationship_types = array_filter($va_relationship_types, 'strlen'))) {
         $va_relationship_types = ca_relationship_types::relationshipTypeIDsToTypeCodes($va_relationship_types);
     }
     if ($va_entry_list = ca_metadata_dictionary_entries::entryExists($ps_bundle_name)) {
         $vn_entry_id = null;
         if (sizeof($va_types) || sizeof($va_relationship_types)) {
             foreach (array_keys($va_entry_list) as $vn_id) {
                 $va_entry = ca_metadata_dictionary_entries::$s_definition_cache[$vn_id];
                 if (sizeof($va_relationship_types)) {
                     if (is_array($va_entry_types = $va_entry['settings']['restrict_to_relationship_types'])) {
                         if (sizeof(array_intersect($va_relationship_types, $va_entry_types))) {
                             $vn_entry_id = $vn_id;
                         } else {
                             $vn_entry_id = null;
                             continue;
                         }
                     }
                 }
                 if (sizeof($va_types)) {
                     if (is_array($va_entry_types = $va_entry['settings']['restrict_to_types'])) {
                         if (sizeof(array_intersect($va_types, $va_entry_types))) {
                             $vn_entry_id = $vn_id;
                         } else {
                             $vn_entry_id = null;
                             continue;
                         }
                     }
                 }
                 if ($vn_entry_id) {
                     break;
                 }
             }
         }
         if (!$vn_entry_id) {
             $vn_entry_id = array_pop(array_keys($va_entry_list));
         }
         return ca_metadata_dictionary_entries::$s_definition_cache[$vn_entry_id];
     }
     return null;
 }