Sulu\Bundle\MediaBundle\Media\FormatLoader\XmlFormatLoader10::getScaleFromFormatNode PHP Method

getScaleFromFormatNode() protected method

protected getScaleFromFormatNode ( DOMNode $formatNode )
$formatNode DOMNode
    protected function getScaleFromFormatNode(\DOMNode $formatNode)
    {
        foreach ($this->xpath->query('x:commands/x:command', $formatNode) as $commandNode) {
            $action = $this->xpath->query('x:action', $commandNode)->item(0)->nodeValue;
            if ($action === 'scale' || $action === 'resize') {
                $xNode = $this->xpath->query('x:parameters/x:parameter[@name = "x"]', $commandNode)->item(0);
                $yNode = $this->xpath->query('x:parameters/x:parameter[@name = "y"]', $commandNode)->item(0);
                $modeNode = $this->xpath->query('x:parameters/x:parameter[@name = "mode"]', $commandNode)->item(0);
                $retinaNode = $this->xpath->query('x:parameters/x:parameter[@name = "retina"]', $commandNode)->item(0);
                $forceRatioNode = $this->xpath->query('x:parameters/x:parameter[@name = "forceRatio"]', $commandNode)->item(0);
                $xValue = null;
                $yValue = null;
                $forceRatio = static::SCALE_FORCE_RATIO_DEFAULT;
                $retina = static::SCALE_RETINA_DEFAULT;
                if ($xNode !== null && $xNode->nodeValue !== '') {
                    $xValue = intval($xNode->nodeValue);
                }
                if ($yNode !== null && $yNode->nodeValue !== '') {
                    $yValue = intval($yNode->nodeValue);
                }
                if ($xValue === null && $yValue === null) {
                    throw new MissingScaleDimensionException();
                }
                if ($forceRatioNode !== null && $forceRatioNode->nodeValue === 'false') {
                    $forceRatio = false;
                }
                if ($retinaNode !== null && $retinaNode->nodeValue === 'true') {
                    $retina = true;
                }
                return ['x' => $xValue, 'y' => $yValue, 'mode' => $modeNode !== null ? $modeNode->nodeValue : static::SCALE_MODE_DEFAULT, 'retina' => $retina, 'forceRatio' => $forceRatio];
            }
        }
        return;
    }