• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Pimple类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Pimple的典型用法代码示例。如果您正苦于以下问题:PHP Pimple类的具体用法?PHP Pimple怎么用?PHP Pimple使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: register

 public function register(\Pimple $container)
 {
     $container['logger'] = function () use($container) {
         return $container['monolog'];
     };
     if ($bridge = class_exists('Symfony\\Bridge\\Monolog\\Logger')) {
         $container['monolog.handler.debug'] = function () use($container) {
             return new DebugHandler($container['monolog.level']);
         };
     }
     $container['monolog.logger.class'] = $bridge ? 'Symfony\\Bridge\\Monolog\\Logger' : 'Monolog\\Logger';
     $container['monolog'] = $container->share(function ($container) {
         $log = new $container['monolog.logger.class']($container['monolog.name']);
         $log->pushHandler($container['monolog.handler']);
         if ($container['debug'] && isset($container['monolog.handler.debug'])) {
             $log->pushHandler($container['monolog.handler.debug']);
         }
         return $log;
     });
     $container['monolog.handler'] = function () use($container) {
         return new StreamHandler($container['monolog.logfile'], $container['monolog.level']);
     };
     $container['monolog.level'] = function () {
         return Logger::DEBUG;
     };
     $container['monolog.name'] = 'container';
 }
开发者ID:uwej711,项目名称:pimplex,代码行数:27,代码来源:MonologServiceProvider.php


示例2: register

 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param \Pimple $mainContainer An Container instance
  */
 public function register(\Pimple $mainContainer)
 {
     $container = new \Pimple();
     $container['profiler'] = $mainContainer->share(function ($container) use($mainContainer) {
         $profiler = new Profiler(new FileStorage($mainContainer['config']->get('profiler_path')));
         $profiler->addCollector($container['collector.cache']);
         $profiler->addCollector($container['collector.database']);
         return $profiler;
     });
     $container['session_storage'] = $mainContainer->share(function () use($mainContainer) {
         return new SessionStorage($mainContainer['session']);
     });
     $container['profiler_manager'] = $mainContainer->share(function ($container) {
         return new ProfilerManager($container['profiler']);
     });
     $container['collector.cache'] = $mainContainer->share(function () {
         return new CacheDataCollector();
     });
     $container['collector.listener'] = $mainContainer->share(function () use($mainContainer) {
         return new ListenerDataCollector($mainContainer['core']['dispatcher']);
     });
     $container['collector.database'] = $mainContainer->share(function () {
         return new DatabaseDataCollector();
     });
     $container['collector.xhprof'] = $mainContainer->share(function () {
         return new XhprofDataCollector();
     });
     $container['listener'] = $mainContainer->share(function ($container) {
         return new ProfilerListener($container['profiler']);
     });
     $container['template_finder'] = $mainContainer->share(function () {
         return new Finder();
     });
     $mainContainer['profiler'] = $container;
 }
开发者ID:itkg,项目名称:profiler,代码行数:43,代码来源:ServiceProvider.php


示例3: createDIContainer

/**
 * @return a new DI container with prefilled values for the news app
 */
function createDIContainer()
{
    $container = new \Pimple();
    /** 
     * BASE
     */
    $container['API'] = $container->share(function ($c) {
        return new API('apptemplate_advanced');
    });
    $container['Security'] = $container->share(function ($c) {
        return new Security($c['API']->getAppName());
    });
    $container['Request'] = $container->share(function ($c) {
        return new Request($_GET, $_POST);
    });
    /** 
     * CONTROLLERS
     */
    $container['IndexController'] = function ($c) {
        return new IndexController($c['API'], $c['Request']);
    };
    $container['SettingsController'] = function ($c) {
        return new SettingsController($c['API'], $c['Request']);
    };
    $container['AjaxController'] = function ($c) {
        return new AjaxController($c['API'], $c['Request']);
    };
    return $container;
}
开发者ID:nickfrey,项目名称:apps,代码行数:32,代码来源:bootstrap.php


