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


PHP Application::extend方法代码示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     if ($output->getVerbosity() >= OutputInterface::VERBOSITY_QUIET) {
         switch ($output->getVerbosity()) {
             default:
             case OutputInterface::VERBOSITY_NORMAL:
                 $level = Logger::WARNING;
                 break;
             case OutputInterface::VERBOSITY_VERBOSE:
                 $level = Logger::NOTICE;
                 break;
             case OutputInterface::VERBOSITY_VERY_VERBOSE:
                 $level = Logger::INFO;
                 break;
             case OutputInterface::VERBOSITY_DEBUG:
                 $level = Logger::DEBUG;
                 break;
         }
         $handler = new StreamHandler('php://stdout', $level);
         $this->container['monolog'] = $this->container->share($this->container->extend('monolog', function ($logger) use($handler) {
             $logger->pushHandler($handler);
             return $logger;
         }));
         $this->container['task-manager.logger'] = $this->container->share($this->container->extend('task-manager.logger', function ($logger) use($handler) {
             $logger->pushHandler($handler);
             return $logger;
         }));
     }
     return $this->doExecute($input, $output);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:33,代码来源:Command.php

示例2: call_user_func

use Alchemy\Phrasea\Core\Event\ApiLoadEndEvent;
use Alchemy\Phrasea\Core\Event\ApiLoadStartEvent;
use Alchemy\Phrasea\Core\Event\Subscriber\ApiOauth2ErrorsSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\ApiExceptionHandlerSubscriber;
use Monolog\Logger;
use Monolog\Processor\WebProcessor;
use Silex\Application as SilexApplication;
use Symfony\Component\HttpFoundation\Request;
return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) {
    $app = new PhraseaApplication($environment);
    $app->loadPlugins();
    $app['exception_handler'] = $app->share(function ($app) {
        return new ApiExceptionHandlerSubscriber($app);
    });
    $app['monolog'] = $app->share($app->extend('monolog', function (Logger $monolog) {
        $monolog->pushProcessor(new WebProcessor());
        return $monolog;
    }));
    $app->register(new \API_V1_Timer());
    $app['dispatcher']->dispatch(PhraseaEvents::API_LOAD_START, new ApiLoadStartEvent());
    $app->get('/api/', function (Request $request, SilexApplication $app) {
        $apiAdapter = new \API_V1_adapter($app);
        $result = new \API_V1_result($app, $request, $apiAdapter);
        return $result->set_datas(['name' => $app['conf']->get(['registry', 'general', 'title']), 'type' => 'phraseanet', 'description' => $app['conf']->get(['registry', 'general', 'description']), 'documentation' => 'https://docs.phraseanet.com/Devel', 'versions' => ['1' => ['number' => $apiAdapter->get_version(), 'uri' => '/api/v1/', 'authenticationProtocol' => 'OAuth2', 'authenticationVersion' => 'draft#v9', 'authenticationEndPoints' => ['authorization_token' => '/api/oauthv2/authorize', 'access_token' => '/api/oauthv2/token']]]])->get_response();
    });
    $app->mount('/api/oauthv2', new Oauth2());
    $app->mount('/api/v1', new V1());
    $app['dispatcher']->addSubscriber(new ApiOauth2ErrorsSubscriber($app['phraseanet.exception_handler'], $app['translator']));
    $app['dispatcher']->dispatch(PhraseaEvents::API_LOAD_END, new ApiLoadEndEvent());
    return $app;
}, isset($environment) ? $environment : PhraseaApplication::ENV_PROD);
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:31,代码来源:Api.php

