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


PHP MvcEvent::setTarget方法代码示例

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


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

示例1: bootstrap

 public function bootstrap()
 {
     $event = new MvcEvent();
     $event->setApplication($this);
     $event->setTarget($this);
     $this->getEventManager()->trigger('bootstrap', $event);
 }
开发者ID:navassouza,项目名称:zf2,代码行数:7,代码来源:MockApplication.php

示例2: testOnDispatch

 public function testOnDispatch()
 {
     // Create MvcEvent
     $e = new MvcEvent();
     $e->setViewModel(new ViewModel());
     $rm = new RouteMatch([]);
     $rm->setParam('controller', 'Application\\Controller\\Download');
     $e->setRouteMatch($rm);
     $e->setTarget(new DownloadController([]));
     // Create EntityManager and EntityRepository
     $moduleDetail = new ModuleList();
     $moduleDetail->setModuleDesc('Pretty description');
     $repo = $this->prophesize('Doctrine\\ORM\\EntityRepository');
     $repo->findOneBy(['moduleName' => 'Application'])->willReturn($moduleDetail);
     $em = $this->prophesize('Doctrine\\ORM\\EntityManager');
     $em->getRepository('Application\\Entity\\ModuleList')->willReturn($repo);
     $this->sm->setService('Doctrine\\ORM\\EntityManager', $em->reveal());
     // Create ViewHelperManager
     $headTitle = new HeadTitle();
     $vhm = new HelperPluginManager();
     $vhm->setService('headTitle', $headTitle);
     $this->sm->setService('ViewHelperManager', $vhm);
     $this->module->onDispatch($e);
     $fbMeta = $e->getViewModel()->getVariable('fbMeta');
     $this->assertEquals(sprintf('%s-Real Live Learn ZF2', $moduleDetail->getModuleDesc()), $fbMeta['title']);
     $this->assertEquals(sprintf('%s-', $moduleDetail->getModuleDesc()), $fbMeta['description']);
 }
开发者ID:shitikovkirill,项目名称:LearnZF2,代码行数:27,代码来源:ModuleTest.php

