PressBooks\Modules\Import\Html\Xhtml::getLicenseAttribution PHP Метод

getLicenseAttribution() защищенный Метод

Looks for div class created by the license module in PB, returns author and license information.
protected getLicenseAttribution ( string $html ) : array
$html string
Результат array $meta
    protected function getLicenseAttribution($html)
    {
        $meta = array();
        // get license attribution statement if it exists
        preg_match('/(?:<div class="license-attribution[^>]*>)(.*)(<\\/div>)/is', $html, $matches);
        if (!empty($matches[1])) {
            // dom it up
            libxml_use_internal_errors(true);
            // Load HTMl snippet into DOMDocument using UTF-8 hack
            $utf8_hack = '<?xml version="1.0" encoding="UTF-8"?>';
            $doc = new \DOMDocument();
            $doc->loadHTML($utf8_hack . $matches[1]);
            $meta = $this->scrapeAndKneadMeta($doc);
            $errors = libxml_get_errors();
            // TODO: Handle errors gracefully
            libxml_clear_errors();
        }
        return $meta;
    }