當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。