AttachmentsTestResponse example

/** * Sets a response given a TestDomainObject instance. * * @param \Symfony\Component\HttpKernel\Event\ViewEvent $event * The event to process. */
  public function onViewTestDomainObject(ViewEvent $event) {
    $result = $event->getControllerResult();

    if ($result instanceof TestDomainObject) {
      if ($result instanceof AttachmentsTestDomainObject) {
        $event->setResponse(new AttachmentsTestResponse('AttachmentsTestDomainObject'));
      }
      elseif ($result instanceof CacheableTestDomainObject) {
        $event->setResponse(new CacheableTestResponse('CacheableTestDomainObject'));
      }
      else {
        $event->setResponse(new Response('TestDomainObject'));
      }
    }
  }

  /** * {@inheritdoc} */
public function response() {
    return new Response('Hello world!');
  }

  public function responseEarly() {
    $render_array = $this->earlyRenderContent();
    return new Response($this->renderer->render($render_array));
  }

  public function responseWithAttachments() {
    return new AttachmentsTestResponse('Hello world!');
  }

  public function responseWithAttachmentsEarly() {
    $render_array = $this->earlyRenderContent();
    return new AttachmentsTestResponse($this->renderer->render($render_array));
  }

  public function cacheableResponse() {
    return new CacheableTestResponse('Hello world!');
  }

  
Home | Imprint | This part of the site doesn't use cookies.