當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Pimple::extend方法代碼示例

本文整理匯總了PHP中Pimple::extend方法的典型用法代碼示例。如果您正苦於以下問題:PHP Pimple::extend方法的具體用法?PHP Pimple::extend怎麽用?PHP Pimple::extend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pimple的用法示例。


在下文中一共展示了Pimple::extend方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: register

 public function register(\Pimple $container)
 {
     $container['doctrine'] = $container->share(function ($container) {
         return new ManagerRegistry($container);
     });
     if (isset($container['form.extensions']) && class_exists('Symfony\\Bridge\\Doctrine\\Form\\DoctrineOrmExtension')) {
         $container['form.extensions'] = $container->share($container->extend('form.extensions', function ($extensions, $container) {
             $extensions[] = new DoctrineOrmExtension($container['doctrine']);
             return $extensions;
         }));
     }
     if (isset($container['validator']) && class_exists('Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntityValidator')) {
         $container['doctrine.orm.validator.unique_validator'] = $container->share(function ($container) {
             return new UniqueEntityValidator($container['doctrine']);
         });
         if (!isset($container['validator.validator_service_ids'])) {
             $container['validator.validator_service_ids'] = array();
         }
         $container['validator.validator_service_ids'] = array_merge($container['validator.validator_service_ids'], array('doctrine.orm.validator.unique' => 'doctrine.orm.validator.unique_validator'));
         $container['validator.object_initializers'] = $container->share($container->extend('validator.object_initializers', function (array $objectInitializers) use($container) {
             $objectInitializers[] = new DoctrineInitializer($container['doctrine']);
             return $objectInitializers;
         }));
     }
     if (class_exists('Saxulum\\DoctrineOrmCommands\\Command\\CreateDatabaseDoctrineCommand')) {
         if (isset($container['console'])) {
             $container['console'] = $container->share($container->extend('console', function (ConsoleApplication $consoleApplication) use($container) {
                 $helperSet = $consoleApplication->getHelperSet();
                 $helperSet->set(new ManagerRegistryHelper($container['doctrine']), 'doctrine');
                 return $consoleApplication;
             }));
         }
         if (isset($container['console.commands'])) {
             $container['console.commands'] = $container->share($container->extend('console.commands', function ($commands) use($container) {
                 $commands[] = new CreateDatabaseDoctrineCommand();
                 $commands[] = new DropDatabaseDoctrineCommand();
                 $commands[] = new CreateSchemaDoctrineCommand();
                 $commands[] = new UpdateSchemaDoctrineCommand();
                 $commands[] = new DropSchemaDoctrineCommand();
                 $commands[] = new RunDqlDoctrineCommand();
                 $commands[] = new RunSqlDoctrineCommand();
                 $commands[] = new ConvertMappingDoctrineCommand();
                 $commands[] = new ClearMetadataCacheDoctrineCommand();
                 $commands[] = new ClearQueryCacheDoctrineCommand();
                 $commands[] = new ClearResultCacheDoctrineCommand();
                 $commands[] = new InfoDoctrineCommand();
                 $commands[] = new ValidateSchemaCommand();
                 $commands[] = new EnsureProductionSettingsDoctrineCommand();
                 return $commands;
             }));
         }
     }
 }
開發者ID:ygeneration666,項目名稱:ec,代碼行數:53,代碼來源:DoctrineOrmManagerRegistryProvider.php

示例2: 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

示例3: process

 public function process(Definition $serviceConf, array $tags, \Pimple $container)
 {
     foreach ($tags as $tag) {
         if (strtolower($tag['name']) === 'konfigurator.event_listener') {
             $container[$this->dispatcher] = $container->extend($this->dispatcher, function ($dispatcher, $c) use($serviceConf, $tag) {
                 $dispatcher->addListener($tag['event'], function () use($serviceConf, $tag, $c) {
                     $service = $serviceConf->getName();
                     $method = $tag['method'];
                     if (isset($c[$service])) {
                         return call_user_func_array(array($c[$service], $method), func_get_args());
                     }
                     return false;
                 });
                 return $dispatcher;
             });
         }
     }
 }
開發者ID:td7650,項目名稱:yml2pimple,代碼行數:18,代碼來源:EventListenerTagHandler.php

示例4: extend

 /**
  * {@inheritdoc}
  */
 public function extend($id, $callable)
 {
     return $this->container->extend($id, $callable);
 }
開發者ID:johndotcat,項目名稱:bolt,代碼行數:7,代碼來源:ContainerProxy.php


注:本文中的Pimple::extend方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。