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


PHP LockBackendInterface::release方法代码示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     try {
         $this->lock->release('cron');
         $io->info($this->trans('commands.cron.release.messages.released'));
     } catch (Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
     return 0;
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:16,代码来源:ReleaseCommand.php

示例2: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     // Allow execution to continue even if the request gets cancelled.
     @ignore_user_abort(TRUE);
     // Prevent session information from being saved while cron is running.
     $original_session_saving = $this->sessionManager->isEnabled();
     $this->sessionManager->disable();
     // Force the current user to anonymous to ensure consistent permissions on
     // cron runs.
     $original_user = $this->currentUser->getAccount();
     $this->currentUser->setAccount(new AnonymousUserSession());
     // Try to allocate enough time to run all the hook_cron implementations.
     drupal_set_time_limit(240);
     $return = FALSE;
     // Try to acquire cron lock.
     if (!$this->lock->acquire('cron', 240.0)) {
         // Cron is still running normally.
         watchdog('cron', 'Attempting to re-run cron while it is already running.', array(), WATCHDOG_WARNING);
     } else {
         $this->invokeCronHandlers();
         $this->setCronLastTime();
         // Release cron lock.
         $this->lock->release('cron');
         // Return TRUE so other functions can check if it did run successfully
         $return = TRUE;
     }
     // Process cron queues.
     $this->processQueues();
     // Restore the user.
     $this->currentUser->setAccount($original_user);
     if ($original_session_saving) {
         $this->sessionManager->enable();
     }
     return $return;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:38,代码来源:Cron.php

示例3: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $modules = $input->getArgument('module');
     if (!$this->lock->acquire('cron', 900.0)) {
         $io->warning($this->trans('commands.cron.execute.messages.lock'));
         return 1;
     }
     if (in_array('all', $modules)) {
         $modules = $this->moduleHandler->getImplementations('cron');
     }
     foreach ($modules as $module) {
         if (!$this->moduleHandler->implementsHook($module, 'cron')) {
             $io->warning(sprintf($this->trans('commands.cron.execute.messages.module-invalid'), $module));
             continue;
         }
         try {
             $io->info(sprintf($this->trans('commands.cron.execute.messages.executing-cron'), $module));
             $this->moduleHandler->invoke($module, 'cron');
         } catch (\Exception $e) {
             watchdog_exception('cron', $e);
             $io->error($e->getMessage());
         }
     }
     $this->state->set('system.cron_last', REQUEST_TIME);
     $this->lock->release('cron');
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
     $io->success($this->trans('commands.cron.execute.messages.success'));
     return 0;
 }
开发者ID:ddrozdik,项目名称:DrupalConsole,代码行数:33,代码来源:ExecuteCommand.php

