Same name in other branches
  1. 5.0.x advagg_validator/src/Form/CssW3Form.php \Drupal\advagg_validator\Form\CssW3Form::parseSoapResponse()
  2. 6.0.x advagg_validator/src/Form/CssW3Form.php \Drupal\advagg_validator\Form\CssW3Form::parseSoapResponse()
  3. 8.x-2.x advagg_validator/src/Form/CssW3Form.php \Drupal\advagg_validator\Form\CssW3Form::parseSoapResponse()
  4. 8.x-4.x advagg_validator/src/Form/CssW3Form.php \Drupal\advagg_validator\Form\CssW3Form::parseSoapResponse()
1 call to CssW3Form::parseSoapResponse()
CssW3Form::testW3C in advagg_validator/src/Form/CssW3Form.php
Given a CSS file, test to make sure it is valid CSS.

File

advagg_validator/src/Form/CssW3Form.php, line 253

Class

CssW3Form
Configure form for W3C validation of CSS files.

Namespace

Drupal\advagg_validator\Form

Code

private function parseSoapResponse($xml) {
    $doc = new DOMDocument();
    $response = [];
    // Try to load soap 1.2 XML response, and suppress warning reports if any.
    if (!@$doc->loadXML($xml)) {
        // Could not load the XML document.
        return $response;
    }
    // Get the standard CDATA elements.
    $cdata = [
        'uri',
        'checkedby',
        'csslevel',
        'date',
    ];
    foreach ($cdata as $var) {
        $element = $doc->getElementsByTagName($var);
        if ($element->length) {
            $response[$var] = $element->item(0)->nodeValue;
        }
    }
    // Handle the element validity and get errors if not valid.
    $element = $doc->getElementsByTagName('validity');
    if ($element->length && $element->item(0)->nodeValue === 'true') {
        $response['validity'] = TRUE;
    }
    else {
        $response['validity'] = FALSE;
        $errors = $doc->getElementsByTagName('error');
        foreach ($errors as $error) {
            $response['errors'][] = $this->domExtractor($error);
        }
    }
    // Get warnings.
    $warnings = $doc->getElementsByTagName('warning');
    foreach ($warnings as $warning) {
        $response['warnings'][] = $this->domExtractor($warning);
    }
    // Return response array.
    return $response;
}