示例4: register

 public function register(Application $app)
 {
     $app['mongodbs.options.initializer'] = $app->protect(function () use($app) {
         static $initialized = false;
         if ($initialized) {
             return;
         }
         $initialized = true;
         if (!isset($app['mongodbs.options'])) {
             $app['mongodbs.options'] = ['default' => isset($app['mongodb.options']) ? $app['mongodb.options'] : []];
         }
         $app['mongodbs.options'] = array_map(function ($options) use($app) {
             return array_replace($app['mongodb.default_options'], $options);
         }, $app['mongodbs.options']);
         if (!isset($app['mongodbs.default'])) {
             $app['mongodbs.default'] = array_keys(array_slice($app['mongodbs.options'], 0, 1))[0];
         }
     });
     $app['mongodbs'] = $app->share(function (Application $app) {
         $app['mongodbs.options.initializer']();
         $container = new \Pimple();
         foreach ($app['mongodbs.options'] as $name => $options) {
             $container[$name] = $container->share(function () use($options) {
                 return new Manager($options['uri'], $options['options'], $options['driverOptions']);
             });
         }
         return $container;
     });
     $app['mongodb.default_options'] = ['uri' => 'mongodb://localhost:27017', 'options' => [], 'driverOptions' => []];
     // shortcuts for the "first" MongoDB
     $app['mongodb'] = $app->share(function (Application $app) {
         $dbs = $app['mongodbs'];
         return $dbs[$app['mongodbs.default']];
     });
 }
开发者ID:coderockr,项目名称:silex-mongodb-provider,代码行数:35,代码来源:ServiceProvider.php


示例5: it_normalizes_expressions

 public function it_normalizes_expressions($parser, \Pimple $container)
 {
     $container->offsetExists('_normalize')->willReturn(true);
     $container->offsetGet('_normalize')->willReturn(array('foo' => 'bar'));
     $parser->evaluate('foo', array('foo' => 'bar'))->willReturn('bar')->shouldBeCalled();
     $this->normalize('?foo', $container)->shouldReturn('bar');
 }
开发者ID:td7650,项目名称:yml2pimple,代码行数:7,代码来源:ExpressionNormalizerSpec.php


示例6: register

 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param \Pimple $mainContainer An Container instance
  */
 public function register(\Pimple $mainContainer)
 {
     $mainContainer['core']['db'] = $mainContainer->share(function () {
         return \Pelican_Db::getInstance();
     });
     $mainContainer['core']['listener.ajax_response_render'] = $mainContainer->share(function () {
         return new AjaxRenderResponseListener(new \Pelican_Ajax_Adapter_Jquery());
     });
 }
开发者ID:itkg,项目名称:core,代码行数:17,代码来源:ServiceLegacyProvider.php


示例7: registerFilters

 public static function registerFilters(\Pimple $container)
 {
     $container['inspector.filter_listener'] = $container->share($container->extend('inspector.filter_listener', function ($listener, $c) {
         $listener->addAvailableFilter('gitignore', function () {
             return new Filter\GitIgnoreFilter();
         });
         return $listener;
     }));
 }
开发者ID:wouterj,项目名称:inspector,代码行数:9,代码来源:InspectorServiceProvider.php


示例8: register

 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param \Pimple $mainContainer An Container instance
  */
 public function register(\Pimple $mainContainer)
 {
     $container = new \Pimple();
     $container['dispatcher'] = $mainContainer->share(function () {
         $dispatcher = new EventDispatcher();
         // Add listeners
         return $dispatcher;
     });
     $mainContainer['core'] = $container;
 }
开发者ID:itkg,项目名称:core,代码行数:18,代码来源:ServiceProvider.php


示例9: register

 /**
  * {@inheritDoc}
  */
 public static function register(\Pimple $container)
 {
     $container['event_dispatcher.class'] = 'Zend\\EventManager\\EventManager';
     if (class_exists($container['event_dispatcher.class'])) {
         $container['event_dispatcher'] = $container->share(function ($c) {
             return new $c['event_dispatcher.class']();
         });
     } else {
         throw new Exception\Provider\ClassNotFoundException('Event Dispatcher', $container['event_dispatcher.class']);
     }
 }
