本文整理汇总了PHP中Drupal\Core\Entity\EntityManagerInterface::getAllBundleInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManagerInterface::getAllBundleInfo方法的具体用法?PHP EntityManagerInterface::getAllBundleInfo怎么用?PHP EntityManagerInterface::getAllBundleInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityManagerInterface
的用法示例。
在下文中一共展示了EntityManagerInterface::getAllBundleInfo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$bundles = $this->entityManager->getAllBundleInfo();
$values = $form_state->getValues();
$entity_values = $values['entity_types'];
$config = $this->config('xmlsitemap.settings');
$settings = $form_state->getValue('settings');
foreach ($entity_values as $key => $value) {
if ($value) {
foreach ($bundles[$key] as $bundle_key => $bundle_value) {
if (!$values['settings'][$key]['types'][$bundle_key]) {
xmlsitemap_link_bundle_delete($key, $bundle_key, TRUE);
} else {
if (!xmlsitemap_link_bundle_check_enabled($key, $bundle_key)) {
xmlsitemap_link_bundle_enable($key, $bundle_key);
}
}
}
} else {
foreach ($bundles[$key] as $bundle_key => $bundle_value) {
xmlsitemap_link_bundle_delete($key, $bundle_key, TRUE);
}
}
}
parent::submitForm($form, $form_state);
}
示例2: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state)
{
$entity_types = $this->entityManager->getDefinitions();
$labels = array();
$default = array();
$bundles = $this->entityManager->getAllBundleInfo();
$language_configuration = array();
foreach ($entity_types as $entity_type_id => $entity_type) {
if (!$entity_type->isTranslatable()) {
continue;
}
$labels[$entity_type_id] = $entity_type->getLabel() ?: $entity_type_id;
$default[$entity_type_id] = FALSE;
// Check whether we have any custom setting.
foreach ($bundles[$entity_type_id] as $bundle => $bundle_info) {
$conf = language_get_default_configuration($entity_type_id, $bundle);
if (!empty($conf['language_show']) || $conf['langcode'] != 'site_default') {
$default[$entity_type_id] = $entity_type_id;
}
$language_configuration[$entity_type_id][$bundle] = $conf;
}
}
asort($labels);
$form = array('#labels' => $labels, '#attached' => array('library' => array('language/drupal.language.admin')));
$form['entity_types'] = array('#title' => $this->t('Custom language settings'), '#type' => 'checkboxes', '#options' => $labels, '#default_value' => $default);
$form['settings'] = array('#tree' => TRUE);
foreach ($labels as $entity_type_id => $label) {
$entity_type = $entity_types[$entity_type_id];
$form['settings'][$entity_type_id] = array('#title' => $label, '#type' => 'container', '#entity_type' => $entity_type_id, '#theme' => 'language_content_settings_table', '#bundle_label' => $entity_type->getBundleLabel() ?: $label, '#states' => array('visible' => array(':input[name="entity_types[' . $entity_type_id . ']"]' => array('checked' => TRUE))));
foreach ($bundles[$entity_type_id] as $bundle => $bundle_info) {
$form['settings'][$entity_type_id][$bundle]['settings'] = array('#type' => 'item', '#label' => $bundle_info['label'], 'language' => array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => $entity_type_id, 'bundle' => $bundle), '#default_value' => $language_configuration[$entity_type_id][$bundle]));
}
}
$form = parent::buildForm($form, $form_state);
// @todo Remove this override. There are tests that check for explicitly for
// the button label which need to be adapted for that.
// https://drupal.org/node/2241727
$form['actions']['submit']['#value'] = $this->t('Save');
return $form;
}
示例3: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$entity_types = $this->entityManager->getDefinitions();
$labels = array();
$default = array();
$bundles = $this->entityManager->getAllBundleInfo();
$language_configuration = array();
foreach ($entity_types as $entity_type_id => $entity_type) {
if (!$entity_type instanceof ContentEntityTypeInterface || !$entity_type->hasKey('langcode') || !isset($bundles[$entity_type_id])) {
continue;
}
$labels[$entity_type_id] = $entity_type->getLabel() ?: $entity_type_id;
$default[$entity_type_id] = FALSE;
// Check whether we have any custom setting.
foreach ($bundles[$entity_type_id] as $bundle => $bundle_info) {
$config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type_id, $bundle);
if (!$config->isDefaultConfiguration()) {
$default[$entity_type_id] = $entity_type_id;
}
$language_configuration[$entity_type_id][$bundle] = $config;
}
}
asort($labels);
$form = array('#labels' => $labels, '#attached' => array('library' => array('language/drupal.language.admin')), '#attributes' => array('class' => 'language-content-settings-form'));
$form['entity_types'] = array('#title' => $this->t('Custom language settings'), '#type' => 'checkboxes', '#options' => $labels, '#default_value' => $default);
$form['settings'] = array('#tree' => TRUE);
foreach ($labels as $entity_type_id => $label) {
$entity_type = $entity_types[$entity_type_id];
$form['settings'][$entity_type_id] = array('#title' => $label, '#type' => 'container', '#entity_type' => $entity_type_id, '#theme' => 'language_content_settings_table', '#bundle_label' => $entity_type->getBundleLabel() ?: $label, '#states' => array('visible' => array(':input[name="entity_types[' . $entity_type_id . ']"]' => array('checked' => TRUE))));
foreach ($bundles[$entity_type_id] as $bundle => $bundle_info) {
$form['settings'][$entity_type_id][$bundle]['settings'] = array('#type' => 'item', '#label' => $bundle_info['label'], 'language' => array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => $entity_type_id, 'bundle' => $bundle), '#default_value' => $language_configuration[$entity_type_id][$bundle]));
}
}
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save configuration'), '#button_type' => 'primary');
return $form;
}
示例4: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state)
{
$entity_types = $this->entityManager->getDefinitions();
$labels = array();
$default = array();
$bundles = $this->entityManager->getAllBundleInfo();
$language_configuration = array();
foreach ($entity_types as $entity_type_id => $entity_type) {
if (!$entity_type->isTranslatable()) {
continue;
}
$labels[$entity_type_id] = $entity_type->getLabel() ?: $entity_type_id;
$default[$entity_type_id] = FALSE;
// Check whether we have any custom setting.
foreach ($bundles[$entity_type_id] as $bundle => $bundle_info) {
$conf = language_get_default_configuration($entity_type_id, $bundle);
if (!empty($conf['language_show']) || $conf['langcode'] != LanguageInterface::LANGCODE_SITE_DEFAULT) {
$default[$entity_type_id] = $entity_type_id;
}
$language_configuration[$entity_type_id][$bundle] = $conf;
}
}
asort($labels);
$form = array('#labels' => $labels, '#attached' => array('library' => array('language/drupal.language.admin')));
$form['entity_types'] = array('#title' => $this->t('Custom language settings'), '#type' => 'checkboxes', '#options' => $labels, '#default_value' => $default);
$form['settings'] = array('#tree' => TRUE);
foreach ($labels as $entity_type_id => $label) {
$entity_type = $entity_types[$entity_type_id];
$form['settings'][$entity_type_id] = array('#title' => $label, '#type' => 'container', '#entity_type' => $entity_type_id, '#theme' => 'language_content_settings_table', '#bundle_label' => $entity_type->getBundleLabel() ?: $label, '#states' => array('visible' => array(':input[name="entity_types[' . $entity_type_id . ']"]' => array('checked' => TRUE))));
foreach ($bundles[$entity_type_id] as $bundle => $bundle_info) {
$form['settings'][$entity_type_id][$bundle]['settings'] = array('#type' => 'item', '#label' => $bundle_info['label'], 'language' => array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => $entity_type_id, 'bundle' => $bundle), '#default_value' => $language_configuration[$entity_type_id][$bundle]));
}
}
$form = parent::buildForm($form, $form_state);
return $form;
}
示例5: getAllBundleInfo
/**
* {@inheritdoc}
*/
public function getAllBundleInfo()
{
return $this->entityManager->getAllBundleInfo();
}