當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。