本文整理汇总了PHP中Drupal\Core\Entity\EntityStorageInterface::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityStorageInterface::delete方法的具体用法?PHP EntityStorageInterface::delete怎么用?PHP EntityStorageInterface::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityStorageInterface
的用法示例。
在下文中一共展示了EntityStorageInterface::delete方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateElements
/**
* {@inheritdoc}
*/
protected function generateElements(array $values)
{
$num = $values['num'];
$kill = $values['kill'];
$pass = $values['pass'];
$age = $values['time_range'];
$roles = array_filter($values['roles']);
if ($kill) {
$uids = $this->userStorage->getQuery()->condition('uid', 1, '>')->execute();
$users = $this->userStorage->loadMultiple($uids);
$this->userStorage->delete($users);
$this->setMessage($this->formatPlural(count($uids), '1 user deleted', '@count users deleted.'));
}
if ($num > 0) {
$names = array();
while (count($names) < $num) {
$name = $this->getRandom()->word(mt_rand(6, 12));
$names[$name] = '';
}
if (empty($roles)) {
$roles = array(DRUPAL_AUTHENTICATED_RID);
}
foreach ($names as $name => $value) {
$account = $this->userStorage->create(array('uid' => NULL, 'name' => $name, 'pass' => $pass, 'mail' => $name . '@example.com', 'status' => 1, 'created' => REQUEST_TIME - mt_rand(0, $age), 'roles' => array_values($roles), 'devel_generate' => TRUE));
// Populate all fields with sample values.
$this->populateFields($account);
$account->save();
}
}
$this->setMessage($this->t('@num_users created.', array('@num_users' => $this->formatPlural($num, '1 user', '@count users'))));
}
示例2: contentKill
/**
* Deletes all products.
*/
protected function contentKill()
{
$pids = $this->productStorage->getQuery()->execute();
if (!empty($pids)) {
$products = $this->productStorage->loadMultiple($pids);
$this->productStorage->delete($products);
$this->setMessage($this->t('Deleted %count products.', array('%count' => count($pids))));
}
}
示例3: contentKill
/**
* Deletes all nodes of given node types.
*
* @param array $values
* The input values from the settings form.
*/
protected function contentKill($values)
{
$nids = $this->nodeStorage->getQuery()->condition('type', $values['node_types'], 'IN')->execute();
if (!empty($nids)) {
$nodes = $this->nodeStorage->loadMultiple($nids);
$this->nodeStorage->delete($nodes);
$this->setMessage($this->t('Deleted %count nodes.', array('%count' => count($nids))));
}
}
示例4: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($form_state->getValue('confirm') && !empty($this->messages)) {
$this->storage->delete($this->messages);
$this->privateTempStoreFactory->get('message_multiple_delete_confirm')->delete($this->account->id());
$count = count($this->messages);
$this->logger('contact')->notice('Deleted @count messages.', ['@count' => $count]);
drupal_set_message($this->stringTranslation->formatPlural($count, 'Deleted 1 message.', 'Deleted @count messages.'));
}
$form_state->setRedirect('entity.contact_message.collection');
}
示例5: deleteMenus
/**
* Deletes custom generated menus.
*/
protected function deleteMenus()
{
if ($this->moduleHandler->moduleExists('menu_ui')) {
$menu_ids = array();
foreach (menu_ui_get_menus(FALSE) as $menu => $menu_title) {
if (strpos($menu, 'devel-') === 0) {
$menu_ids[] = $menu;
}
}
if ($menu_ids) {
$menus = $this->menuStorage->loadMultiple($menu_ids);
$this->menuStorage->delete($menus);
}
}
// Delete menu links generated by devel.
$link_ids = $this->menuLinkContentStorage->getQuery()->condition('menu_name', 'devel', '<>')->condition('link__options', '%' . db_like('s:5:"devel";b:1') . '%', 'LIKE')->execute();
if ($link_ids) {
$links = $this->menuLinkContentStorage->loadMultiple($link_ids);
$this->menuLinkContentStorage->delete($links);
}
}
示例6: execute
public function execute($object = NULL) {
$this->entityStorage->delete([$object]);
}
示例7: deleteVocabularies
/**
* Deletes all vocabularies.
*/
protected function deleteVocabularies()
{
$vocabularies = $this->vocabularyStorage->loadMultiple();
$this->vocabularyStorage->delete($vocabularies);
}
示例8: entityDeleteMultiple
/**
* {@inheritdoc}
*/
protected function entityDeleteMultiple(array $entity_ids)
{
$entities = $this->storageController->loadMultiple($entity_ids);
$this->storageController->delete($entities);
}
示例9: emptyOldStorage
/**
* {@inheritdoc}
*/
public function emptyOldStorage(EntityTypeInterface $entity_type, EntityStorageInterface $storage)
{
$entities = $storage->loadMultiple();
if ($entities) {
$storage->delete($entities);
}
return $this;
}
示例10: deleteVocabularyTerms
/**
* Deletes all terms of given vocabularies.
*
* @param array $vids
* Array of vocabulary vid.
*/
protected function deleteVocabularyTerms($vids)
{
$tids = $this->vocabularyStorage->getToplevelTids($vids);
$terms = $this->termStorage->loadMultiple($tids);
$this->termStorage->delete($terms);
}