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


PHP Application::mount方法代码示例

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


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

示例1: boot

 public function boot(Application $app)
 {
     // Because they're at the root admin prefix we mount them directly instead to  $app['np.admin.controllers']
     $app->mount($app['np.admin.controllers.prefix'], new AuthRouting());
     $app->mount($app['np.admin.controllers.prefix'], new AdminRouting());
     $app->before(function () use($app) {
         $app['np.admin.theme'] = $app->share(function ($app) {
             if (isset($app['np.theme.manager'])) {
                 $app['np.theme.manager']->get($app['np.admin.theme']);
             }
         });
     });
     // $app->on(ThemeEvents::THEME_MANAGER_INITIALIZED, function(Event $event) use ($app) {
     //     $app['np.admin.theme'] = $app->share(function($app) {
     //         if (isset($app['np.theme.manager'])
     //             && $theme = $app['np.theme.manager']->getTheme($app['np.admin.theme'])) {
     //             $javascripts = array();
     //             // add all extension js modules
     //             $resources = $app['np.extension_manager']->collectMethodCalls('getResourceManifest');
     //             foreach ($resources as $resource) {
     //                 if (0 === strpos($resource, '/js')) {
     //                     $javascripts[] = $resource;
     //                 }
     //             }
     //             $theme->addJavaScripts($javascripts);
     //             $app['np.theme.manager']->setTheme($theme);
     //             return $theme;
     //         }
     //     });
     // });
 }
开发者ID:nodepub,项目名称:core,代码行数:31,代码来源:AdminDashboardServiceProvider.php

示例2: add

 /**
  * Adds a single module
  * 
  * @param Module $module
  */
 public function add(Module $module)
 {
     if ($this->locked) {
         throw new \RuntimeException('Cannot register modules: the registry is already locked');
     }
     $this->modules[] = $module;
     // A module is by its definition a Silex\ControllerProviderInterface so
     // is possible to pass it to Silex\Application::mount() method
     $this->app->mount($module->getPrefix(), $module);
 }
开发者ID:vonalbert,项目名称:silext,代码行数:15,代码来源:ModulesRegistry.php

示例3: register

 /**
  * {@inheritDoc}
  */
 public function register(SilexApplication $app)
 {
     $app['payum.api.controller.root'] = $app->share(function () {
         return new RootController();
     });
     $app['payum.api.controller.payment'] = $app->share(function () use($app) {
         return new PaymentController($app['payum'], $app['api.view.payment_to_json_converter'], $app['form.factory'], $app['api.view.form_to_json_converter'], $app['url_generator']);
     });
     $app['payum.api.controller.token'] = $app->share(function () use($app) {
         return new TokenController($app['payum'], $app['form.factory'], $app['api.view.token_to_json_converter'], $app['api.view.form_to_json_converter']);
     });
     $app['payum.api.controller.gateway'] = $app->share(function () use($app) {
         return new GatewayController($app['form.factory'], $app['url_generator'], $app['api.view.form_to_json_converter'], $app['payum.gateway_config_storage'], $app['api.view.gateway_config_to_json_converter']);
     });
     $app['payum.api.controller.gateway_meta'] = $app->share(function () use($app) {
         return new GatewayMetaController($app['form.factory'], $app['api.view.form_to_json_converter'], $app['payum']);
     });
     $app->get('/', 'payum.api.controller.root:rootAction')->bind('api_root');
     /** @var ControllerCollection $payments */
     $payments = $app['controllers_factory'];
     $payments->get('/meta', 'payum.api.controller.payment:metaAction')->bind('payment_meta');
     $payments->get('/{id}', 'payum.api.controller.payment:getAction')->bind('payment_get');
     $payments->put('/{id}', 'payum.api.controller.payment:updateAction')->bind('payment_update');
     $payments->delete('/{id}', 'payum.api.controller.payment:deleteAction')->bind('payment_delete');
     $payments->post('/', 'payum.api.controller.payment:createAction')->bind('payment_create');
     $payments->get('/', 'payum.api.controller.payment:allAction')->bind('payment_all');
     $app->mount('/payments', $payments);
     /** @var ControllerCollection $gateways */
     $gateways = $app['controllers_factory'];
     $gateways->get('/meta', 'payum.api.controller.gateway_meta:getAllAction')->bind('payment_factory_get_all');
     $gateways->get('/', 'payum.api.controller.gateway:allAction')->bind('gateway_all');
     $gateways->get('/{name}', 'payum.api.controller.gateway:getAction')->bind('gateway_get');
     $gateways->delete('/{name}', 'payum.api.controller.gateway:deleteAction')->bind('gateway_delete');
     $gateways->post('/', 'payum.api.controller.gateway:createAction')->bind('gateway_create');
     $app->mount('/gateways', $gateways);
     /** @var ControllerCollection $tokens */
     $tokens = $app['controllers_factory'];
     $tokens->post('/', 'payum.api.controller.token:createAction')->bind('token_create');
     $app->mount('/tokens', $tokens);
     $gateways->before($app['api.parse_json_request']);
     $payments->before($app['api.parse_json_request']);
     $tokens->before($app['api.parse_json_request']);
     $gateways->before($app['api.parse_post_request']);
     $payments->before($app['api.parse_post_request']);
     $tokens->before($app['api.parse_post_request']);
     if ($app['debug']) {
         $gateways->after($app['api.view.pretty_print_json']);
         $payments->after($app['api.view.pretty_print_json']);
         $tokens->after($app['api.view.pretty_print_json']);
     }
 }
