public function initialize(EventDispatcherInterface $dispatcher) { $dispatcher->connect(function (PopulateOptionsEvent $event) { if (!$event->resource->isCollection()) { $event->addAllowedMethod(WebDav::METHOD_PUT); } }); }
public function initialize(EventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; $dispatcher->connect(function (PopulateOptionsEvent $event) { $event->addAllowedMethod(WebDav::METHOD_REPORT); }); $dispatcher->connect([$this, 'serializePropertyNames']); $dispatcher->connect([$this, 'serializeProperties']); }
/** * {@inheritDoc} */ public function terminate(HttpRequest $request, HttpResponse $response) { $this->dispatcher->notify(new SendResponseEvent($request, self::MASTER_REQUEST, $response, $this)); while (ob_get_level() > 1) { ob_end_flush(); } $buffer = ob_get_level() ? ob_get_clean() : ''; ini_set('default_mimetype', NULL); ini_set('default_charset', NULL); if ($response->hasEntity() && !$request->isHead()) { if ('gzip' == strtolower($response->getHeader('Content-Encoding', ''))) { ini_set('zlib.output_compression_level', 1); ini_set('zlib.output_compression', 4096); } else { ob_start(NULL, 4096); } } foreach ($response->getHeaders() as $n => $headers) { switch ($n) { case 'server': case 'connection': case 'content-length': case 'content-encoding': case 'transfer-encoding': continue 2; } foreach ($headers as $index => $header) { header(sprintf('%s: %s', $header[0], $header[1]), $index == 0); } } $statusLine = sprintf('%s %u %s', $response->getProtocol(), $response->getStatus(), $response->getReason()); header($statusLine, true, $response->getStatus()); if ($response->hasEntity() && !$request->isHead()) { $stream = new UrlStream('php://output', 'wb'); try { $response->getEntity()->send($stream); } finally { $stream->close(); } } if (function_exists('fastcgi_finish_request')) { @fastcgi_finish_request(); } $event = new TerminateEvent($request, self::MASTER_REQUEST, $response, $this); $event->bufferedContent = $buffer; $this->dispatcher->notify($event); }
/** * {@inheritdoc} */ public function notify($event) { $this->eventDispatcher->notify($event); }
/** * Dispatch the given notification event. * * @param object $event */ public function notify($event) { if ($this->eventDispatcher !== NULL) { $this->eventDispatcher->notify($event); } }
public function initialize(EventDispatcherInterface $dispatcher) { $dispatcher->connect([$this, 'populateOptions']); $dispatcher->connect([$this, 'serializeProperties']); $dispatcher->connect([$this, 'serializePropertyNames']); }
public function initialize(EventDispatcherInterface $dispatcher) { $dispatcher->connect(function (PopulateOptionsEvent $event) { $event->addAllowedMethod(WebDav::METHOD_PROPPATCH); }); }
/** * Trigger the context-bound event for the given context. * * @param ExpressContext $context */ public function triggerContextBound(ExpressContext $context) { if ($this->eventDispatcher) { $this->eventDispatcher->notify(new ExpressContextBoundEvent($context)); } }
public function bootEventSubscriptions(ContainerInterface $container, EventDispatcherInterface $dispatcher) { $container->eachMarked(function (EventListener $event, BindingInterface $binding) use($container, $dispatcher) { $dispatcher->attach($event->event, new BindingListener($container, $binding, $event->method, $event->lazy), $event->priority); }); }
public function initialize(EventDispatcherInterface $dispatcher) { $dispatcher->connect(function (PopulateOptionsEvent $event) { $event->addFeature('extended-mkcol'); }); }
public function bootEvents(EventDispatcherInterface $dispatcher) { $dispatcher->connect(function (ExpressContextBoundEvent $event, Configuration $config) { $event->set('@config', $config); }); }