当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityStorageInterface::delete方法代码示例

本文整理汇总了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'))));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:34,代码来源:UserDevelGenerate.php

示例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))));
     }
 }
开发者ID:OlgaRabodzei,项目名称:commerce_generate,代码行数:12,代码来源:CommerceDevelGenerate.php

示例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))));
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:15,代码来源:ContentDevelGenerate.php

示例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');
  }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:14,代码来源:DeleteMultiple.php

示例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);
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:24,代码来源:MenuDevelGenerate.php

示例6: execute

 public function execute($object = NULL) {
   $this->entityStorage->delete([$object]);
 }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:3,代码来源:DeleteEFormSubmission.php

示例7: deleteVocabularies

 /**
  * Deletes all vocabularies.
  */
 protected function deleteVocabularies()
 {
     $vocabularies = $this->vocabularyStorage->loadMultiple();
     $this->vocabularyStorage->delete($vocabularies);
 }
开发者ID:atif-shaikh,项目名称:DCX-Profile,代码行数:8,代码来源:VocabularyDevelGenerate.php

示例8: entityDeleteMultiple

 /**
  * {@inheritdoc}
  */
 protected function entityDeleteMultiple(array $entity_ids)
 {
     $entities = $this->storageController->loadMultiple($entity_ids);
     $this->storageController->delete($entities);
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:8,代码来源:EntityProcessorBase.php

示例9: emptyOldStorage

 /**
  * {@inheritdoc}
  */
 public function emptyOldStorage(EntityTypeInterface $entity_type, EntityStorageInterface $storage)
 {
     $entities = $storage->loadMultiple();
     if ($entities) {
         $storage->delete($entities);
     }
     return $this;
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:11,代码来源:MultiversionMigration.php

示例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);
 }
开发者ID:ABaldwinHunter,项目名称:durhamatletico-cms,代码行数:12,代码来源:TermDevelGenerate.php


注:本文中的Drupal\Core\Entity\EntityStorageInterface::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。