开发者ID:detain,项目名称:PayumServer,代码行数:54,代码来源:ApiControllerProvider.php

示例4: finish

 /**
  * Finish mounting process by sorting them and mounting them to application
  */
 public function finish()
 {
     if ($this->isPropagationStopped()) {
         return;
     }
     krsort($this->priorities);
     foreach ($this->priorities as $priority) {
         foreach ($priority as $list) {
             list($prefix, $controllers) = $list;
             $this->app->mount($prefix, $controllers);
         }
     }
     $this->stopPropagation();
 }
开发者ID:nectd,项目名称:nectd-web,代码行数:17,代码来源:MountEvent.php

示例5: createApplication

 /**
  * Bootstrap Silex Application for tests
  * @method createApplication
  * @return $app              Silex\Application
  */
 public function createApplication()
 {
     $app = new Application(['dev' => true]);
     // errors
     error_reporting(E_ALL ^ E_STRICT);
     $app->error(function (Exception $e, $code) use($app) {
         return $app->json(['error' => $e->getMessage(), 'type' => get_class($e)], $code);
     });
     // database
     $app->register(new DoctrineServiceProvider(), ['db.options' => ['driver' => 'pdo_sqlite', 'path' => __DIR__ . '/tests.db', 'charset' => 'UTF8']]);
     // jwt (json-web-token)
     $app['security.jwt'] = ['secret_key' => 'omg-so-secret-test-!', 'life_time' => 2592000, 'algorithm' => ['HS256'], 'options' => ['header_name' => 'X-Access-Token', 'username_claim' => 'email']];
     $app->register(new SecurityServiceProvider());
     $app->register(new SecurityJWTServiceProvider());
     // mailer
     $app->register(new SwiftmailerServiceProvider(), ['swiftmailer.options' => ['host' => '127.0.0.1', 'port' => '1025']]);
     // twig
     $app->register(new TwigServiceProvider(), ['twig.path' => __DIR__ . '/../templates']);
     $app->register(new UrlGeneratorServiceProvider());
     // simple-user-jwt
     $app['user.jwt.options'] = ['invite' => ['enabled' => true], 'forget' => ['enabled' => true], 'mailer' => ['enabled' => true, 'from' => ['email' => 'do-not-reply@test.com', 'name' => 'Test']]];
     $app->register(new UserProvider());
     // roles
     $app['security.role_hierarchy'] = ['ROLE_INVITED' => ['ROLE_USER'], 'ROLE_REGISTERED' => ['ROLE_INVITED', 'ROLE_ALLOW_INVITE'], 'ROLE_ADMIN' => ['ROLE_REGISTERED']];
     // needed to parse user at each request
     $app['security.firewalls'] = ['login' => ['pattern' => 'register|login|forget|reset', 'anonymous' => true], 'secured' => ['pattern' => '.*$', 'users' => $app->share(function () use($app) {
         return $app['user.manager'];
     }), 'jwt' => ['use_forward' => true, 'require_previous_session' => false, 'stateless' => true]]];
     // controller
     $app->mount('/', new UserProvider());
     return $app;
 }
开发者ID:thcolin,项目名称:silex-simpleuser-jwt,代码行数:37,代码来源:UserControllerTests.php

示例6: createApplication

 public function createApplication()
 {
     $app = new Application();
     $app['debug'] = true;
     $app['session.test'] = true;
     $app['monolog.logfile'] = __DIR__ . '/../build/logs/dev.monolog.log';
     $app['session.storage'] = new MockFileSessionStorage();
     $app->register(new Provider\TwigServiceProvider());
     $app->register(new Provider\ServiceControllerServiceProvider());
     $app->register(new Provider\SecurityServiceProvider());
     $app->register(new Provider\SessionServiceProvider());
     $app->register(new Provider\UrlGeneratorServiceProvider());
     $app->register(new Provider\MonologServiceProvider());
     // Mock services
     $app->register(new MockSmsHandlerProvider());
     $app['user.manager'] = $app->share(function () {
         return new MockUserProvider();
     });
     $smsLoginProvider = new SmsLoginProvider();
     $app->register($smsLoginProvider);
     $app->mount('', $smsLoginProvider);
     $app->get('/', function () use($app) {
         return $app['twig']->render('home.twig', ['message' => 'Testing']);
     });
     $app['security.firewalls'] = array('login' => array('pattern' => '^/login$'), 'secured_area' => array('pattern' => '^.*$', 'sms' => true, 'logout' => ['logout_path' => '/logout'], 'users' => $app->share(function ($app) {
         return $app['user.manager'];
     })));
     $app['twig.templates'] = ['login.twig' => '<form action="{{ form_action }}" method="POST">{% if mobile is defined %}<p class="number">{{ mobile }}</p>' . '<input type="hidden" name="mobile" value="{{ mobile }}" />{% endif %}' . '<input type="password" placeholder="Secret code" name="code" />' . '<button class="btn btn-positive btn-block" name="submit">Login</button></form>', 'home.twig' => 'Homepage {{ message }}'];
     unset($app['exception_handler']);
     return $app;
 }
开发者ID:apiaryhq,项目名称:silex-sms-login-provider,代码行数:31,代码来源:SmsLoginTest.php

示例7: boot

 public function boot(Application $app)
 {
     $app->mount($app['widget.routes.prefix'], $this);
     /*$app->on('twig:render', function() use($app) {
     
     			$app['twig']->addGlobal('widgetManager', $app['widget.manager']);
     		});*/
 }
开发者ID:xesenix,项目名称:bdf2-library,代码行数:8,代码来源:WidgetServiceProvider.php

示例8: 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).
  */
 public function boot(Application $app)
 {
     $paths = $app['lazy.thumbnail.mount_paths'];
     foreach ($paths as $route => $data) {
         $realRoute = isset($data['route']) ? $data['route'] : $route;
         $app->mount($realRoute, $this->connect($app, $realRoute, $data));
     }
 }
开发者ID:fzerorubigd,项目名称:silex-lazy-thumbnail-generator,代码行数:15,代码来源:LazyThumbnailGenerator.php

示例9: register

 public function register(Application $app)
 {
     $app['company'] = $app->share(function () use($app) {
         $storage = new CompanyStorage($app);
         return new Service\Company($app, $storage);
     });
     $app['building'] = $app->share(function () use($app) {
         $storage = new BuildingStorage($app);
         return new Service\Building($app, $storage);
     });
     $app['rubric'] = $app->share(function () use($app) {
         $storage = new RubricStorage($app);
         return new Service\Rubric($app, $storage);
     });
     $app->mount('/company', new CompanyController());
     $app->mount('/building', new BuildingController());
     $app->mount('/rubric', new RubricController());
 }
