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


PHP EntityManagerInterface::clearCachedFieldDefinitions方法代碼示例

本文整理匯總了PHP中Drupal\Core\Entity\EntityManagerInterface::clearCachedFieldDefinitions方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityManagerInterface::clearCachedFieldDefinitions方法的具體用法?PHP EntityManagerInterface::clearCachedFieldDefinitions怎麽用?PHP EntityManagerInterface::clearCachedFieldDefinitions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Entity\EntityManagerInterface的用法示例。


在下文中一共展示了EntityManagerInterface::clearCachedFieldDefinitions方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $type = $this->entity;
     $type->setNewRevision($form_state->getValue(array('options', 'revision')));
     $type->set('type', trim($type->id()));
     $type->set('name', trim($type->label()));
     $status = $type->save();
     $t_args = array('%name' => $type->label());
     if ($status == SAVED_UPDATED) {
         drupal_set_message(t('The support ticket type %name has been updated.', $t_args));
     } elseif ($status == SAVED_NEW) {
         support_ticket_add_body_field($type);
         // @todo
         drupal_set_message(t('The support ticket type %name has been added.', $t_args));
         $context = array_merge($t_args, array('link' => $type->link($this->t('View'), 'collection')));
         $this->logger('support_ticket')->notice('Added support ticket type %name.', $context);
     }
     $fields = $this->entityManager->getFieldDefinitions('support_ticket', $type->id());
     // Update title field definition.
     $title_field = $fields['title'];
     $title_label = $form_state->getValue('title_label');
     if ($title_field->getLabel() != $title_label) {
         $title_field->getConfig($type->id())->setLabel($title_label)->save();
     }
     // Update workflow options.
     $support_ticket = $this->entityManager->getStorage('support_ticket')->create(array('support_ticket_type' => $type->id()));
     foreach (array('status', 'locked') as $field_name) {
         $value = (bool) $form_state->getValue(['options', $field_name]);
         if ($support_ticket->{$field_name}->value != $value) {
             $fields[$field_name]->getConfig($type->id())->setDefaultValue($value)->save();
         }
     }
     $this->entityManager->clearCachedFieldDefinitions();
     $form_state->setRedirectUrl($type->urlInfo('collection'));
 }
開發者ID:justincletus,項目名稱:webdrupalpro,代碼行數:38,代碼來源:SupportTicketTypeForm.php

示例2: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $type = $this->entity;
     $type->setNewRevision($form_state->getValue(array('options', 'revision')));
     $type->set('type', trim($type->id()));
     $type->set('name', trim($type->label()));
     $status = $type->save();
     $t_args = array('%name' => $type->label());
     if ($status == SAVED_UPDATED) {
         drupal_set_message(t('The content type %name has been updated.', $t_args));
     } elseif ($status == SAVED_NEW) {
         drupal_set_message(t('The content type %name has been added.', $t_args));
         $context = array_merge($t_args, array('link' => $type->link($this->t('View'), 'collection')));
         $this->logger('log')->notice('Added content type %name.', $context);
     }
     $fields = $this->entityManager->getFieldDefinitions('log', $type->id());
     // Update title field definition.
     $title_field = $fields['title'];
     $title_label = $form_state->getValue('title_label');
     // Update workflow options.
     // @todo Make it possible to get default values without an entity.
     //   https://www.drupal.org/node/2318187
     $node = $this->entityManager->getStorage('log')->create(array('type' => $type->id()));
     $this->entityManager->clearCachedFieldDefinitions();
     $form_state->setRedirectUrl($type->urlInfo('collection'));
 }
開發者ID:eiriksm,項目名稱:log,代碼行數:29,代碼來源:LogTypeForm.php

示例3: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $type = $this->entity;
     $type->setNewRevision($form_state->getValue(array('options', 'revision')));
     $type->type = trim($type->id());
     $type->name = trim($type->name);
     $status = $type->save();
     $t_args = array('%name' => $type->label());
     if ($status == SAVED_UPDATED) {
         drupal_set_message(t('The content type %name has been updated.', $t_args));
     } elseif ($status == SAVED_NEW) {
         drupal_set_message(t('The content type %name has been added.', $t_args));
         $context = array_merge($t_args, array('link' => $this->l(t('View'), new Url('node.overview_types'))));
         $this->logger('node')->notice('Added content type %name.', $context);
     }
     $fields = $this->entityManager->getFieldDefinitions('node', $type->id());
     // Update title field definition.
     $title_field = $fields['title'];
     $title_label = $form_state->getValue('title_label');
     if ($title_field->getLabel() != $title_label) {
         $title_field->getConfig($type->id())->setLabel($title_label)->save();
     }
     // Update workflow options.
     // @todo Make it possible to get default values without an entity.
     //   https://www.drupal.org/node/2318187
     $node = $this->entityManager->getStorage('node')->create(array('type' => $type->id()));
     foreach (array('status', 'promote', 'sticky') as $field_name) {
         $value = (bool) $form_state->getValue(['options', $field_name]);
         if ($node->{$field_name}->value != $value) {
             $fields[$field_name]->getConfig($type->id())->setDefaultValue($value)->save();
         }
     }
     $this->entityManager->clearCachedFieldDefinitions();
     $form_state->setRedirect('node.overview_types');
 }