示例4: rebuild

 /**
  * {@inheritdoc}
  */
 public function rebuild()
 {
     if ($this->building) {
         throw new \RuntimeException('Recursive router rebuild detected.');
     }
     if (!$this->lock->acquire('router_rebuild')) {
         // Wait for another request that is already doing this work.
         // We choose to block here since otherwise the routes might not be
         // available, resulting in a 404.
         $this->lock->wait('router_rebuild');
         return FALSE;
     }
     $this->building = TRUE;
     $collection = new RouteCollection();
     foreach ($this->getRouteDefinitions() as $routes) {
         // The top-level 'routes_callback' is a list of methods in controller
         // syntax, see \Drupal\Core\Controller\ControllerResolver. These methods
         // should return a set of \Symfony\Component\Routing\Route objects, either
         // in an associative array keyed by the route name, which will be iterated
         // over and added to the collection for this provider, or as a new
         // \Symfony\Component\Routing\RouteCollection object, which will be added
         // to the collection.
         if (isset($routes['route_callbacks'])) {
             foreach ($routes['route_callbacks'] as $route_callback) {
                 $callback = $this->controllerResolver->getControllerFromDefinition($route_callback);
                 if ($callback_routes = call_user_func($callback)) {
                     // If a RouteCollection is returned, add the whole collection.
                     if ($callback_routes instanceof RouteCollection) {
                         $collection->addCollection($callback_routes);
                     } else {
                         foreach ($callback_routes as $name => $callback_route) {
                             $collection->add($name, $callback_route);
                         }
                     }
                 }
             }
             unset($routes['route_callbacks']);
         }
         foreach ($routes as $name => $route_info) {
             $route_info += array('defaults' => array(), 'requirements' => array(), 'options' => array());
             $route = new Route($route_info['path'], $route_info['defaults'], $route_info['requirements'], $route_info['options']);
             $collection->add($name, $route);
         }
     }
     // DYNAMIC is supposed to be used to add new routes based upon all the
     // static defined ones.
     $this->dispatcher->dispatch(RoutingEvents::DYNAMIC, new RouteBuildEvent($collection));
     // ALTER is the final step to alter all the existing routes. We cannot stop
     // people from adding new routes here, but we define two separate steps to
     // make it clear.
     $this->dispatcher->dispatch(RoutingEvents::ALTER, new RouteBuildEvent($collection));
     $this->checkProvider->setChecks($collection);
     $this->dumper->addRoutes($collection);
     $this->dumper->dump();
     $this->lock->release('router_rebuild');
     $this->dispatcher->dispatch(RoutingEvents::FINISHED, new Event());
     $this->building = FALSE;
     $this->rebuildNeeded = FALSE;
     return TRUE;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:63,代码来源:RouteBuilder.php

示例5: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     // Allow execution to continue even if the request gets cancelled.
     @ignore_user_abort(TRUE);
     // Force the current user to anonymous to ensure consistent permissions on
     // cron runs.
     $this->accountSwitcher->switchTo(new AnonymousUserSession());
     // Try to allocate enough time to run all the hook_cron implementations.
     drupal_set_time_limit(240);
     $return = FALSE;
     // Try to acquire cron lock.
     if (!$this->lock->acquire('cron', 900.0)) {
         // Cron is still running normally.
         $this->logger->warning('Attempting to re-run cron while it is already running.');
     } else {
         $this->invokeCronHandlers();
         $this->setCronLastTime();
         // Release cron lock.
         $this->lock->release('cron');
         // Return TRUE so other functions can check if it did run successfully
         $return = TRUE;
     }
     // Process cron queues.
     $this->processQueues();
     // Restore the user.
     $this->accountSwitcher->switchBack();
     return $return;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:31,代码来源:Cron.php

示例6: execute

 /**
  * Executes a callback.
  *
  * @param \Drupal\feeds\FeedInterface $feeds_feed
  *   The Feed we are executing a job for.
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The request object to grab POST params from.
  *
  * @todo Configure a time limit.
  * @todo Really awesome error handling.
  */
 public function execute(FeedInterface $feeds_feed, Request $request)
 {
     $cid = 'feeds_feed:' . $feeds_feed->id();
     if ($token = $request->request->get('token') && ($job = $this->state->get($cid))) {
         if ($job['token'] == $token && ($lock = $this->lockBackend->acquire($cid))) {
             $method = $job['method'];
             $this->state->delete($cid);
             ignore_user_abort(TRUE);
             set_time_limit(0);
             while ($feeds_feed->{$method}() != StateInterface::BATCH_COMPLETE) {
                 // Reset static caches in between runs to avoid memory leaks.
                 drupal_reset_static();
             }
             $this->lockBackend->release($cid);
         }
     }
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:28,代码来源:JobController.php

示例7: finish

 /**
  * Finishes the batch.
  *
  * @param array $context.
  *   The batch context.
  */
 protected function finish(array &$context)
 {
     $this->eventDispatcher->dispatch(ConfigEvents::IMPORT, new ConfigImporterEvent($this));
     // The import is now complete.
     $this->lock->release(static::LOCK_NAME);
     $this->reset();
     $context['message'] = t('Finalizing configuration synchronization.');
     $context['finished'] = 1;
 }
开发者ID:brstde,项目名称:gap1,代码行数:15,代码来源:ConfigImporter.php

示例8: lockAcquire

 /**
  * Try to acquire a named lock and report the outcome.
  */
 public function lockAcquire()
 {
     if ($this->lock->acquire('system_test_lock_acquire')) {
         $this->lock->release('system_test_lock_acquire');
         return ['#markup' => 'TRUE: Lock successfully acquired in \\Drupal\\system_test\\Controller\\SystemTestController::lockAcquire()'];
     } else {
         return ['#markup' => 'FALSE: Lock not acquired in \\Drupal\\system_test\\Controller\\SystemTestController::lockAcquire()'];
     }
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:12,代码来源:SystemTestController.php

示例9: getMails

 /**
  * {@inheritdoc}
  */
 public function getMails($limit = self::UNLIMITED, $conditions = array())
 {
     $messages = array();
     // Continue to support 'nid' as a condition.
     if (!empty($conditions['nid'])) {
         $conditions['entity_type'] = 'node';
         $conditions['entity_id'] = $conditions['nid'];
         unset($conditions['nid']);
     }
     // Add default status condition if not set.
     if (!isset($conditions['status'])) {
         $conditions['status'] = array(SpoolStorageInterface::STATUS_PENDING, SpoolStorageInterface::STATUS_IN_PROGRESS);
     }
     // Special case for the status condition, the in progress actually only
     // includes spool items whose locking time has expired. So this need to build
     // an OR condition for them.
     $status_or = new Condition('OR');
     $statuses = is_array($conditions['status']) ? $conditions['status'] : array($conditions['status']);
     foreach ($statuses as $status) {
         if ($status == SpoolStorageInterface::STATUS_IN_PROGRESS) {
             $status_or->condition((new Condition('AND'))->condition('status', $status)->condition('s.timestamp', $this->getExpirationTime(), '<'));
         } else {
             $status_or->condition('status', $status);
         }
     }
     unset($conditions['status']);
     $query = $this->connection->select('simplenews_mail_spool', 's')->fields('s')->condition($status_or)->orderBy('s.timestamp', 'ASC');
     // Add conditions.
     foreach ($conditions as $field => $value) {
         $query->condition($field, $value);
     }
     /* BEGIN CRITICAL SECTION */
     // The semaphore ensures that multiple processes get different message ID's,
     // so that duplicate messages are not sent.
     if ($this->lock->acquire('simplenews_acquire_mail')) {
         // Get message id's
         // Allocate messages
         if ($limit > 0) {
             $query->range(0, $limit);
         }
         foreach ($query->execute() as $message) {
             if (Unicode::strlen($message->data)) {
                 $message->data = unserialize($message->data);
             } else {
                 $message->data = simplenews_subscriber_load_by_mail($message->mail);
             }
             $messages[$message->msid] = $message;
         }
         if (count($messages) > 0) {
             // Set the state and the timestamp of the messages
             $this->updateMails(array_keys($messages), array('status' => SpoolStorageInterface::STATUS_IN_PROGRESS));
         }
         $this->lock->release('simplenews_acquire_mail');
     }
     /* END CRITICAL SECTION */
     return new SpoolList($messages);
 }
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:60,代码来源:SpoolStorage.php

示例10: delete

 /**
  * Deletes data from the store for a given key and releases the lock on it.
  *
  * @param string $key
  *   The key of the data to delete.
  */
 public function delete($key)
 {
     if (!$this->lockBackend->acquire($key)) {
         $this->lockBackend->wait($key);
         if (!$this->lockBackend->acquire($key)) {
             throw new TempStoreException("Couldn't acquire lock to delete item '{$key}' from {$this->storage->getCollectionName()} temporary storage.");
         }
     }
     $this->storage->delete($key);
     $this->lockBackend->release($key);
 }
开发者ID:318io,项目名称:318-io,代码行数:17,代码来源:SharedTempStore.php

示例11: delete

 /**
  * Deletes data from the store for a given key and releases the lock on it.
  *
  * @param string $key
  *   The key of the data to delete.
  */
 public function delete($key)
 {
     if (!$this->lockBackend->acquire($key)) {
         $this->lockBackend->wait($key);
         if (!$this->lockBackend->acquire($key)) {
             throw new TempStoreException(String::format("Couldn't acquire lock to delete item %key from %collection temporary storage.", array('%key' => $key, '%collection' => $this->storage->getCollectionName())));
         }
     }
     $this->storage->delete($key);
     $this->lockBackend->release($key);
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:17,代码来源:SharedTempStore.php

示例12: menuLinksRebuild

 /**
  * Perform menu-specific rebuilding.
  */
 protected function menuLinksRebuild()
 {
     if ($this->lock->acquire(__FUNCTION__)) {
         $transaction = db_transaction();
         try {
             // Ensure the menu links are up to date.
             $this->menuLinkManager->rebuild();
             // Ignore any database replicas temporarily.
             db_ignore_replica();
         } catch (\Exception $e) {
             $transaction->rollback();
             watchdog_exception('menu', $e);
         }
         $this->lock->release(__FUNCTION__);
     } else {
         // Wait for another request that is already doing this work.
         // We choose to block here since otherwise the router item may not
         // be available during routing resulting in a 404.
         $this->lock->wait(__FUNCTION__);
     }
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:24,代码来源:MenuRouterRebuildSubscriber.php

示例13: menuLinksRebuild

 /**
  * Perform menu-specific rebuilding.
  */
 protected function menuLinksRebuild()
 {
     if ($this->lock->acquire(__FUNCTION__)) {
         $transaction = db_transaction();
         try {
             // Ensure the menu links are up to date.
             menu_link_rebuild_defaults();
             // Clear the menu cache.
             menu_cache_clear_all();
             // Track which menu items are expanded.
             _menu_update_expanded_menus();
         } catch (\Exception $e) {
             $transaction->rollback();
             watchdog_exception('menu', $e);
         }
         $this->lock->release(__FUNCTION__);
     } else {
         // Wait for another request that is already doing this work.
         // We choose to block here since otherwise the router item may not
         // be available during routing resulting in a 404.
         $this->lock->wait(__FUNCTION__);
     }
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:26,代码来源:RouterRebuildSubscriber.php

示例14: delete

 /**
  * Deletes data from the store for a given key and releases the lock on it.
  *
  * @param string $key
  *   The key of the data to delete.
  *
  * @return bool
  *   TRUE if the object was deleted or does not exist, FALSE if it exists but
  *   is not owned by $this->owner.
  */
 public function delete($key)
 {
     $key = $this->createkey($key);
     if (!($object = $this->storage->get($key))) {
         return TRUE;
     } elseif ($object->owner != $this->getOwner()) {
         return FALSE;
     }
     if (!$this->lockBackend->acquire($key)) {
         $this->lockBackend->wait($key);
         if (!$this->lockBackend->acquire($key)) {
             throw new TempStoreException("Couldn't acquire lock to delete item '{$key}' from '{$this->storage->getCollectionName()}' temporary storage.");
         }
     }
     $this->storage->delete($key);
     $this->lockBackend->release($key);
     return TRUE;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:28,代码来源:PrivateTempStore.php

示例15: delete

 /**
  * Deletes data from the store for a given key and releases the lock on it.
  *
  * @param string $key
  *   The key of the data to delete.
  *
  * @return bool
  *   TRUE if the object was deleted or does not exist, FALSE if it exists but
  *   is not owned by $this->owner.
  */
 public function delete($key)
 {
     $key = $this->createkey($key);
     if (!($object = $this->storage->get($key))) {
         return TRUE;
     } elseif ($object->owner != $this->getOwner()) {
         return FALSE;
     }
     if (!$this->lockBackend->acquire($key)) {
         $this->lockBackend->wait($key);
         if (!$this->lockBackend->acquire($key)) {
             throw new TempStoreException(SafeMarkup::format("Couldn't acquire lock to delete item %key from %collection temporary storage.", array('%key' => $key, '%collection' => $this->storage->getCollectionName())));
         }
     }
     $this->storage->delete($key);
     $this->lockBackend->release($key);
     return TRUE;
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:28,代码来源:PrivateTempStore.php


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