本文整理汇总了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);
}
}
}
示例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.');
}
示例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;
}
示例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));
}
示例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;
}
示例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);
}
}
示例7: delete
/**
* {@inheritdoc}
*/
public function delete($key)
{
$this->state->delete($key);
}