function metatag_entity_type_enable in Metatag 7
Enable support for a specific entity type if setting does not exist.
Parameters
string $entity_type: The entity type.
string $bundle: The bundle of the entity.
bool $force_enable: If TRUE, then the type is enabled regardless of any stored variables.
Return value
bool TRUE if either the bundle or entity type was enabled by this function.
5 calls to metatag_entity_type_enable()
- MetatagCoreWithSearchApiTest::setUp in tests/
MetatagCoreWithSearchApiTest.test - Sets up a Drupal site for running functional and integration tests.
- MetatagTestBase::createContentType in tests/
MetatagTestBase.test - Create a content type for the tests.
- MetatagTestBase::createVocabulary in tests/
MetatagTestBase.test - Returns a new vocabulary with random properties.
- metatag_node_type_insert in ./
metatag.module - Implements hook_node_type_insert().
- metatag_taxonomy_vocabulary_insert in ./
metatag.module - Implements hook_taxonomy_vocabulary_insert().
File
- ./
metatag.module, line 1873 - Primary hook implementations for Metatag.
Code
function metatag_entity_type_enable($entity_type, $bundle = NULL, $force_enable = FALSE) {
// The bundle was defined.
$bundle_set = FALSE;
if (isset($bundle)) {
$stored_bundle = variable_get('metatag_enable_' . $entity_type . '__' . $bundle, NULL);
if ($force_enable || !isset($stored_bundle)) {
variable_set('metatag_enable_' . $entity_type . '__' . $bundle, TRUE);
$bundle_set = TRUE;
}
}
// Always enable the entity type, because otherwise there's no point in
// enabling the bundle.
$entity_type_set = FALSE;
$stored_entity_type = variable_get('metatag_enable_' . $entity_type, NULL);
if ($force_enable || !isset($stored_entity_type)) {
variable_set('metatag_enable_' . $entity_type, TRUE);
$entity_type_set = TRUE;
}
// Clear the static cache so that the entity type / bundle will work.
drupal_static_reset('metatag_entity_supports_metatags');
return $bundle_set || $entity_type_set;
}