The button-location always knows best
what the formats are... so it should be trusted.

@todo MDL-31298 - re-analyze set_formats_from_button comment
@param array $formats array of PORTFOLIO_FORMAT_XX
@return void
199378
public function set_formats_from_button($formats) {
        $base = $this->base_supported_formats();
        if (count($base) != count($formats)
                || count($base) != count(array_intersect($base, $formats))) {
                $this->supportedformats = portfolio_most_specific_formats($formats, $base);
                return;
        }
        // in the case where the button hasn't actually set anything,
        // we need to run through again and resolve conflicts
        // TODO revisit this comment - it looks to me like it's lying
        $this->supportedformats = portfolio_most_specific_formats($formats, $formats);
    }
750669
public function setFieldKeyFormat($format)
    {
        $this->validator->isFormatValid($format);
        $this->fieldKeyFormat = $format;
        return $this;
    }
632319
public function setFormat($format)
    {
        if (in_array($format, TextFormat::asArray()) === true) {
            $this->format = $format;
        } else {
            $msg = "The 'format' argument must be a value from the TextFormat enumeration, '" . gettype($format) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
23624
public function setButtons(array $buttons)
    {
        $this->buttons = array();
        foreach ($buttons as $button) {
            $this->addButton($button);
        }
        return $this;
    }
647701
public function setFormat($format, $mimeTypes)
    {
        if (null === static::$formats) {
            static::initializeFormats();
        }

        static::$formats[$format] = \is_array($mimeTypes) ? $mimeTypes : [$mimeTypes];
    }
1118948
public function setStyle(string $style): void
    {
        $style = strtolower($style);
        switch ($style) {
            case 'nested':
            case 'compact':
            case 'compressed':
            case 'expanded':
            case 'crunched':
                $this->flags = str_replace(" --style $this->style", '', $this->flags);
                $this->style = $style;
                $this->flags .= " --style $style";
                break;
            default:
                $this->log("Style $style ignored", Project::MSG_INFO);
        }
    }
146526
public function setFormat($format, $placeholder = NULL)
	{
		$this->format = $format;

		if ($placeholder === NULL) {
			$placeholder = self::makeFormatPlaceholder($format);
		}
		if (!empty($placeholder)) {
			$this->setPlaceholder($placeholder);
		}

		return $this;
	}
358655
public function setComponents(array $components)
    {
        foreach ($components as $id => $properties) {
            $this->setComponent($id, $properties);
        }
    }
921077
protected function add_format($format) {
        if (in_array($format, $this->supportedformats)) {
            return;
        }
        $this->supportedformats = portfolio_most_specific_formats(array($format), $this->supportedformats);
    }
743483
public function setInitValues(array $values)
    {
        if (isset($this->data['isSend']) == false || $this->data['isSend'] != true) {
            foreach ($this->elements as $name => $element) {
                if ($element instanceof ElementInterface) {
                    if (array_key_exists($name, $values)) {
                        $element->setValue($values[$name]);
                    }
                }
            }
        }
    }
1095463
public function setFormat($format = false)
    {
        if(!$format)
        {
            $format = \Ginger\System\Parameters::$format;
        }
        $this->format   = $format;

        if(!isset($this->allowedFormats[$this->format]))
        {
            $this->format = $this->defaultFormat;
        }
    }
1296812
public function setFormat($format) {

        $this->checkInArray($format, GDAXConstants::$reportFormatValues);
        $this->format = $format;
        return $this;

    }
84876
protected void setFormats(RTPFormats formats) {
		try {
			this.rtpChannel.setFormatMap(formats);
			this.rtpChannel.setOutputFormats(formats.getFormats());
		} catch (FormatNotSupportedException e) {
			// Never happens
			logger.warn("Could not set output formats", e);
		}
	}
664273
public function setLinks(array $links)
    {
        foreach ($links as &$href) {
            $href = ['href' => $href];
        }

        $this->links = $links;
    }
934563
private function appendStyles(array $styles)
    {
        if (empty($styles)) {
            return;
        }

        $string = '';
        $prependSemicolon = false;
        foreach ($styles as $key => $value) {
            if ($prependSemicolon) {
                $string .= '; ';
            }
            $prependSemicolon = true;
            $string .= $key.': '.$value;
        }

        $this->appendAttribute('style', $string);
    }
394470
public function setButtons(array $buttons): self
    {
        $this->isValidArray($buttons, 1);

        $this->buttons = $buttons;

        return $this;
    }
299595
public function setFormat($format) {
        if ($format === null) {
            $format = [];
        } else if ( ! is_array($format)) {
            $format = [$format];
        }

        $this->format = $format;

        return $this;
    }