本文整理匯總了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();
}
}
}