本文整理匯總了PHP中Drupal\Core\Entity\ContentEntityForm::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContentEntityForm::init方法的具體用法?PHP ContentEntityForm::init怎麽用?PHP ContentEntityForm::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Entity\ContentEntityForm
的用法示例。
在下文中一共展示了ContentEntityForm::init方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
/**
* {@inheritdoc}
*/
protected function init(FormStateInterface $form_state)
{
$comment = $this->entity;
// Make the comment inherit the current content language unless specifically
// set.
if ($comment->isNew()) {
$language_content = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT);
$comment->langcode->value = $language_content->getId();
}
parent::init($form_state);
}
示例2: init
/**
* {@inheritdoc}
*/
protected function init(array &$form_state)
{
$message = $this->entity;
// Make the message inherit the current content language unless specifically
// set.
if ($message->isNew() && !$message->langcode->value) {
$language_content = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT);
$message->langcode->value = $language_content->id;
}
parent::init($form_state);
}