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


PHP Application::extend方法代码示例

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


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

示例1: register

 public function register(BaseApplication $app)
 {
     // Routingを追加
     $admin = $app['config']['admin_route'];
     $app->match($admin . '/sales_report', '\\Plugin\\SalesReport\\Controller\\SalesReportController::index')->bind('admin_sales_report');
     $app->match($admin . '/sales_report/term', '\\Plugin\\SalesReport\\Controller\\SalesReportController::term')->bind('admin_sales_report_term');
     $app->match($admin . '/sales_report/member', '\\Plugin\\SalesReport\\Controller\\SalesReportController::member')->bind('admin_sales_report_member');
     $app->match($admin . '/sales_report/age', '\\Plugin\\SalesReport\\Controller\\SalesReportController::age')->bind('admin_sales_report_age');
     $app->match($admin . '/sales_report/product', '\\Plugin\\SalesReport\\Controller\\SalesReportController::product')->bind('admin_sales_report_product');
     // Formの定義
     $app['form.types'] = $app->share($app->extend('form.types', function ($types) use($app) {
         $types[] = new \Plugin\SalesReport\Form\Type\SalesReportType();
         return $types;
     }));
     // Serviceの定義
     $app['eccube.plugin.service.sales_report'] = $app->share(function () use($app) {
         return new \Plugin\SalesReport\Service\SalesReportService($app);
     });
     // サブナビの拡張
     $app['config'] = $app->share($app->extend('config', function ($config) {
         $nav = array('id' => 'admin_sales_report', 'name' => '売上集計', 'has_child' => 'true', 'icon' => 'cb-chart', 'child' => array(array('id' => 'admin_sales_report', 'url' => 'admin_sales_report', 'name' => '期間別集計'), array('id' => 'admin_sales_report_product', 'url' => 'admin_sales_report_product', 'name' => '商品別集計'), array('id' => 'admin_sales_report_age', 'url' => 'admin_sales_report_age', 'name' => '年代別集計')));
         $config['nav'][] = $nav;
         return $config;
     }));
 }
开发者ID:k-yamamura,项目名称:sales-report-plugin,代码行数:25,代码来源:SalesReportServiceProvider.php

示例2: register

 public function register(Application $app)
 {
     $app['controllers_factory'] = function ($app) {
         return new ControllerCollection($app['route_factory']);
     };
     $app['controllers'] = $app->share(function ($app) {
         return new RootControllerCollection($app, $app['dispatcher'], $app['route_factory']);
     });
     $app['url_matcher'] = $app->share(function ($app) {
         return new UrlMatcher($app['routes'], $app['request_context']);
     });
     $app['resolver'] = $app->share(function ($app) {
         return new ControllerResolver($app, $app['logger']);
     });
     $app['callback_resolver'] = $app->share(function ($app) {
         return new CallbackResolver($app, $app['controller.classmap']);
     });
     $app['route_factory'] = $app->extend('route_factory', function (Route $route, $app) {
         if ($app['config']->get('general/enforce_ssl')) {
             $route->requireHttps();
         }
         return $route;
     });
     $app['url_generator'] = $app->share($app->extend('url_generator', function ($urlGenerator) {
         return new UrlGeneratorFragmentWrapper($urlGenerator);
     }));
     $app['url_generator.lazy'] = $app->share(function ($app) {
         return new LazyUrlGenerator(function () use($app) {
             return $app['url_generator'];
         });
     });
 }
开发者ID:d-m-,项目名称:bolt,代码行数:32,代码来源:RoutingServiceProvider.php

示例3: register

 /**
  * {@inheritdoc}
  */
 public function register(Application $app)
 {
     if (isset($app['profiler'])) {
         $app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig) {
             $twig->addExtension(new DoctrineExtension());
             return $twig;
         }));
         $app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function (\Twig_Loader_Filesystem $twigLoaderFilesystem) {
             $twigLoaderFilesystem->addPath(dirname(__DIR__) . '/Resources/views', 'SaxulumWebProfilerProvider');
             return $twigLoaderFilesystem;
         }));
         $dataCollectors = $app['data_collectors'];
         $dataCollectors['db'] = $app->share(function ($app) {
             $dataCollector = new DoctrineDataCollector($app['doctrine']);
             foreach ($app['doctrine']->getConnectionNames() as $name) {
                 $logger = new DbalLogger($app['monolog'], $app['stopwatch']);
                 $app['doctrine']->getConnection($name)->getConfiguration()->setSQLLogger($logger);
                 $dataCollector->addLogger($name, $logger);
             }
             return $dataCollector;
         });
         $app['data_collectors'] = $dataCollectors;
         $dataCollectorTemplates = $app['data_collector.templates'];
         $dataCollectorTemplates[] = array('db', '@SaxulumWebProfilerProvider/Collector/db.html.twig');
         $app['data_collector.templates'] = $dataCollectorTemplates;
     }
 }