开发者ID:wouterj,项目名称:inspector,代码行数:14,代码来源:EventDispatcherServiceProvider.php


示例10: it_creates_a_array_parameter_and_merges_existing_data

 public function it_creates_a_array_parameter_and_merges_existing_data(Parameter $parameterConf, \Pimple $container)
 {
     $parameterConf->getParameterName()->willReturn('db.options');
     $parameterConf->getParameterValue()->willReturn(array('host' => 'example.org'));
     $parameterConf->getMergeStrategy(Argument::type('array'))->willReturn('array_replace_recursive');
     $parameterConf->mergeExisting()->willReturn(true);
     $container->offsetExists('db.options')->willReturn(true);
     $container->offsetGet('db.options')->willReturn(array('host' => 'localhost', 'user' => 'root', 'password' => 'test'));
     $container->offsetSet('db.options', array('host' => 'example.org', 'user' => 'root', 'password' => 'test'))->shouldBeCalled();
     $container = $this->create($parameterConf, $container);
 }
开发者ID:td7650,项目名称:yml2pimple,代码行数:11,代码来源:ParameterFactorySpec.php


示例11: register

 public function register(\Pimple $container)
 {
     $container['knp_menu.route.voter'] = $container->share(function (\Pimple $container) {
         $voter = new RouteVoter();
         $voter->setRequest($container['request_stack']->getCurrentRequest());
         return $voter;
     });
     $container['knp_menu.matcher.configure'] = $container->protect(function (Matcher $matcher) use($container) {
         $matcher->addVoter($container['knp_menu.route.voter']);
     });
 }
开发者ID:saxulum,项目名称:saxulum-menu-provider,代码行数:11,代码来源:SaxulumMenuProvider.php


示例12: register

 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param \Pimple $container An Container instance
  */
 public function register(\Pimple $container)
 {
     $services = new \Pimple();
     $services['factory'] = $container->share(function () use($container) {
         return new \Itkg\Core\Cache\Factory($container['cache']['adapters']);
     });
     $services['listener'] = $container->share(function () use($services, $container) {
         return new CacheListener($services['factory']->create($container['config']['cache']['adapter'], $container['config']['cache']), $container['core']['dispatcher']);
     });
     $container['cache'] = $services;
 }
开发者ID:itkg,项目名称:core,代码行数:19,代码来源:ServiceProvider.php


示例13: createApplication

 public function createApplication()
 {
     $pimple = new \Pimple();
     $dependencies = array('beforeTokenChecker' => $pimple->protect(function () {
     }));
     require SPIKA_ROOT . '/etc/app.php';
     $mailer = $this->getMockBuilder('\\Silex\\Provider\\SwiftmailerServiceProvider')->setMethods(array('send'))->disableOriginalConstructor()->getMock();
     $mailer->expects(once())->method('send')->with(isInstanceOf('Swift_Message'));
     $app['mailer'] = $mailer;
     return $app;
 }
开发者ID:ashishkalranitk,项目名称:Spika-Server,代码行数:11,代码来源:ReportControllerTest.php


示例14: registerApplication

 public static function registerApplication(\Pimple $container)
 {
     $container['console.application'] = $container->share(function ($c) {
         $app = new $c['console.application.class']($c);
         foreach ($c['console.command'] as $command) {
             $app->add($command());
         }
         return $app;
     });
     $container['console.command'] = new \ArrayObject();
     self::registerCommands($container);
 }
开发者ID:wouterj,项目名称:inspector,代码行数:12,代码来源:ConsoleServiceProvider.php


示例15: testGetMenuAsClosure

 public function testGetMenuAsClosure()
 {
     $pimple = new \Pimple();
     $menu = $this->getMock('Knp\\Menu\\ItemInterface');
     $pimple['menu'] = $pimple->protect(function ($options, $c) use($menu) {
         $c['options'] = $options;
         return $menu;
     });
     $provider = new PimpleProvider($pimple, array('default' => 'menu'));
     $this->assertSame($menu, $provider->get('default', array('foo' => 'bar')));
     $this->assertEquals(array('foo' => 'bar'), $pimple['options']);
 }
