當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EntityManagerInterface::getAllBundleInfo方法代碼示例

本文整理匯總了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);
 }
開發者ID:jeroenos,項目名稱:jeroenos_d8.mypressonline.com,代碼行數:29,代碼來源:XmlSitemapEntitiesSettingsForm.php

示例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;
 }
開發者ID:alnutile,項目名稱:drunatra,代碼行數:43,代碼來源:ContentLanguageSettingsForm.php

示例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;
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:40,代碼來源:ContentLanguageSettingsForm.php

示例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;
 }
開發者ID:davidsoloman,項目名稱:drupalconsole.com,代碼行數:39,代碼來源:ContentLanguageSettingsForm.php

示例5: getAllBundleInfo

 /**
  * {@inheritdoc}
  */
 public function getAllBundleInfo()
 {
     return $this->entityManager->getAllBundleInfo();
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:7,代碼來源:EntityManagerWrapper.php


注:本文中的Drupal\Core\Entity\EntityManagerInterface::getAllBundleInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。