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


PHP LockBackendInterface::wait方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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


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