开发者ID:ygeneration666,项目名称:ec,代码行数:30,代码来源:SaxulumWebProfilerProvider.php

示例4: register

 /**
  * {@inheritdoc}
  */
 public function register(BaseApplication $app)
 {
     $app['translator']->addResource('yaml', __DIR__ . '/../Resource/locale/message.ja.yml', 'ja');
     $app['config'] = $app->share($app->extend('config', function ($config) {
         foreach ($config['nav'] as $key => $menu1) {
             if ($menu1['id'] == 'setting') {
                 $children = $menu1['child'];
                 foreach ($children as $key2 => $menu2) {
                     if ($menu2['id'] == 'system') {
                         $config['nav'][$key]['child'][$key2]['has_child'] = 'true';
                         $config['nav'][$key]['child'][$key2]['child'][] = array('id' => 'admin_maintenance_manager', 'name' => 'メンテナンス管理', 'url' => 'admin_maintenance_manager');
                         break;
                     }
                 }
             }
         }
         return $config;
     }));
     $app['form.types'] = $app->share($app->extend('form.types', function ($types) use($app) {
         $types[] = new \Plugin\MaintenanceManager\Form\Type\MaintenanceType($app);
         return $types;
     }));
     $app['plg.service.maintenance_manager'] = $app->share(function () use($app) {
         return new \Plugin\MaintenanceManager\Service\MaintenanceManagerService($app);
     });
     $url = '/' . $app["config"]["admin_route"] . '/MaintenanceManager';
     $app->match($url . '/config', '\\Plugin\\MaintenanceManager\\Controller\\ConfigController::index')->bind('admin_maintenance_manager');
     //         $app->match($url . '/enable', '\Plugin\MaintenanceManager\Controller\ConfigController::enable')->bind('admin_maintenance_manager_enable');
     //         $app->match($url . '/disable', '\Plugin\MaintenanceManager\Controller\ConfigController::diable')->bind('admin_maintenance_manager_disable');
 }
开发者ID:shhirose,项目名称:MaintenanceManager,代码行数:33,代码来源:MaintenanceManagerServiceProvider.php

示例5: register

 public function register(Application $app)
 {
     if (!isset($app['profiler'])) {
         $app->register(new Silex\Provider\WebProfilerServiceProvider(), ['profiler.cache_dir' => $app['resources']->getPath('cache/profiler'), 'web_profiler.debug_toolbar.enable' => false]);
     }
     $app->register(new DebugToolbarEnabler());
     $app['data_collector.templates'] = $app->share($app->extend('data_collector.templates', function ($templates) {
         // Set the 'bolt' toolbar item as the first one, and overriding the 'Symfony' one.
         array_unshift($templates, ['bolt', '@BoltProfiler/bolt.html.twig']);
         $templates[] = ['db', '@BoltProfiler/db.html.twig'];
         // Hackishly replace the template for the first toolbar item with our own.
         $templates[1][1] = '@BoltProfiler/config.html.twig';
         return $templates;
     }));
     $app['data_collectors'] = $app->share($app->extend('data_collectors', function ($collectors, $app) {
         // @codingStandardsIgnoreStart
         $collectors['bolt'] = $app->share(function ($app) {
             return new BoltDataCollector($app);
         });
         $collectors['db'] = $app->share(function ($app) {
             return new DatabaseDataCollector($app['db.logger']);
         });
         // @codingStandardsIgnoreEnd
         return $collectors;
     }));
     $app['twig.loader.bolt_filesystem'] = $app->share($app->extend('twig.loader.bolt_filesystem', function ($filesystem) {
         $filesystem->addPath('bolt://app/view/toolbar', 'BoltProfiler');
         return $filesystem;
     }));
     $app['db.logger'] = $app->share(function () {
         return new DebugStack();
     });
 }
