本文整理汇总了PHP中Drupal\Core\Entity\ContentEntityBase::preCreate方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentEntityBase::preCreate方法的具体用法?PHP ContentEntityBase::preCreate怎么用?PHP ContentEntityBase::preCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\ContentEntityBase
的用法示例。
在下文中一共展示了ContentEntityBase::preCreate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preCreate
/**
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage, array &$values)
{
parent::preCreate($storage, $values);
if (empty($values['type'])) {
$values['type'] = $storage->getEntityTypeId();
}
}
示例2: preCreate
/**
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values)
{
parent::preCreate($storage_controller, $values);
$values += array('user_id' => \Drupal::currentUser()->id());
if (isset($values['issue_type'])) {
$values['issue_type'] = \Drupal::service('checkstyle.issue.nodemapper')->getCheckstyleTypeId($values['issue_type']);
}
return FALSE;
}
示例3: preCreate
/**
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += array(
'user_id' => \Drupal::currentUser()->id(),
);
}
示例4: preCreate
/**
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage, array &$values)
{
parent::preCreate($storage, $values);
if (!isset($values['shortcut_set'])) {
$values['shortcut_set'] = 'default';
}
}
示例5: preCreate
/**
* {@inheritdoc}
*
* @todo Remove once https://drupal.org/node/1979260 is done.
*/
public static function preCreate(EntityStorageInterface $storage, array &$values)
{
parent::preCreate($storage, $values);
$account = \Drupal::currentUser();
// Set user id of contact owner.
$values += array('uid' => $account->id());
}
示例6: preCreate
/**
* {@inheritdoc}
*/
static function preCreate(EntityStorageInterface $storage, array &$values)
{
parent::preCreate($storage, $values);
// Users always have the authenticated user role.
$values['roles'][] = DRUPAL_AUTHENTICATED_RID;
}
示例7: preCreate
/**
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage, array &$values)
{
parent::preCreate($storage, $values);
// Set default values.
$store_config = \Drupal::config('uc_store.settings');
$values += ['order_status' => uc_order_state_default('in_checkout'), 'currency' => $store_config->get('currency.code'), 'billing_country' => $store_config->get('address.country'), 'delivery_country' => $store_config->get('address.country'), 'created' => REQUEST_TIME];
// Take the primary email address from the user, if necessary.
if (empty($values['primary_email']) && !empty($values['uid'])) {
if ($account = User::load($values['uid'])) {
$values['primary_email'] = $account->getEmail();
}
}
}