Sulu\Bundle\MediaBundle\Media\FormatLoader\BaseXmlFormatLoader::supports PHP Метод

supports() публичный Метод

Returns true if this class supports the given resource.
public supports ( mixed $resource, string $type = null ) : boolean
$resource mixed A resource
$type string The resource type
Результат boolean true if this class supports the given resource, false otherwise
    public function supports($resource, $type = null)
    {
        if (!is_string($resource) || 'xml' !== pathinfo($resource, PATHINFO_EXTENSION)) {
            return false;
        }
        $file = $this->getLocator()->locate($resource);
        $document = XmlUtils::loadFile($file);
        $namespaces = $document->documentElement->attributes->getNamedItem('schemaLocation')->nodeValue;
        $start = strpos($namespaces, static::XML_NAMESPACE_URI) + strlen(static::XML_NAMESPACE_URI) + 1;
        $namespace = substr($namespaces, $start);
        $end = strpos($namespace, ' ');
        if ($end !== false) {
            $namespace = substr($namespace, 0, $end);
        }
        return $namespace === static::SCHEMA_URI;
    }