开发者ID:bolt,项目名称:bolt,代码行数:33,代码来源:ProfilerServiceProvider.php

示例6: register

 public function register(BaseApplication $app)
 {
     // リポジトリ
     $app['eccube.plugin.product_rank.repository.product_rank'] = $app->share(function () use($app) {
         return new ProductRankRepository($app['orm.em'], $app['orm.em']->getClassMetadata('\\Eccube\\Entity\\ProductCategory'), $app);
     });
     $basePath = '/' . $app["config"]["admin_route"];
     // 一覧
     $app->match($basePath . '/product/product_rank/', '\\Plugin\\ProductRank\\Controller\\ProductRankController::index')->bind('admin_product_product_rank');
     // 一覧:上
     $app->put($basePath . '/product/product_rank/{category_id}/{product_id}/up', '\\Plugin\\ProductRank\\Controller\\ProductRankController::up')->assert('category_id', '\\d+')->assert('product_id', '\\d+')->bind('admin_product_product_rank_up');
     // 一覧:下
     $app->put($basePath . '/product/product_rank/{category_id}/{product_id}/down', '\\Plugin\\ProductRank\\Controller\\ProductRankController::down')->assert('category_id', '\\d+')->assert('product_id', '\\d+')->bind('admin_product_product_rank_down');
     // 一覧:N番目へ移動
     $app->post($basePath . '/product/product_rank/moveRank', '\\Plugin\\ProductRank\\Controller\\ProductRankController::moveRank')->assert('category_id', '\\d+')->assert('product_id', '\\d+')->assert('position', '\\d+')->bind('admin_product_product_rank_move_rank');
     // カテゴリ選択
     $app->match($basePath . '/product/product_rank/{category_id}', '\\Plugin\\ProductRank\\Controller\\ProductRankController::index')->assert('category_id', '\\d+')->bind('admin_product_product_rank_show');
     // メッセージ登録
     $app['translator'] = $app->share($app->extend('translator', function ($translator, \Silex\Application $app) {
         $translator->addLoader('yaml', new \Symfony\Component\Translation\Loader\YamlFileLoader());
         $file = __DIR__ . '/../Resource/locale/message.' . $app['locale'] . '.yml';
         if (file_exists($file)) {
             $translator->addResource('yaml', $file, $app['locale']);
         }
         return $translator;
     }));
     // メニュー登録
     $app['config'] = $app->share($app->extend('config', function ($config) {
         $addNavi['id'] = "product_rank";
         $addNavi['name'] = "商品並び替え";
         $addNavi['url'] = "admin_product_product_rank";
         self::addNavi($config['nav'], $addNavi, array('product'));
         return $config;
     }));
 }
开发者ID:lockontatsuyaito,项目名称:ProductRank-plugin,代码行数:35,代码来源:ProductRankServiceProvider.php

示例7: boot

 public function boot(Application $app)
 {
     $app->before(function () use($app) {
         $app['np.extensions']['debug'] = $app['debug'];
         $app['np.extensions']['admin'] = $app['np.admin'];
         $app['np.extensions']->boot();
         // add template paths for all extensions and blocks
         $app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function ($loader, $app) {
             foreach ($app['np.extensions']->getAll() as $namespace => $extension) {
                 $loader->addPath($extension->getPath(), $namespace);
             }
             foreach ($app['np.extensions']['block_types'] as $blockType) {
                 $loader->addPath($blockType->getPath(), 'block_' . $app['np.slug_helper']->slugify($blockType->name));
             }
             return $loader;
         }));
         // load collected twig functions
         $app['twig'] = $app->share($app->extend('twig', function ($twig, $app) {
             foreach ($app['np.extensions']['twig_extensions'] as $extension) {
                 $twig->addExtension($extension);
             }
             return $twig;
         }));
     });
     $app->after(function (Request $request, Response $response) use($app) {
         if ($response instanceof BinaryFileResponse || !$app['np.extensions']->booted) {
             return;
         }
         $app['np.extensions']->prepareSnippets();
         $response->setContent($app['np.extensions']['snippet_queue']->processAll($app, $response->getContent()));
     });
 }