开发者ID:nfouka,项目名称:jobbet_sf2.5,代码行数:12,代码来源:PimpleProviderTest.php


示例16: startup

 /**
  * Initialize the user.
  *
  * @param \Pimple $container The dependency container.
  *
  * @return void
  */
 public function startup(\Pimple $container)
 {
     $container['workflow.security.user'] = $container->share(function () use($container) {
         $user = $this->createUser($container['event-dispatcher']);
         try {
             $contaoUser = $container['user'];
             $this->initializeContaoUser($user, $contaoUser);
         } catch (\Exception $e) {
             // Ignore error. Fetching user from container could throw an error for a unknown TL_MODE.
         }
         return $user;
     });
 }
开发者ID:netzmacht,项目名称:contao-workflow,代码行数:20,代码来源:Boot.php


示例17: register

 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param \Pimple $mainContainer An Container instance
  */
 public function register(\Pimple $mainContainer)
 {
     $mainContainer['router'] = $mainContainer->share(function () {
         return new Router();
     });
     $mainContainer['request_matcher'] = $mainContainer->share(function ($mainContainer) {
         return new RequestMatcher($mainContainer['router']);
     });
     // listeners
     $mainContainer['listener.request_matcher'] = $mainContainer->share(function ($mainContainer) {
         return new RequestMatcherListener($mainContainer['request_matcher']);
     });
     $mainContainer['dispatcher']->addSubscriber($mainContainer['listener.request_matcher']);
 }
开发者ID:itkg,项目名称:core,代码行数:22,代码来源:ServiceRouterProvider.php


示例18: register

 public function register(\Pimple $pimple)
 {
     $pimple['issue'] = $pimple->share(function ($pimple) {
         return new IssueService($pimple['session']);
     });
     $pimple['issue.email'] = $pimple->share(function ($pimple) {
         return new IssueEmailService($pimple['session'], $pimple['workflow']);
     });
     $pimple['workflow'] = $pimple->share(function ($pimple) {
         return new WorkflowService($pimple['session']);
     });
     $pimple['project'] = $pimple->share(function ($pimple) {
         return new ProjectService($pimple['session']);
     });
 }
开发者ID:spiasecki,项目名称:ubirimi,代码行数:15,代码来源:YongoServiceProvider.php


示例19: register

 /**
  * {@inheritdoc}
  */
 public function register(\Pimple $container)
 {
     foreach ($this->getDefaults() as $key => $value) {
         if (!isset($container[$key])) {
             $container[$key] = $value;
         }
     }
     $container['console'] = $container->share(function () use($container) {
         $class = $container['console.class'];
         $instance = new $class(isset($container['console.name']) ? $container['console.name'] : '', isset($container['console.version']) ? $container['console.version'] : null);
         if ($instance instanceof ContainerAwareApplication) {
             $instance->setContainer($container);
         }
         return $instance;
     });
 }
开发者ID:axelmdev,项目名称:ecommerce,代码行数:19,代码来源:BaseConsoleServiceProvider.php


示例20: register

 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param \Pimple $mainContainer An Container instance
  */
 public function register(\Pimple $mainContainer)
 {
     $mainContainer['listener.response_exception'] = $mainContainer->share(function () {
         return new ResponseExceptionListener();
     });
     $mainContainer['listener.processor_response_render'] = $mainContainer->share(function () {
         return new ResponsePostRendererListener();
     });
     // Response Processors
     $mainContainer['response.processor.compress'] = $mainContainer->share(function () {
         return new CompressProcessor();
     });
     $dispatcher = $mainContainer['dispatcher'];
     $dispatcher->addSubscriber($mainContainer['listener.response_exception']);
     $dispatcher->addSubscriber($mainContainer['listener.processor_response_render']);
 }
开发者ID:itkg,项目名称:core,代码行数:24,代码来源:ServiceResponseProvider.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Piwi类代码示例发布时间:2022-05-23
下一篇:
PHP Pimcore_Tool类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap