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


PHP StateInterface::delete方法代码示例

本文整理汇总了PHP中Drupal\Core\State\StateInterface::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP StateInterface::delete方法的具体用法?PHP StateInterface::delete怎么用?PHP StateInterface::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\State\StateInterface的用法示例。


在下文中一共展示了StateInterface::delete方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: stopTracking

 /**
  * {@inheritdoc}
  */
 public function stopTracking(IndexInterface $index, array $datasource_ids = NULL)
 {
     $valid_tracker = $index->hasValidTracker();
     if (!isset($datasource_ids)) {
         $this->state->delete($this->getIndexStateKey($index));
         if ($valid_tracker) {
             $index->getTrackerInstance()->trackAllItemsDeleted();
         }
         return;
     }
     // Catch the case of being called with an empty array of datasources.
     if (!$datasource_ids) {
         return;
     }
     // If no state is saved, this will return NULL, making the following unset()
     // statements no-ops.
     $index_state = $this->getIndexState($index, FALSE);
     foreach ($datasource_ids as $datasource_id) {
         unset($index_state['pages'][$datasource_id]);
         if ($valid_tracker) {
             $index->getTrackerInstance()->trackAllItemsDeleted($datasource_id);
         }
     }
     // If we had an index state saved, update it now.
     if (isset($index_state)) {
         if (empty($index_state['pages'])) {
             $this->state->delete($this->getIndexStateKey($index));
         } else {
             $this->state->set($this->getIndexStateKey($index), $index_state);
         }
     }
 }
开发者ID:curveagency,项目名称:intranet,代码行数:35,代码来源:IndexTaskManager.php

示例2: handleResetSession

 /**
  * Utility submit function to reset the demo.
  *
  * @param array $form
  *   FormAPI form.
  * @param FormStateInterface $form_state
  *   FormAPI form state.
  *
  * @todo Note this does NOT clear any managed file references in Drupal's DB.
  *       It might be a good idea to add this.
  */
 public function handleResetSession(array &$form, FormStateInterface $form_state)
 {
     $this->state->delete('file_example_default_file');
     $this->state->delete('file_example_default_directory');
     $this->clearStoredData();
     drupal_set_message('Session reset.');
 }
开发者ID:alexburrows,项目名称:cream-2.x,代码行数:18,代码来源:FileExampleReadWriteForm.php

示例3: getCalledServerMethods

 /**
  * Retrieves the methods called on the test server.
  *
  * @param bool $reset
  *   (optional) Whether to reset the list after the called methods are
  *   retrieved.
  *
  * @return string[]
  *   The methods called on the test server since the last reset.
  */
 protected function getCalledServerMethods($reset = TRUE) {
   $key = 'search_api_test_backend.methods_called.' . $this->server->id();
   $methods_called = $this->state->get($key, array());
   if ($reset) {
     $this->state->delete($key);
   }
   return $methods_called;
 }
开发者ID:jkyto,项目名称:agolf,代码行数:18,代码来源:ServerTaskUnitTest.php

示例4: deleteAll

 /**
  * {@inheritdoc}
  */
 public function deleteAll()
 {
     $this->state->delete('drupal_css_cache_files');
     $delete_stale = function ($uri) {
         // Default stale file threshold is 30 days.
         if (REQUEST_TIME - filemtime($uri) > \Drupal::config('system.performance')->get('stale_file_threshold')) {
             file_unmanaged_delete($uri);
         }
     };
     file_scan_directory('public://css', '/.*/', array('callback' => $delete_stale));
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:14,代码来源:CssCollectionOptimizer.php

示例5: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $name = $input->getArgument('name');
     if (!$name) {
         $io->error($this->trans('commands.state.delete.messages.enter-name'));
         return 1;
     }
     if (!$this->state->get($name)) {
         $io->error(sprintf($this->trans('commands.state.delete.messages.state-not-exists'), $name));
         return 1;
     }
     try {
         $this->state->delete($name);
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     $io->success(sprintf($this->trans('commands.state.delete.messages.deleted'), $name));
     return 0;
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:24,代码来源:DeleteCommand.php

示例6: submitConfirmForm

 /**
  * Submission handler for the confirmation form.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 public function submitConfirmForm(array &$form, FormStateInterface $form_state)
 {
     $storage = $form_state->getStorage();
     if (isset($storage['upgrade_option']) && $storage['upgrade_option'] == static::MIGRATE_UPGRADE_ROLLBACK) {
         $query = $this->entityStorage->getQuery();
         $names = $query->execute();
         // Order the migrations according to their dependencies.
         /** @var \Drupal\migrate\Entity\MigrationInterface[] $migrations */
         $migrations = $this->entityStorage->loadMultiple($names);
         // Assume we want all those tagged 'Drupal %'.
         foreach ($migrations as $migration_id => $migration) {
             $keep = FALSE;
             $tags = $migration->get('migration_tags');
             foreach ($tags as $tag) {
                 if (strpos($tag, 'Drupal ') === 0) {
                     $keep = TRUE;
                     break;
                 }
             }
             if (!$keep) {
                 unset($migrations[$migration_id]);
             }
         }
         // Roll back in reverse order.
         $migrations = array_reverse($migrations);
         $batch = ['title' => $this->t('Rolling back upgrade'), 'progress_message' => '', 'operations' => [[[MigrateUpgradeRunBatch::class, 'run'], [array_keys($migrations), 'rollback']]], 'finished' => [MigrateUpgradeRunBatch::class, 'finished']];
         batch_set($batch);
         $form_state->setRedirect('migrate_upgrade.upgrade');
         $this->state->delete('migrate_upgrade.performed');
     } else {
         $migration_template = $storage['migration_template'];
         $migration_ids = $this->createMigrations($migration_template);
         $batch = ['title' => $this->t('Running upgrade'), 'progress_message' => '', 'operations' => [[[MigrateUpgradeRunBatch::class, 'run'], [$migration_ids, 'import']]], 'finished' => [MigrateUpgradeRunBatch::class, 'finished']];
         batch_set($batch);
         $form_state->setRedirect('<front>');
         $this->state->set('migrate_upgrade.performed', REQUEST_TIME);
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:46,代码来源:MigrateUpgradeForm.php

示例7: delete

 /**
  * {@inheritdoc}
  */
 public function delete($key)
 {
     $this->state->delete($key);
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:7,代码来源:StateWrapper.php


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