開發者ID:davidsoloman,項目名稱:drupalconsole.com,代碼行數:38,代碼來源:NodeTypeForm.php

示例4: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $type = $this->entity;
     $type->type = trim($type->id());
     $type->name = trim($type->name);
     $status = $type->save();
     $t_args = array('%name' => $type->label());
     if ($status == SAVED_UPDATED) {
         drupal_set_message(t('The entity bundle %name has been updated.', $t_args));
     } elseif ($status == SAVED_NEW) {
         drupal_set_message(t('The entity bundle %name has been added.', $t_args));
         $context = array_merge($t_args, array('link' => $this->l(t('View'), new Url('eck.entity.' . $type->getEntityType()->getBundleOf() . '_type.list'))));
         $this->logger($this->entity->getEntityTypeId())->notice('Added entity bundle %name.', $context);
     }
     $fields = $this->entityManager->getFieldDefinitions($type->getEntityType()->getBundleOf(), $type->id());
     // Update title field definition.
     $title_field = $fields['title'];
     $title_label = $form_state->getValue('title_label');
     if ($title_field->getLabel() != $title_label) {
         $title_field->getConfig($type->id())->setLabel($title_label)->save();
     }
     // Update workflow options.
     // @todo Make it possible to get default values without an entity.
     //   https://www.drupal.org/node/2318187
     $node = $this->entityManager->getStorage($type->getEntityType()->getBundleOf())->create(array('type' => $type->id()));
     $this->entityManager->clearCachedFieldDefinitions();
     $form_state->setRedirect('eck.entity.' . $type->getEntityType()->getBundleOf() . '_type.list');
 }
開發者ID:jokas,項目名稱:d8.dev,代碼行數:31,代碼來源:EckEntityBundleForm.php

示例5: submitForm

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);

    $values = $form_state->getValues();
    $this->config('ds.settings')
      ->set('field_template', $values['fs1']['field_template'])
      ->set('ft-default', $values['fs1']['ft-default'])
      ->set('ft-show-colon', $values['fs1']['ft-show-colon'])
      ->save();

    $this->entityManager->clearCachedFieldDefinitions();
    $this->moduleHandler->resetImplementations();
    $this->themeRegistry->reset();
    $this->routeBuilder->setRebuildNeeded();

    \Drupal::cache('render')->deleteAll();
  }
開發者ID:jkyto,項目名稱:agolf,代碼行數:20,代碼來源:SettingsForm.php

示例6: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $entity_types = '';
     $values = $form_state->getValues();
     $input_values = $form_state->getUserInput();
     $config = $this->config('sharethis.settings');
     // If the location change to/from 'content', clear the Field Info cache.
     $current_location = $config->get('location');
     $new_location = $values['location'];
     if (($current_location == 'content' || $new_location == 'content') && $current_location != $new_location) {
         $this->entityManager->clearCachedFieldDefinitions();
     }
     $entity_info = \Drupal::entityManager()->getAllBundleInfo('node');
     if (isset($entity_info['node'])) {
         $entity_types = $entity_info['node'];
     }
     $config->set('button_option', $values['button_option'])->set('service_option', $values['service_option'])->set('option_extras', $values['option_extras'])->set('callesi', $values['callesi'])->set('location', $values['location'])->set('node_types', $input_values['node_types'])->set('comments', $values['comments'])->set('weight', $values['weight'])->set('publisherID', $values['publisherID'])->set('late_load', $values['late_load'])->set('twitter_suffix', $values['twitter_suffix'])->set('twitter_handle', $values['twitter_handle'])->set('twitter_recommends', $values['twitter_recommends'])->set('option_onhover', $values['option_onhover'])->set('option_neworzero', $values['option_neworzero'])->set('option_shorten', $values['option_shorten'])->set('cns.donotcopy', $input_values['cns']['donotcopy'])->set('cns.hashaddress', $input_values['cns']['hashaddress'])->save();
     if (is_array($entity_types)) {
         foreach ($entity_types as $key => $entity_type) {
             $config->set('sharethisnodes.' . $key, $values[$key . '_options'])->save();
         }
     }
     parent::submitForm($form, $form_state);
 }
開發者ID:nB-MDSO,項目名稱:mdso-d8blog,代碼行數:27,代碼來源:SharethisConfigurationForm.php

示例7: clearCachedFieldDefinitions

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


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