本文整理汇总了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'));
}
示例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'));
}
示例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');
}
示例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');
}
示例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();
}
示例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);
}
示例7: clearCachedFieldDefinitions
/**
* {@inheritdoc}
*/
public function clearCachedFieldDefinitions()
{
$this->entityManager->clearCachedFieldDefinitions();
}