示例3: addMocks

 protected function addMocks(Application $app)
 {
     $app['debug'] = true;
     $app['form.csrf_provider'] = $app->share(function () {
         return new CsrfTestProvider();
     });
     $app['url_generator'] = $app->share($app->extend('url_generator', function ($generator, $app) {
         $host = parse_url($app['conf']->get('servername'), PHP_URL_HOST);
         $generator->setContext(new RequestContext('', 'GET', $host));
         return $generator;
     }));
     $app['translator'] = $this->createTranslatorMock();
     $app['phraseanet.SE.subscriber'] = $this->getMock('Symfony\\Component\\EventDispatcher\\EventSubscriberInterface');
     $app['phraseanet.SE.subscriber']::staticExpects($this->any())->method('getSubscribedEvents')->will($this->returnValue([]));
     $app['EM'] = $app->share($app->extend('EM', function ($em) {
         $this->initializeSqliteDB();
         return $em;
     }));
     $app['browser'] = $app->share($app->extend('browser', function ($browser) {
         $browser->setUserAgent(self::USER_AGENT_FIREFOX8MAC);
         return $browser;
     }));
     $app['notification.deliverer'] = $this->getMockBuilder('Alchemy\\Phrasea\\Notification\\Deliverer')->disableOriginalConstructor()->getMock();
     $app['notification.deliverer']->expects($this->any())->method('deliver')->will($this->returnCallback(function () {
         $this->fail('Notification deliverer must be mocked');
     }));
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:27,代码来源:PhraseanetTestCase.php

示例4: call_user_func

use Alchemy\Phrasea\Core\Event\Subscriber\JsonRequestSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\DebuggerSubscriber;
use Monolog\Logger;
use Monolog\Processor\WebProcessor;
use Silex\Provider\WebProfilerServiceProvider;
use Sorien\Provider\DoctrineProfilerServiceProvider;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) {
    $app = new PhraseaApplication($environment);
    $app->loadPlugins();
    $app['exception_handler'] = $app->share(function ($app) {
        return new PhraseaExceptionHandlerSubscriber($app['phraseanet.exception_handler']);
    });
    $app['monolog'] = $app->share($app->extend('monolog', function (Logger $monolog) {
        $monolog->pushProcessor(new WebProcessor());
        return $monolog;
    }));
    $app->before(function (Request $request) use($app) {
        if (0 === strpos($request->getPathInfo(), '/setup')) {
            if (!$app['phraseanet.configuration-tester']->isInstalled()) {
                if (!$app['phraseanet.configuration-tester']->isBlank()) {
                    if ('setup_upgrade_instructions' !== $app['request']->attributes->get('_route')) {
                        return $app->redirectPath('setup_upgrade_instructions');
                    }
                }
            } elseif (!$app['phraseanet.configuration-tester']->isBlank()) {
                return $app->redirectPath('homepage');
            }
        } else {
            if (false === strpos($request->getPathInfo(), '/include/minify')) {
                $app['firewall']->requireSetup();
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:32,代码来源:Root.php

示例5: call_user_func

use Alchemy\Phrasea\Core\Event\ApiResultEvent;
use Alchemy\Phrasea\Core\Event\Subscriber\ApiOauth2ErrorsSubscriber;
use Alchemy\Phrasea\Core\Event\Subscriber\ApiExceptionHandlerSubscriber;
use Monolog\Logger;
use Monolog\Processor\WebProcessor;
use Silex\Application as SilexApplication;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
return call_user_func(function ($environment = PhraseaApplication::ENV_PROD) {
    $app = new PhraseaApplication($environment);
    $app->loadPlugins();
    $app['exception_handler'] = $app->share(function ($app) {
        return new ApiExceptionHandlerSubscriber($app);
    });
    $app['monolog'] = $app->share($app->extend('monolog', function (Logger $monolog) {
        $monolog->pushProcessor(new WebProcessor());
        return $monolog;
    }));
    // handle API content negotiation
    $app->before(function (Request $request) use($app) {
        // register custom API format
        $request->setFormat(Result::FORMAT_JSON_EXTENDED, V1::$extendedContentTypes['json']);
        $request->setFormat(Result::FORMAT_YAML_EXTENDED, V1::$extendedContentTypes['yaml']);
        $request->setFormat(Result::FORMAT_JSONP_EXTENDED, V1::$extendedContentTypes['jsonp']);
        $request->setFormat(Result::FORMAT_JSONP, array('text/javascript', 'application/javascript'));
        // handle content negociation
        $priorities = array('application/json', 'application/yaml', 'text/yaml', 'text/javascript', 'application/javascript');
        foreach (V1::$extendedContentTypes['json'] as $priorities[]) {
        }
        foreach (V1::$extendedContentTypes['yaml'] as $priorities[]) {
        }
        $format = $app['format.negociator']->getBest($request->headers->get('accept'), $priorities);
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:32,代码来源:Api.php

示例6: addMocks

 protected function addMocks(Application $app)
 {
     $app['debug'] = true;
     $app['form.csrf_provider'] = $app->share(function () {
         return new CsrfTestProvider();
     });
     $app['url_generator'] = $app->share($app->extend('url_generator', function ($generator, $app) {
         $host = parse_url($app['conf']->get('servername'), PHP_URL_HOST);
         $generator->setContext(new RequestContext('', 'GET', $host ?: $app['conf']->get('servername')));
         return $generator;
     }));
     $app['task-manager.notifier'] = $app->share($app->extend('task-manager.notifier', function (Notifier $notifier) {
         $notifier->setTimeout(0.0001);
         return $notifier;
     }));
     $app['translator'] = $this->createTranslatorMock();
     $app['phraseanet.SE.subscriber'] = new PhraseanetSeTestSubscriber();
     $app['orm.em'] = $app->extend('orm.em', function ($em, $app) {
         return $app['orm.ems'][$app['db.test.hash.key']];
     });
     $app['browser'] = $app->share($app->extend('browser', function ($browser) {
         $browser->setUserAgent(self::USER_AGENT_FIREFOX8MAC);
         return $browser;
     }));
     $app['notification.deliverer'] = $this->getMockBuilder('Alchemy\\Phrasea\\Notification\\Deliverer')->disableOriginalConstructor()->getMock();
     $app['notification.deliverer']->expects($this->any())->method('deliver')->will($this->returnCallback(function () {
         $this->fail('Notification deliverer must be mocked');
     }));
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:29,代码来源:PhraseanetTestCase.php


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