Returns the renderer for the given format.

@param string $format

@throws \AltThree\Badger\Exceptions\InvalidRendererException

@return \AltThree\Badger\Render\RenderInterface
367
protected function getRendererForFormat(string $format)
    {
        if (!isset($this->renderers[$format])) {
            throw new InvalidRendererException('No renders found for the given format: '.$format);
        }

        return $this->renderers[$format];
    }
225534
public function getRenderer()
    {
        $locator = $this->getServiceLocator();
        if (null === $this->renderer && $locator->has(Renderer\RendererInterface::class)) {
            $this->setRenderer($locator->get(Renderer\RendererInterface::class));
        }

        return $this->renderer;
    }
1293996
public function format($format = true)
    {
        if (!is_bool($format)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be boolean, %s given', __METHOD__, gettype($format)));
        }

        $this->document->formatOutput = $format;

        return $this;
    }
1370070
public function loadRenderer($type)
	{
		$class = __NAMESPACE__ . '\\Type\\' . ucfirst($this->_type) . '\\' . ucfirst($type);

		if (!class_exists($class))
		{
			throw new \InvalidArgumentException(\Lang::txt('Unable to load renderer class'), 500);
		}

		return new $class($this);
	}
968594
public function resolve(FormatInterface $format)
    {
        foreach ($this->renderers as $render) {

            if ($render->getFormat() === $format->getName()) {
                return $render;
            }
        }

        throw new \Exception('Render not found');
    }
454522
public function toString(string $format = self::FORMAT_XML, bool $gzip = false): string
    {
        switch ($format) {
            case self::FORMAT_XML:
                return $this->toXmlString($gzip);
            case self::FORMAT_TXT:
                return $this->toTxtString($gzip);
            default:
                throw new \InvalidArgumentException('Unknown format');

        }
    }
1146945
public function generate($format = 'php')
    {
        // Check if the generator for this format exists
        $method = 'generate'.ucfirst($format).'Helper';
        if (method_exists($this, $method)) {
            return $this->$method();
        }

        return $this->generatePhpHelper();
    }
984600
public function setFormat($format)
    {
        if (!in_array($format, $this->formats)) {
            $msg = "The '%s' format is not allowed. Try with '%s'";
            throw new InvalidArgumentException(sprintf($msg, $format, implode("', '", $this->formats)));
        }

        $this->format = $format;

        return $this;
    }
1163438
public static function fromString(string $format)
    {
        if (preg_match('/^(([^-]|--)+)-(([^-]|--)+)-(([^-]|--)+)\.(svg|png|gif|jpg)$/', $format, $match) === false && (7 != count($match))) {
            throw new InvalidArgumentException('The given format string is invalid: '.$format);
        }

        $subject = $match[1];
        $status = $match[3];
        $color = $match[5];
        $format = $match[7];

        return new self($subject, $status, $color, $format);
    }
356630
public function format($format)
    {
        if(Format::exist($format))
            $this->format = Format::get($format);
        else
            Format::invalidType();

        return $this;
    }
1185995
public function setFormat(FormatInterface $format)
    {
        $this->formatId = $format->getName();

        return parent::setFormat($format);
    }
456488
public static function renderDateTime(DateTime $dateTime = null, $format = self::DATETIME_FORMAT) {
        if (null === $dateTime) {
            return "";
        }
        return $dateTime->format($format);
    }
780366
public function getRenderer()
    {
        $collectorClass = get_class($this);
        $rendererClass = '\\' . str_replace('Collectors', 'Renderer\\Html', $collectorClass);

        if (!class_exists($rendererClass)) {
            throw new \RuntimeException('Collector ' . $collectorClass . ' is renderable but ' . $rendererClass . ' does not exist');
        }

        return new $rendererClass;
    }
1319715
public function format($format = null)
    {
        $format ?: $format = $this->format;

        return strtr($format, $this->getFormattedReplacements());
    }
121650
public function getFluidRendererForTemplate(string $template, string $format = 'html') {
    $configurationManager = $this->objectManager->get(ConfigurationManagerInterface::class);
    $configuration        = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
    $layoutRootPath       = $configuration['view']['layoutRootPath'];

    if (empty($layoutRootPath)) {
      $firstLayoutRootPath = reset($configuration['view']['layoutRootPaths']);

      $layoutRootPath = GeneralUtility::getFileAbsFileName($firstLayoutRootPath);
    } else {
      $layoutRootPath = GeneralUtility::getFileAbsFileName($layoutRootPath);
    }

    $templateRootPath = $configuration['view']['templateRootPath'];

    if (empty($templateRootPath)) {
      $firstTemplateRootPath = reset($configuration['view']['templateRootPaths']);

      $templateRootPath = GeneralUtility::getFileAbsFileName($firstTemplateRootPath);
    } else {
      $templateRootPath = GeneralUtility::getFileAbsFileName($templateRootPath);
    }

    $partialRootPath = $configuration['view']['partialRootPath'];

    if (empty($partialRootPath)) {
      $firstPartialRootPath = reset($configuration['view']['partialRootPaths']);

      $partialRootPath = GeneralUtility::getFileAbsFileName($firstPartialRootPath);
    } else {
      $partialRootPath = GeneralUtility::getFileAbsFileName($partialRootPath);
    }

    $renderer = $this->objectManager->get(StandaloneView::class);
    $renderer->setLayoutRootPaths([$layoutRootPath]);
    $renderer->setPartialRootPaths([$partialRootPath]);
    $renderer->setTemplatePathAndFilename($templateRootPath . $template);
    $renderer->setFormat($format);

    return $renderer;
  }
469793
public function Format($format)
    {
        if (!$this->value) {
            return null;
        }
        $formatter = $this->getFormatter();
        $formatter->setPattern($format);
        return $formatter->format($this->getTimestamp());
    }
69145
private static function getRenderer($id)
    {
        if (!isset(self::$renderers[$id])) {
            throw new \InvalidArgumentException("no such renderer: ".$id);
        }
        return self::$renderers[$id];
    }