Commit bd6ad51a authored by alexpott's avatar alexpott

Issue #2008558 by effulgentsia: Move nonalterations from...

Issue #2008558 by effulgentsia: Move nonalterations from hook_entity_bundle_info_alter() implementations to hook_entity_bundle_info() implementations.
parent 6f25f158
......@@ -50,21 +50,24 @@ function field_test_entity_view_mode_info_alter(&$view_modes) {
}
/**
* Implements hook_entity_bundle_info_alter().
* Implements hook_entity_bundle_info().
*/
function field_test_entity_bundle_info_alter(&$bundles) {
function field_test_entity_bundle_info() {
$bundles = array();
$entity_info = entity_get_info();
foreach ($bundles as $entity_type => $info) {
if ($entity_info[$entity_type]['module'] == 'field_test') {
foreach ($entity_info as $entity_type => $info) {
if ($info['module'] == 'field_test') {
$bundles[$entity_type] = Drupal::state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
if ($entity_type == 'test_entity_bundle') {
$bundles[$entity_type] += array('test_entity_2' => array('label' => 'Test entity 2'));
}
if ($entity_type == 'test_entity_bundle_key') {
$bundles[$entity_type] += array('bundle1' => array('label' => 'Bundle1'), 'bundle2' => array('label' => 'Bundle2'));
}
}
}
$bundles['test_entity_bundle']['test_entity_2'] = array('label' => 'Test entity 2');
$bundles['test_entity_bundle_key']['bundle1'] = array('label' => 'Bundle1');
$bundles['test_entity_bundle_key']['bundle2'] = array('label' => 'Bundle2');
return $bundles;
}
/**
......
......@@ -267,20 +267,3 @@ function field_test_field_extra_fields_alter(&$info) {
// Remove all extra fields from the 'no_fields' content type;
unset($info['node']['no_fields']);
}
/**
* Implements hook_module_implements_alter().
*
* field_test_entity_info_alter() adds the bundles for its entities, and thus
* needs to run before rdf_entity_info_alter().
* @todo Remove when http://drupal.org/node/1822458 is fixed.
*/
function field_test_module_implements_alter(&$implementations, $hook) {
if ($hook == 'entity_bundle_info_alter' && isset($implementations['field_test']) && isset($implementations['rdf'])) {
foreach (array('field_test', 'rdf') as $module) {
$group = $implementations[$module];
unset($implementations[$module]);
$implementations[$module] = $group;
}
}
}
......@@ -122,15 +122,17 @@ function entity_test_delete_bundle($bundle, $entity_type = 'entity_test') {
}
/**
* Implements hook_entity_bundle_info_alter().
* Implements hook_entity_bundle_info().
*/
function entity_test_entity_bundle_info_alter(&$bundles) {
function entity_test_entity_bundle_info() {
$bundles = array();
$entity_info = entity_get_info();
foreach ($bundles as $entity_type => $info) {
if ($entity_info[$entity_type]['module'] == 'entity_test') {
foreach ($entity_info as $entity_type => $info) {
if ($info['module'] == 'entity_test') {
$bundles[$entity_type] = Drupal::state()->get($entity_type . '.bundles') ?: array($entity_type => array('label' => 'Entity Test Bundle'));
}
}
return $bundles;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment