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


PHP Application::offsetGet方法代码示例

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


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

示例1: 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 ($app->offsetExists('facade.aliases')) {
         $aliases = $app->offsetGet('facade.aliases');
         ClassAliaser::register($aliases);
     }
 }
开发者ID:mrubiosan,项目名称:facade,代码行数:14,代码来源:FacadeProvider.php

示例2: testBasePathAndUrls

 public function testBasePathAndUrls()
 {
     $app = new Application();
     $app->register(new AssetServiceProvider(), ['assets' => ['base_path' => '/', 'base_urls' => ['//exemple.com']]]);
     $this->setExpectedException('LogicException');
     $app->offsetGet('asset.packages');
 }
开发者ID:matthecat,项目名称:silex-asset-provider,代码行数:7,代码来源:AssetServiceProviderTest.php

示例3: offsetGet

 public function offsetGet($id)
 {
     if (parent::offsetExists($id)) {
         return parent::offsetGet($id);
     }
     return $this->phpdi->get($id);
 }
开发者ID:praswicaksono,项目名称:Silex-Bridge,代码行数:7,代码来源:Application.php

示例4: offsetGet

 /**
  * Gets a parameter or an object.
  *
  * @param  string $id The unique identifier for the parameter or object
  * @return mixed      The value of the parameter or an object
  * @throws \InvalidArgumentException if the identifier is not defined
  */
 public function offsetGet($id)
 {
     $instance = parent::offsetGet($id);
     if ($instance instanceof PimpleAwareInterface) {
         $instance->setContainer($this);
     }
     return $instance;
 }
开发者ID:sunnyct,项目名称:silexcmf-core,代码行数:15,代码来源:Application.php

示例5: offsetGet

 /**
  * Override Pimple's offsetGet to add support for initializers
  *
  * @param  string $id The unique identifier for the parameter or object
  * @return mixed      The value of the parameter or an object
  */
 public function offsetGet($id)
 {
     $value = parent::offsetGet($id);
     if (is_object($value)) {
         $this->initialize($value);
     }
     return $value;
 }
开发者ID:bodetree,项目名称:synapse-base,代码行数:14,代码来源:Application.php

示例6: offsetGet

 public function offsetGet($id)
 {
     if ($this->isPublicScope() && false === $this->isServicePublished($id)) {
         throw new PrivateScopeViolationException($id);
     }
     $scope = $this->enterPrivateScope();
     $service = parent::offsetGet($id);
     $this->leavePrivateScope($scope);
     return $service;
 }
开发者ID:mlebkowski,项目名称:silex-private-scope,代码行数:10,代码来源:ScopedApplication.php

示例7: it_handles_authorization_refusal

 public function it_handles_authorization_refusal(AuthorizeControllerInterface $oauth2AuthorizeController, ParameterBag $requestBag, Application $app, Request $request, TokenStorageInterface $tokenStorage)
 {
     $app->offsetGet('security.token_storage')->willReturn($tokenStorage);
     $requestBag->all()->willReturn(['authorize' => '0']);
     $responseArgument = Argument::type('OAuth2\\HttpFoundationBridge\\Response');
     $requestArgument = Argument::type('OAuth2\\HttpFoundationBridge\\Request');
     $oauth2AuthorizeController->handleAuthorizeRequest($requestArgument, $responseArgument, false, null)->shouldBeCalled();
     $response = $this->__invoke($app, $request);
     $response->shouldHaveType('OAuth2\\HttpFoundationBridge\\Response');
     $response->getStatusCode()->shouldReturn(200);
 }
开发者ID:mathroc,项目名称:oauth2-provider,代码行数:11,代码来源:AuthorizeHandlerSpec.php

示例8: it_renders_authenticated_authorize_view

 public function it_renders_authenticated_authorize_view(UrlGeneratorInterface $urlGenerator, AuthorizeControllerInterface $oauth2AuthorizeController, AuthorizeRenderer $authorizeRenderer, Application $app, Request $request, ParameterBag $queryBag, BridgeResponse $response, TokenStorageInterface $tokenStorage, TokenInterface $token)
 {
     $responseArgument = Argument::type('OAuth2\\HttpFoundationBridge\\Response');
     $requestArgument = Argument::type('OAuth2\\HttpFoundationBridge\\Request');
     $oauth2AuthorizeController->validateAuthorizeRequest($requestArgument, $responseArgument)->willReturn(true);
     $urlGenerator->generate('oauth2_authorize_handler', Argument::any())->willReturn('/url');
     $queryBag->all()->willReturn(['client_id' => 'clientId', 'response_type' => 'responseType']);
     $app->offsetGet('security.token_storage')->willReturn($tokenStorage);
     $tokenStorage->getToken()->willReturn($token);
     $token->getUser()->willReturn('user');
     $authorizeRenderer->render('/url', 'clientId', 'responseType', 'user')->willReturn($response);
     $this->__invoke($app, $request)->shouldReturn($response);
 }
开发者ID:mathroc,项目名称:oauth2-provider,代码行数:13,代码来源:AuthorizeValidatorSpec.php

示例9: register

 /**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  */
 public function register(Application $app)
 {
     if ($app->offsetGet('api.version') === false) {
         throw new \Exception('Missing api version');
     }
     $app['rest_normalizer.builder'] = $app->protect(function ($object = null) use($app) {
         $request = $app['request'];
         // @var $request Request
         $builder = ResponseBuilder::create($app['api.version'], HttpMethod::valueOf($request->getMethod()), $object);
         foreach ($request->request->all() as $key => $value) {
             $parameter = Parameter::create($key, $value);
             $builder->addParameter($parameter);
         }
         return $builder;
     });
 }
开发者ID:craklabs,项目名称:skeleton-service,代码行数:22,代码来源:RestNormalizerProvider.php

示例10: register

 /**
  * Registers services on the given app.
  *
  * @param Application $app
  */
 public function register(Application $app)
 {
     $app["debesha.doctrine_extra_profiler.logger"] = $app->share(function () use($app) {
         return new HydrationLogger($app->offsetGet("orm.em"));
     });
     $app['debesha.class.hydrationDataCollector'] = 'SilexDoctrineHydrationProfile\\Fix\\DataCollector';
     $app["debesha.doctrine_extra_profiler.data_collector"] = $app->share(function () use($app) {
         $class = $app['debesha.class.hydrationDataCollector'];
         return new $class($app->offsetGet("debesha.doctrine_extra_profiler.logger"));
     });
     if ($app->offsetExists(self::ORM_EM_OPTIONS)) {
         $options = $app->offsetGet(self::ORM_EM_OPTIONS);
     } else {
         $options = array();
     }
     $overwrite = array('class.configuration' => 'SilexDoctrineHydrationProfile\\Fix\\LoggingConfiguration', 'class.entityManager' => 'Debesha\\DoctrineProfileExtraBundle\\ORM\\LoggingEntityManager', 'class.driver.yml' => 'Doctrine\\ORM\\Mapping\\Driver\\YamlDriver', 'class.driver.simple_yml' => 'Doctrine\\ORM\\Mapping\\Driver\\SimplifiedYamlDriver', 'class.driver.xml' => 'Doctrine\\ORM\\Mapping\\Driver\\XmlDriver', 'class.driver.simple_xml' => 'Doctrine\\ORM\\Mapping\\Driver\\SimplifiedXmlDriver', 'class.driver.php' => 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\StaticPHPDriver');
     foreach ($overwrite as $key => $className) {
         if (!isset($options[$key])) {
             $options[$key] = $className;
         }
     }
     $app[self::ORM_EM_OPTIONS] = $options;
     $app['orm.ems'] = $app->share(function ($app) {
         /**
          * @var \Pimple $app
          */
         $app['orm.ems.options.initializer']();
         $ems = new \Pimple();
         foreach ($app['orm.ems.options'] as $name => $options) {
             if ($app['orm.ems.default'] === $name) {
                 // we use shortcuts here in case the default has been overridden
                 $config = $app['orm.em.config'];
             } else {
                 $config = $app['orm.ems.config'][$name];
             }
             $ems[$name] = $app->share(function () use($app, $options, $config) {
                 /**
                  * @var $entityManagerClassName \Doctrine\ORM\EntityManager
                  */
                 $entityManagerClassName = $options['class.entityManager'];
                 return $entityManagerClassName::create($app['dbs'][$options['connection']], $config, $app['dbs.event_manager'][$options['connection']]);
             });
         }
         return $ems;
     });
     $app['orm.ems.config'] = $app->share(function (\Pimple $app) {
         $app['orm.ems.options.initializer']();
         $configs = new \Pimple();
         foreach ($app['orm.ems.options'] as $name => $options) {
             /**
              * @var $config \Doctrine\ORM\Configuration
              */
             $configurationClassName = $options['class.configuration'];
             $config = new $configurationClassName();
             $app['orm.cache.configurer']($name, $config, $options);
             $config->setProxyDir($app['orm.proxies_dir']);
             $config->setProxyNamespace($app['orm.proxies_namespace']);
             $config->setAutoGenerateProxyClasses($app['orm.auto_generate_proxies']);
             $config->setCustomStringFunctions($app['orm.custom.functions.string']);
             $config->setCustomNumericFunctions($app['orm.custom.functions.numeric']);
             $config->setCustomDatetimeFunctions($app['orm.custom.functions.datetime']);
             $config->setCustomHydrationModes($app['orm.custom.hydration_modes']);
             $config->setClassMetadataFactoryName($app['orm.class_metadata_factory_name']);
             $config->setDefaultRepositoryClassName($app['orm.default_repository_class']);
             $config->setEntityListenerResolver($app['orm.entity_listener_resolver']);
             $config->setRepositoryFactory($app['orm.repository_factory']);
             $config->setNamingStrategy($app['orm.strategy.naming']);
             $config->setQuoteStrategy($app['orm.strategy.quote']);
             /**
              * @var \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain $chain
              */
             $chain = $app['orm.mapping_driver_chain.locator']($name);
             foreach ((array) $options['mappings'] as $entity) {
                 if (!is_array($entity)) {
                     throw new \InvalidArgumentException("The 'orm.em.options' option 'mappings' should be an array of arrays.");
                 }
                 if (!empty($entity['resources_namespace'])) {
                     if ($app->offsetExists('psr0_resource_locator')) {
                         $entity['path'] = $app['psr0_resource_locator']->findFirstDirectory($entity['resources_namespace']);
                     } else {
                         throw new \InvalidArgumentException('Not exist psr0_resource_locator');
                     }
                 }
                 if (isset($entity['alias'])) {
                     $config->addEntityNamespace($entity['alias'], $entity['namespace']);
                 }
                 if ('annotation' === $entity['type']) {
                     $useSimpleAnnotationReader = isset($entity['use_simple_annotation_reader']) ? $entity['use_simple_annotation_reader'] : true;
                     $driver = $config->newDefaultAnnotationDriver((array) $entity['path'], $useSimpleAnnotationReader);
                 } else {
                     $driver = $app['orm.driver.factory']($entity, $options);
                 }
                 $chain->addDriver($driver, $entity['namespace']);
             }
             $config->setMetadataDriverImpl($chain);
//.........这里部分代码省略.........
开发者ID:BI0R0B0T,项目名称:SilexDoctrineHydrationProfile,代码行数:101,代码来源:SilexDoctrineHydrationProfileProvider.php

示例11: testJWTListenerService

 public function testJWTListenerService()
 {
     $this->register();
     $this->app->boot();
     $jwtListener = $this->app->offsetGet('security.authentication_listener.all.jwt');
     $this->assertInstanceOf(JWTListener::class, $jwtListener);
 }
开发者ID:evaneos,项目名称:silex-jwt-provider,代码行数:7,代码来源:SecurityJWTServiceProviderTest.php


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