开发者ID:BOPOH,项目名称:gis-api,代码行数:18,代码来源:ServiceProvider.php

示例10: process

 public function process(Application $app, ReflectionClass $reflectionClass)
 {
     $controllerCollection = $app['controllers_factory'];
     /** @var AnnotationService $annotationService */
     $annotationService = $app['annot'];
     $annotationService->processClassAnnotations($reflectionClass, $controllerCollection);
     $annotationService->processMethodAnnotations($reflectionClass, $controllerCollection);
     $app->mount($this->prefix, $controllerCollection);
 }
开发者ID:jsmith07,项目名称:silex-annotation-provider,代码行数:9,代码来源:Controller.php

示例11: createApplication

 /**
  * Returns Silex Application instance.
  *
  * @return Application
  */
 private function createApplication()
 {
     $app = new Application();
     $controller = new ImageController(array('image_path' => __DIR__));
     $app->register(new InterventionImageServiceProvider())->register(new UrlGeneratorServiceProvider());
     //Automatic images mount
     $app->mount('/', $controller);
     return $app;
 }
开发者ID:microstudi,项目名称:silex-image-controller,代码行数:14,代码来源:ImageControllerTest.php

示例12: createApplication

 /**
  * {@inheritdoc}
  */
 public function createApplication()
 {
     $app = new Application();
     $app['controller.thumbnails'] = new Controller();
     $app->mount('/thumbs', $app['controller.thumbnails']);
     $app->register(new ServiceControllerServiceProvider());
     $mock = $this->getMock('Bolt\\Thumbs\\ThumbnailResponder', ['respond'], [], '', false);
     $app['thumbnails'] = $mock;
     return $app;
 }
开发者ID:pkdevboxy,项目名称:bolt-thumbs,代码行数:13,代码来源:ControllerTest.php

示例13: 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).
  */
 public function boot(Application $app)
 {
     if (!isset($app[self::PROVIDER_KEY . '.controllersPath'])) {
         throw new \Exception(self::PROVIDER_NAME . ': Please configure ' . self::PROVIDER_KEY . '.controllersPath');
     }
     $this->Parser = new Parser($app[self::PROVIDER_KEY . '.controllersPath'], $app[self::PROVIDER_KEY . '.recursiv']);
     $this->controllersAsApplicationAwareService = $app[self::PROVIDER_KEY . '.controllersAsApplicationAwareServices'];
     $this->controllers = $this->Parser->parseEmAll()->getParsedControllers();
     $app->mount('/', $this);
 }
开发者ID:NicolasCharpentier,项目名称:silex-simple-annotations,代码行数:17,代码来源:AnnotationsServiceProvider.php

示例14: createScopeControllers

 /**
  * Create scope controllers
  */
 public function createScopeControllers()
 {
     $this->configLoader->load();
     $silex = $this->silex;
     $manifests = $this->configLoader->getManifests();
     foreach ($manifests as $scope => $manifest) {
         /** @var ControllerCollection $controllers_factory */
         $controllers_factory = $this->silex['controllers_factory'];
         foreach ($manifest['routes'] as $http_method => $route) {
             $scope_path = $this->configLoader->getPath();
             /** @var Controller $routeController */
             $routeController = $controllers_factory->{$http_method}($route['route'], function (Request $request) use($silex, $scope, $manifest, $route, $scope_path) {
                 //Scope container
                 $scope_container = $silex['scopes'][$scope];
                 if (isset($silex['translator'])) {
                     $scope_container['translator'] = $silex['translator'];
                 }
                 if (isset($silex['url_generator'])) {
                     $scope_container['url_generator'] = $silex['url_generator'];
                 }
                 if (isset($silex['log_factory'])) {
                     $scope_container['log_factory'] = $silex['log_factory'];
                 }
                 if (isset($silex['predis'])) {
                     $scope_container['predis'] = $silex['predis'];
                 }
                 $silex['scopes'][$scope] = $scope_container;
                 /** @var Twig_Loader_Filesystem $twig_loader_filesystem */
                 $twig_loader_filesystem = $silex['twig.loader.filesystem'];
                 $twig_loader_filesystem->prependPath($scope_path . '/' . $scope . '/views');
                 //Create request
                 $psr7Factory = new DiactorosFactory();
                 $psrRequest = $psr7Factory->createRequest($request);
                 /** @var AbstractScopeController $scope_controller */
                 $namespace_controller = $this->scope_namespace . implode('\\', [$scope, 'controller', ucfirst($route['controller']) . 'Controller']);
                 $scope_controller = $namespace_controller::create($manifest, $silex['scopes'][$scope], $psrRequest, $this->base_namespace);
                 $scope_controller->setTwig($silex['twig']);
                 $psrResponse = $scope_controller->execute($route['call']);
                 //Create response
                 $httpFoundationFactory = new HttpFoundationFactory();
                 $symfonyResponse = $httpFoundationFactory->createResponse($psrResponse);
                 return $symfonyResponse;
             });
             //Filter
             if (is_array($route['filter'])) {
                 foreach ($route['filter'] as $filter) {
                     $routeController->before($this->silex['filter_factory']->createFilter($scope, $filter));
                 }
             }
             //Bind
             $routeController->bind(implode('::', [$route['controller'], $route['call']]));
         }
         $this->silex->mount($manifest['mount'], $controllers_factory);
     }
 }
开发者ID:triadev,项目名称:silex-scope-framework,代码行数:58,代码来源:SilexScopeFactory.php

示例15: register

 /**
  * Register service function.
  *
  * @param BaseApplication $app
  */
 public function register(BaseApplication $app)
 {
     // Repository
     $app['orderpdf.repository.order_pdf'] = $app->share(function () use($app) {
         return $app['orm.em']->getRepository('Plugin\\OrderPdf\\Entity\\OrderPdf');
     });
     // Order pdf event
     $app['orderpdf.event.order_pdf'] = $app->share(function () use($app) {
         return new OrderPdf($app);
     });
     // Order pdf legacy event
     $app['orderpdf.event.order_pdf_legacy'] = $app->share(function () use($app) {
         return new OrderPdfLegacy($app);
     });
     // ============================================================
     // コントローラの登録
     // ============================================================
     // 管理画面定義
     $admin = $app['controllers_factory'];
     // 強制SSL
     if ($app['config']['force_ssl'] == Constant::ENABLED) {
         $admin->requireHttps();
     }
     // 帳票の作成
     $admin->match('/plugin/order-pdf', '\\Plugin\\OrderPdf\\Controller\\OrderPdfController::index')->bind('plugin_admin_order_pdf');
     // PDFファイルダウンロード
     $admin->post('/plugin/order-pdf/download', '\\Plugin\\OrderPdf\\Controller\\OrderPdfController::download')->bind('plugin_admin_order_pdf_download');
     $app->mount('/' . trim($app['config']['admin_route'], '/') . '/', $admin);
     // ============================================================
     // Formの登録
     // ============================================================
     // 型登録
     $app['form.types'] = $app->share($app->extend('form.types', function ($types) use($app) {
         $types[] = new OrderPdfType($app);
         return $types;
     }));
     // -----------------------------
     // サービスの登録
     // -----------------------------
     // 帳票作成
     $app['orderpdf.service.order_pdf'] = $app->share(function () use($app) {
         return new OrderPdfService($app);
     });
     // ============================================================
     // メッセージ登録
     // ============================================================
     $file = __DIR__ . '/../Resource/locale/message.' . $app['locale'] . '.yml';
     if (file_exists($file)) {
         $app['translator']->addResource('yaml', $file, $app['locale']);
     }
     // initialize logger (for 3.0.0 - 3.0.8)
     if (!Version::isSupportMethod()) {
         eccube_log_init($app);
     }
 }
开发者ID:EC-CUBE,项目名称:order-pdf-plugin,代码行数:60,代码来源:OrderPdfServiceProvider.php


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