开发者ID:nodepub,项目名称:core,代码行数:32,代码来源:ExtensionServiceProvider.php

示例8: register

 public function register(Application $app)
 {
     if (!isset($app['db'])) {
         $app->register(new \Silex\Provider\DoctrineServiceProvider(), ['db.options' => $app['config']->get('general/database')]);
     }
     $app['db.config'] = $app->share($app->extend('db.config', function ($config) use($app) {
         $config->setFilterSchemaAssetsExpression($app['schema.tables_filter']);
         return $config;
     }));
     $app['db.doctrine_listener'] = $app->share(function ($app) {
         return new DoctrineListener($app['logger.system'], $app['controller.exception']);
     });
     // For each database connection add this class as an event subscriber
     $app['dbs.event_manager'] = $app->share($app->extend('dbs.event_manager', function ($managers) use($app) {
         /** @var \Pimple $managers */
         foreach ($managers->keys() as $name) {
             /** @var \Doctrine\Common\EventManager $manager */
             $manager = $managers[$name];
             $manager->addEventSubscriber($app['db.doctrine_listener']);
         }
         return $managers;
     }));
     $app['db.query_cache'] = $app->share(function ($app) {
         $cache = $app['config']->get('general/caching/database') == true ? $app['cache'] : new ArrayCache();
         return $cache;
     });
     $app['db.query_cache_profile'] = $app->share(function ($app) {
         $lifetime = $app['config']->get('general/caching/duration') ?: 0;
         return new QueryCacheProfile($lifetime, 'bolt.db', $app['db.query_cache']);
     });
     $app['db'] = $app->share($app->extend('db', function ($db) use($app) {
         $db->setQueryCacheProfile($app['db.query_cache_profile']);
         return $db;
     }));
 }
开发者ID:bolt,项目名称:bolt,代码行数:35,代码来源:DatabaseServiceProvider.php

示例9: boot

 /**
  * Bootstraps the application.
  *
  * This method is called after all services are registered
  * and should be used for "dynamic" configuration (whenever
  * a service must be requested).
  * @param Application $app
  */
 public function boot(Application $app)
 {
     if (php_sapi_name() === 'cli') {
         $app['console.commands'] = $app->extend('console.commands', function ($commands) use($app) {
             $migrationCommands = [new Proxy\DiffCommandProxy(), new Proxy\ExecuteCommandProxy(), new Proxy\GenerateCommandProxy(), new Proxy\LatestCommandProxy(), new Proxy\MigrateCommandProxy(), new Proxy\StatusCommandProxy(), new Proxy\VersionCommandProxy()];
             if (isset($app['migrations.directory'])) {
                 $config = new Configuration($app['db']);
                 $config->setMigrationsDirectory($app['migrations.directory']);
                 $config->setMigrationsNamespace('DocMigrations');
                 $config->setMigrationsTableName('doc_migrations');
                 $config->registerMigrationsFromDirectory($app['migrations.directory']);
                 /** @var AbstractCommand $cmd */
                 foreach ($migrationCommands as $cmd) {
                     $cmd->setMigrationConfiguration($config);
                 }
             }
             return array_merge($commands, $migrationCommands, [new Proxy\ClearMetadataCacheDoctrineCommand(), new Proxy\ClearQueryCacheDoctrineCommand(), new Proxy\ClearResultCacheDoctrineCommand(), new Proxy\ConvertMappingDoctrineCommand(), new Proxy\CreateSchemaDoctrineCommand(), new Proxy\DropSchemaDoctrineCommand(), new Proxy\EnsureProductionSettingsDoctrineCommand(), new Proxy\InfoDoctrineCommand(), new Proxy\RunDqlDoctrineCommand(), new Proxy\RunSqlDoctrineCommand(), new Proxy\UpdateSchemaDoctrineCommand(), new Proxy\UpdateSchemaDoctrineCommand(), new Proxy\ValidateSchemaCommand(), new Proxy\GenProxiesDoctrineCommand(), new CreateDatabaseDoctrineCommand(), new DropDatabaseDoctrineCommand()]);
         });
         if (isset($app['console'])) {
             $app['console'] = $app->share($app->extend('console', function (ConsoleApplication $consoleApplication) use($app) {
                 $helperSet = $consoleApplication->getHelperSet();
                 $helperSet->set(new ManagerRegistryHelper($app['doctrine']), 'doctrine');
                 return $consoleApplication;
             }));
         }
     }
 }
