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


PHP ServiceUtil::setContainer方法代码示例

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


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

示例1: find

 /**
  * Load routes of the specified module from the module's configuration file.
  *
  * @param AbstractBundle $bundle
  *
  * @return RouteCollection[]
  */
 private function find(AbstractBundle $bundle)
 {
     if (!\ServiceUtil::hasContainer()) {
         \ServiceUtil::setContainer($this->container);
     }
     try {
         $path = $this->zikulaKernel->locateResource($bundle->getRoutingConfig());
     } catch (\InvalidArgumentException $e) {
         // Routing file does not exist (e.g. because the bundle could not be located).
         return [new RouteCollection(), new RouteCollection(), new RouteCollection()];
     }
     $name = $bundle->getName();
     $topRouteCollection = new RouteCollection();
     $middleRouteCollection = new RouteCollection();
     $bottomRouteCollection = new RouteCollection();
     /**
      * These are all routes of the module, as loaded by Symfony.
      * @var RouteCollection $routeCollection
      */
     $routeCollection = $this->import($path);
     // Add all resources from the imported route collection to the middleRouteCollection.
     // The actual collection (top, middle, bottom) to add the resources too does not matter,
     // they just must be added to one of them, so that they don't get lost.
     foreach ($routeCollection->getResources() as $resource) {
         $middleRouteCollection->addResource($resource);
     }
     // It would be great to auto-reload routes here if the module version changes or a module is uninstalled.
     // This is not yet possible, see
     // - https://github.com/symfony/symfony/issues/7176
     // - https://github.com/symfony/symfony/pull/15738
     // - https://github.com/symfony/symfony/pull/15692
     // $routeCollection->addResource(new ZikulaResource())
     /** @var Route $route */
     foreach ($routeCollection as $oldRouteName => $route) {
         //          set break here with $oldRouteName == 'zikula_routesmodule_route_renew'
         $this->fixRequirements($route);
         $this->prependBundlePrefix($route, $bundle);
         list($type, $func) = $this->setZikulaDefaults($route, $bundle, $name);
         $routeName = $this->getRouteName($oldRouteName, $name, $type, $func);
         if ($route->hasOption('zkPosition')) {
             switch ($route->getOption('zkPosition')) {
                 case 'top':
                     $topRouteCollection->add($routeName, $route);
                     break;
                 case 'bottom':
                     $bottomRouteCollection->add($routeName, $route);
                     break;
                 default:
                     throw new \RuntimeException('Unknown route position. Got "' . $route->getOption('zkPosition') . '", expected "top" or "bottom"');
             }
         } else {
             $middleRouteCollection->add($routeName, $route);
         }
     }
     return [$middleRouteCollection, $topRouteCollection, $bottomRouteCollection];
 }
开发者ID:Silwereth,项目名称:core,代码行数:63,代码来源:RouteLoader.php

示例2: getPathWithBundlePrefix

 /**
  * Returns the route's path prepended with the bundle prefix.
  *
  * @param null $container Can be used to set the container for \ServiceUtil in case it is not already set.
  *
  * @return string
  */
 public function getPathWithBundlePrefix($container = null)
 {
     if (!isset($this->options['zkNoBundlePrefix']) || !$this->options['zkNoBundlePrefix']) {
         $bundle = $this->getBundle();
         if (!\ServiceUtil::hasContainer()) {
             \ServiceUtil::setContainer($container);
         }
         $modinfo = \ModUtil::getInfoFromName($bundle);
         return "/" . $modinfo["url"] . $this->path;
     }
     return $this->path;
 }
开发者ID:rmaiwald,项目名称:core,代码行数:19,代码来源:RouteEntity.php


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