示例3: bootstrap

 public function bootstrap()
 {
     $event = new MvcEvent();
     $event->setApplication($this);
     $event->setTarget($this);
     $this->getEventManager()->trigger(MvcEvent::EVENT_BOOTSTRAP, $event);
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:7,代码来源:MockApplication.php

示例4: setUpMvcEvent

 public function setUpMvcEvent($app, $request, $response)
 {
     $event = new MvcEvent();
     $event->setTarget($app);
     $event->setApplication($app)->setRequest($request)->setResponse($response);
     $r = new ReflectionProperty($app, 'event');
     $r->setAccessible(true);
     $r->setValue($app, $event);
     return $app;
 }
开发者ID:nuxwin,项目名称:zf-apigility,代码行数:10,代码来源:ApplicationTest.php

示例5: testNotRestoreWithoutSessionSteps

 public function testNotRestoreWithoutSessionSteps()
 {
     $listener = new StepCollectionListener();
     $event = new MvcEvent();
     $stepMock = $this->getMock('Wizard\\Step\\StepInterface');
     $stepMock->method('getWizard')->will($this->returnValue($this->getWizard()));
     $stepMock->expects($this->never())->method('setFromArray');
     $event->setTarget($stepMock);
     $listener->restore($event);
 }
开发者ID:Tribalx,项目名称:Wizard,代码行数:10,代码来源:StepCollectionListenerTest.php

示例6: testRouteListenerModifiesHalPluginToRenderCollectionsIfControllerIsRelevant

 public function testRouteListenerModifiesHalPluginToRenderCollectionsIfControllerIsRelevant()
 {
     $this->setupServiceChain();
     $this->hal->setRenderCollections(false);
     $matches = new RouteMatch(['controller' => 'ZF\\Apigility\\Admin\\Foo\\Controller']);
     $event = new MvcEvent();
     $event->setRouteMatch($matches);
     $event->setTarget($this->application);
     $this->assertNull($this->module->onRoute($event));
     $this->assertTrue($this->hal->getRenderCollections());
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:11,代码来源:ModuleTest.php

示例7: testInjectTemplate

 public function testInjectTemplate()
 {
     require_once __DIR__ . '/_files/TestController.php';
     $event = new MvcEvent();
     $routeMatch = new RouteMatch(array('action' => 'test'));
     $event->setRouteMatch($routeMatch);
     $model = $this->getMock('Zend\\View\\Model\\ViewModel', array('setTemplate'));
     $model->expects($this->once())->method('setTemplate')->with($this->equalTo('AzmTest/TestSubNamespace/test.phtml'));
     $event->setResult($model);
     $event->setTarget(new TestController());
     $this->listener->injectTemplate($event);
 }
开发者ID:argezeit,项目名称:azm-extensions,代码行数:12,代码来源:InjectTemplateListenerTest.php

示例8: testResolve

 public function testResolve()
 {
     $event = new MvcEvent();
     $controller = new AbcController();
     $event->setTarget($controller);
     $routeMatch = new RouteMatch(['action' => 'def']);
     $event->setRouteMatch($routeMatch);
     list($module, $controller, $action) = $this->testedObject->resolve($event);
     $this->assertSame('applicationcoreacltest\\model\\provider', $module);
     $this->assertSame('abc', $controller);
     $this->assertSame('def', $action);
 }
开发者ID:omusico,项目名称:zf2-demo,代码行数:12,代码来源:NamesResolverTest.php

示例9: __Construct

 public function __Construct()
 {
     $env = getenv("DB");
     switch ($env) {
         case $env == "sqlite":
             $dbfilename = "schema.sqlite.sql";
             $configFileName = "sqlite.config.php";
             break;
         case $env == "mysql":
             $dbfilename = "schema.sql";
             $configFileName = "mysql.config.php";
             break;
         case $env == "pgsql":
             $dbfilename = "schema.pgsql.sql";
             $configFileName = "pgsql.config.php";
             break;
     }
     $configuration = (include __DIR__ . '/TestConfiguration.php');
     if (isset($configuration['output_buffering']) && $configuration['output_buffering']) {
         ob_start();
         // required to test sessions
     }
     $this->serviceManager = new ServiceManager(new ServiceManagerConfig(isset($configuration['service_manager']) ? $configuration['service_manager'] : array()));
     $this->serviceManager->setService('ApplicationConfig', $configuration);
     $this->serviceManager->setFactory('ServiceListener', 'Zend\\Mvc\\Service\\ServiceListenerFactory');
     /** @var $moduleManager \Zend\ModuleManager\ModuleManager */
     $moduleManager = $this->serviceManager->get('ModuleManager');
     $moduleManager->loadModules();
     $this->serviceManager->setAllowOverride(true);
     $application = $this->serviceManager->get('Application');
     $event = new MvcEvent();
     $event->setTarget($application);
     $event->setApplication($application)->setRequest($application->getRequest())->setResponse($application->getResponse())->setRouter($this->serviceManager->get('Router'));
     /// lets create user's table
     $em = $this->serviceManager->get("doctrine.entitymanager.orm_default");
     $conn = $em->getConnection();
     if (file_exists(__DIR__ . "/../vendor/zf-commons/zfc-user/data/{$dbfilename}")) {
         $sql = file_get_contents(__DIR__ . "/../vendor/zf-commons/zfc-user/data/{$dbfilename}");
     } elseif (file_exists(__DIR__ . "/../../../../vendor/zf-commons/zfc-user/data/{$dbfilename}")) {
         $sql = file_get_contents(__DIR__ . "/../../../../vendor/zf-commons/zfc-user/data/{$dbfilename}");
     } else {
         throw new \Exception("please check the zfc user sql file", 500);
     }
     $stmt = $conn->prepare($sql);
     try {
         $stmt->execute();
     } catch (Exception $exc) {
     }
 }
开发者ID:tawfekov,项目名称:zf2entityaudit,代码行数:49,代码来源:Bootstrap.php

示例10: injectTemplate

 /**
  * Inject a template into the view model, if none present
  *
  * Template is derived from the controller found in the route match, and,
  * optionally, the action, if present.
  *
  * @param  MvcEvent $e
  * @return void
  */
 public function injectTemplate(MvcEvent $e)
 {
     /**
      * This condition fix the template name derived from the controller
      * We have to use the service name insteadof the controller class because
      * proxy manager generate a random name
      */
     $controller = $e->getTarget();
     $routeMatch = $e->getRouteMatch();
     if ($controller instanceof ProxyInterface) {
         $e->setTarget($routeMatch->getParam('controller', ''));
     }
     parent::injectTemplate($e);
     if ($controller instanceof ProxyInterface) {
         $e->setTarget($controller);
     }
 }
开发者ID:sydnerdrage,项目名称:sample-service,代码行数:26,代码来源:InjectProxyTemplateListener.php

示例11: testOnBootstrapMethodRegistersListenersWithEventManager

 /**
  * @depends testModuleDefinesServiceForContentTypeListener
  */
 public function testOnBootstrapMethodRegistersListenersWithEventManager($factory)
 {
     $serviceConfig = $this->module->getServiceConfig();
     $this->services->setFactory('ZF\\Versioning\\ContentTypeListener', $serviceConfig['factories']['ZF\\Versioning\\ContentTypeListener']);
     $this->services->setFactory('ZF\\Versioning\\AcceptListener', $serviceConfig['factories']['ZF\\Versioning\\AcceptListener']);
     $this->services->setInvokableClass('ZF\\Versioning\\VersionListener', 'ZF\\Versioning\\VersionListener');
     $event = new MvcEvent();
     $event->setTarget($this->app);
     $this->module->onBootstrap($event);
     $listeners = $this->events->getListeners(MvcEvent::EVENT_ROUTE);
     $this->assertEquals(3, count($listeners));
     $this->assertTrue($listeners->hasPriority(-40));
     $test = [];
     foreach ($listeners as $listener) {
         $callback = $listener->getCallback();
         $test[] = array_shift($callback);
     }
     $expected = ['ZF\\Versioning\\ContentTypeListener', 'ZF\\Versioning\\AcceptListener', 'ZF\\Versioning\\VersionListener'];
     foreach ($expected as $class) {
         $listener = $this->services->get($class);
         $this->assertContains($listener, $test);
     }
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:26,代码来源:ModuleTest.php

示例12: completeRequest

 /**
  * Complete the request
  *
  * Triggers "render" and "finish" events, and returns response from
  * event object.
  *
  * @param  MvcEvent $event
  * @return Application
  */
 protected function completeRequest(MvcEvent $event)
 {
     $events = $this->getEventManager();
     $event->setTarget($this);
     $events->trigger(MvcEvent::EVENT_RENDER, $event);
     $events->trigger(MvcEvent::EVENT_FINISH, $event);
     return $this;
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:17,代码来源:Application.php

示例13: prepareEvent

 private function prepareEvent($forApi = false)
 {
     if ($forApi) {
         $controllerMock = $this->getMock(AbstractApiActionController::class);
     } else {
         $controllerMock = $this->getMock(AbstractActionController::class);
     }
     $routerFactory = new RouterFactory();
     $router = $routerFactory->createService(Bootstrap::getServiceManager());
     $event = new MvcEvent();
     $event->setTarget($controllerMock);
     $event->setRouter($router);
     $event->setResponse(new Response());
     return $event;
 }
开发者ID:omusico,项目名称:zf2-demo,代码行数:15,代码来源:AclServiceTest.php

示例14: getMvcEvent

 /**
  * Get the MVC event instance
  * 
  * @return MvcEvent
  */
 public function getMvcEvent()
 {
     if ($this->event) {
         return $this->event;
     }
     $this->event = $event = new MvcEvent();
     $event->setTarget($this);
     $event->setRequest($this->getRequest())->setResponse($this->getResponse())->setRouter($this->getRouter());
     return $event;
 }
开发者ID:ranxin1022,项目名称:zf2,代码行数:15,代码来源:Application.php

示例15: testDecodingMultipartFormDataWithFileRegistersFileCleanupEventListener

 public function testDecodingMultipartFormDataWithFileRegistersFileCleanupEventListener()
 {
     $request = new Request();
     $request->setMethod('PATCH');
     $request->getHeaders()->addHeaderLine('Content-Type', 'multipart/form-data; boundary=6603ddd555b044dc9a022f3ad9281c20');
     $request->setContent(file_get_contents(__DIR__ . '/TestAsset/multipart-form-data.txt'));
     $target = new TestAsset\EventTarget();
     $events = $this->getMock('Zend\\EventManager\\EventManagerInterface');
     $events->expects($this->once())->method('attach')->with($this->equalTo('finish'), $this->equalTo(array($this->listener, 'onFinish')), $this->equalTo(1000));
     $target->events = $events;
     $event = new MvcEvent();
     $event->setTarget($target);
     $event->setRequest($request);
     $event->setRouteMatch(new RouteMatch(array()));
     $listener = $this->listener;
     $result = $listener($event);
 }
开发者ID:alapini,项目名称:apigility-3hr-tutorial,代码行数:17,代码来源:ContentTypeListenerTest.php


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