开发者ID:baohx2000,项目名称:doc,代码行数:35,代码来源:DocServiceProvider.php

示例10: register

 public function register(Application $app)
 {
     if (!isset($app['twig'])) {
         $app->register(new \Silex\Provider\TwigServiceProvider());
     }
     // Handlers
     $app['twig.handlers'] = $app->share(function (Application $app) {
         return new \Pimple(['admin' => $app->share(function () use($app) {
             return new AdminHandler($app);
         }), 'array' => $app->share(function () use($app) {
             return new ArrayHandler($app);
         }), 'html' => $app->share(function () use($app) {
             return new HtmlHandler($app);
         }), 'image' => $app->share(function () use($app) {
             return new ImageHandler($app);
         }), 'record' => $app->share(function () use($app) {
             return new RecordHandler($app);
         }), 'text' => $app->share(function () use($app) {
             return new TextHandler($app);
         }), 'user' => $app->share(function () use($app) {
             return new UserHandler($app);
         }), 'utils' => $app->share(function () use($app) {
             return new UtilsHandler($app);
         })]);
     });
     // Add the Bolt Twig Extension.
     $app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig, $app) {
         $twig->addExtension(new TwigExtension($app, $app['twig.handlers'], false));
         return $twig;
     }));
     $app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function ($filesystem, $app) {
         $filesystem->addPath($app['resources']->getPath('app/view/twig'), 'bolt');
         // @deprecated Since Bolt 2.3 and will be removed in Bolt 3.
         $filesystem->addPath($app['resources']->getPath('app/view/twig'));
         return $filesystem;
     }));
     // Twig paths
     $app['twig.path'] = function () use($app) {
         return $app['config']->getTwigPath();
     };
     // Twig options
     $app['twig.options'] = function () use($app) {
         // Should we cache or not?
         if ($app['config']->get('general/caching/templates')) {
             $cache = $app['resources']->getPath('cache');
         } else {
             $cache = false;
         }
         return ['debug' => true, 'cache' => $cache, 'strict_variables' => $app['config']->get('general/strict_variables'), 'autoescape' => true];
     };
     $app['safe_twig.bolt_extension'] = function () use($app) {
         return new TwigExtension($app, $app['twig.handlers'], true);
     };
     $app['safe_twig'] = $app->share(function ($app) {
         $loader = new \Twig_Loader_String();
         $twig = new \Twig_Environment($loader);
         $twig->addExtension($app['safe_twig.bolt_extension']);
         return $twig;
     });
 }
开发者ID:richardudovich,项目名称:bolt,代码行数:60,代码来源:TwigServiceProvider.php

示例11: getServices

 public function getServices(Application $app)
 {
     return array('resolver' => $app->share($app->extend('resolver', function ($resolver, $container) {
         return new $container['sdispatcher.cbv_resolver.class']($container, $resolver);
     })), 'dispatcher' => $app->share($app->extend('dispatcher', function (EventDispatcherInterface $dispatcher, $container) {
         $dispatcher->addSubscriber($container['sdispatcher.rest_route_listener']);
         $dispatcher->addSubscriber($container['sdispatcher.option_inspector']);
         $dispatcher->addSubscriber($container['sdispatcher.content_negotiator']);
         $dispatcher->addSubscriber($container['sdispatcher.deserializer']);
         $dispatcher->addSubscriber($container['sdispatcher.serializer']);
         $dispatcher->addSubscriber($container['sdispatcher.pagination_listener']);
         return $dispatcher;
     })), 'sdispatcher.resource_option' => $app->share(function ($container) {
         return new $container['sdispatcher.resource_option.class']();
     }), 'sdispatcher.rest_route_listener' => $app->share(function ($container) {
         return new $container['sdispatcher.rest_route_listener.class']($container['routes']);
     }), 'sdispatcher.option_inspector' => $app->share(function ($container) {
         return new $container['sdispatcher.option_inspector.class']($container['routes'], $container['sdispatcher.resource_option']);
     }), 'sdispatcher.content_negotiator' => $app->share(function ($container) {
         return new $container['sdispatcher.content_negotiator.class']($container['routes'], new FormatNegotiator());
     }), 'sdispatcher.deserializer' => $app->share(function ($container) {
         return new $container['sdispatcher.deserializer.class']($container['routes'], new FOSDecoderProvider());
     }), 'sdispatcher.serializer' => $app->share(function ($container) {
         return new $container['sdispatcher.serializer.class']($container['routes'], new ChainEncoder(array(new JsonEncoder(), new DefaultXmlEncoder())));
     }), 'sdispatcher.pagination_listener' => $app->share(function ($container) {
         return new $container['sdispatcher.pagination_listener.class']($container['routes']);
     }));
 }
开发者ID:bcen,项目名称:silex-dispatcher,代码行数:28,代码来源:SDispatcherServiceProvider.php

示例12: register

 /**
  * Registers services on the given app.
  *
  * @param Application $app Silex application.
  */
 public function register(Application $app)
 {
     if (!isset($app['data_collector.templates'])) {
         throw new \LogicException('The provider: "' . __CLASS__ . '" must be registered after the "WebProfilerServiceProvider"');
     }
     $app['data_collector.templates'] = $app->extend('data_collector.templates', function ($tpls) {
         $tpls[] = ['guzzle', '@CampruGuzzle/views/Collector/guzzle.html.twig'];
         return $tpls;
     });
     $app['guzzle_bundle.subscriber.profiler'] = $app->share(function () {
         return new \GuzzleHttp\Subscriber\History();
     });
     $app['guzzle_bundle.subscriber.storage'] = $app->share(function () {
         return new \Campru\GuzzleBundle\Subscriber\Stopwatch(new \SplObjectStorage());
     });
     $app['data_collectors'] = $app->share($app->extend('data_collectors', function ($collectors, $app) {
         $collectors['guzzle'] = function ($app) {
             return new \Campru\GuzzleBundle\DataCollector\GuzzleDataCollector($app['guzzle_bundle.subscriber.profiler'], $app['guzzle_bundle.subscriber.storage']);
         };
         return $collectors;
     }));
     $app['guzzle_bundle.profiler.templates_path'] = function () {
         $class = new \ReflectionClass('Campru\\GuzzleBundle\\DataCollector\\GuzzleDataCollector');
         return dirname(dirname($class->getFileName())) . '/../resources';
     };
     $app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function ($loader, $app) {
         $loader->addPath($app['guzzle_bundle.profiler.templates_path'], 'CampruGuzzle');
         return $loader;
     }));
 }
开发者ID:campru,项目名称:guzzle-bundle,代码行数:35,代码来源:GuzzleProfilerServiceProvider.php

示例13: register

 public function register(Application $app)
 {
     // Checking for dependencies
     if (!isset($app['orm.em'])) {
         throw new \RuntimeException('You must register ORM EntityManager before registring ' . get_class($this));
     }
     // Setup Controllers
     $app['content.article.controller'] = $app->share(function () use($app) {
         return new ArticleController($app);
     });
     // Setup routing
     $app['content.article.routes.prefix'] = '/articles';
     // Adding entities to ORM Entity Manager
     $app['orm.em.paths'] = $app->share($app->extend('orm.em.paths', function ($paths) use($app) {
         $paths[] = __DIR__ . '/../Entity';
         return $paths;
     }));
     // Adding view paths
     $app['twig.path'] = $app->share($app->extend('twig.path', function ($paths) {
         $path = __DIR__ . '/../views';
         if (!in_array($path, $paths)) {
             $paths[] = $path;
         }
         return $paths;
     }));
 }
开发者ID:xesenix,项目名称:bdf2-library,代码行数:26,代码来源:ContentServiceProvider.php

示例14: register

 /**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param Application $app An Application instance
  */
 public function register(Application $app)
 {
     $app['ladybug.options'] = array('theme' => 'modern', 'expanded' => false, 'silenced' => false, 'array_max_nesting_level' => 9, 'object_max_nesting_level' => 3);
     $app['ladybug.dumper'] = $app->share(function () use($app) {
         $dumper = new Dumper();
         $dumper->setOptions($app['ladybug.options']);
         return $dumper;
     });
     $app['ladybug'] = $app->share(function () use($app) {
         return new LadybugDataCollector($app['ladybug.dumper']);
     });
     $app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig, $app) {
         $twig->addExtension(new LadybugExtension($app));
         return $twig;
     }));
     if (isset($app['profiler'])) {
         $app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function ($loader, $app) {
             $loader->addPath($app['rswork.templates_path'], 'Rswork');
             return $loader;
         }));
         $app['rswork.templates_path'] = function () {
             return realpath(__DIR__ . '/../../views');
         };
         $app['data_collector.templates'] = array_merge($app['data_collector.templates'], array(array('ladybug', '@Rswork/collector/ladybug.html.twig')));
         $app['data_collectors'] = $app->share($app->extend('data_collectors', function ($collectors, $app) {
             $collectors['ladubug'] = $app->share(function ($app) {
                 return $app['ladybug'];
             });
             return $collectors;
         }));
     }
 }
开发者ID:Rivsen,项目名称:ladybug-service-provider,代码行数:40,代码来源:LadybugServiceProvider.php

示例15: register

 public function register(Application $app)
 {
     $app['knp_menu.factory'] = $app->share(function () use($app) {
         $factory = new MenuFactory();
         if (isset($app['url_generator'])) {
             $factory->addExtension(new RoutingExtension($app['url_generator']));
         }
         return $factory;
     });
     $app['knp_menu.matcher'] = $app->share(function () use($app) {
         $matcher = new Matcher();
         if (isset($app['knp_menu.matcher.configure'])) {
             $app['knp_menu.matcher.configure']($matcher);
         }
         return $matcher;
     });
     $app['knp_menu.renderer.list'] = $app->share(function () use($app) {
         return new ListRenderer($app['knp_menu.matcher'], array(), $app['charset']);
     });
     $app['knp_menu.menu_provider'] = $app->share(function () use($app) {
         return new PimpleMenuProvider($app, $app['knp_menu.menus']);
     });
     if (!isset($app['knp_menu.menus'])) {
         $app['knp_menu.menus'] = array();
     }
     $app['knp_menu.renderer_provider'] = $app->share(function () use($app) {
         $app['knp_menu.renderers'] = array_merge(array('list' => 'knp_menu.renderer.list'), isset($app['knp_menu.renderer.twig']) ? array('twig' => 'knp_menu.renderer.twig') : array(), isset($app['knp_menu.renderers']) ? $app['knp_menu.renderers'] : array());
         return new PimpleRendererProvider($app, $app['knp_menu.default_renderer'], $app['knp_menu.renderers']);
     });
     $app['knp_menu.menu_manipulator'] = $app->share(function () use($app) {
         return new MenuManipulator();
     });
     if (!isset($app['knp_menu.default_renderer'])) {
         $app['knp_menu.default_renderer'] = 'list';
     }
     $app['knp_menu.helper'] = $app->share(function () use($app) {
         return new Helper($app['knp_menu.renderer_provider'], $app['knp_menu.menu_provider'], $app['knp_menu.menu_manipulator']);
     });
     if (isset($app['twig'])) {
         $app['knp_menu.twig_extension'] = $app->share(function () use($app) {
             return new MenuExtension($app['knp_menu.helper'], $app['knp_menu.matcher'], $app['knp_menu.menu_manipulator']);
         });
         $app['knp_menu.renderer.twig'] = $app->share(function () use($app) {
             return new TwigRenderer($app['twig'], $app['knp_menu.template'], $app['knp_menu.matcher']);
         });
         if (!isset($app['knp_menu.template'])) {
             $app['knp_menu.template'] = 'knp_menu.html.twig';
         }
         $app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig) use($app) {
             $twig->addExtension($app['knp_menu.twig_extension']);
             return $twig;
         }));
         $app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function (\Twig_Loader_Filesystem $loader) use($app) {
             $loader->addPath(__DIR__ . '/../../Resources/views');
             return $loader;
         }));
     }
 }
开发者ID:rasanga,项目名称:KnpMenu,代码行数:58,代码来源:KnpMenuServiceProvider.php


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