private $logger;
/**
- * Constructor.
- *
* Primary job is to initialize the XMLParser
+ * @param LoggerInterface|null $logger
*/
function __construct( LoggerInterface $logger = null ) {
-
if ( !function_exists( 'xml_parser_create_ns' ) ) {
// this should already be checked by this point
throw new RuntimeException( 'XMP support requires XML Parser' );
* For example in jpeg's with extendedXMP
*/
private function resetXMLParser() {
-
$this->destroyXMLParser();
$this->xmlParser = xml_parser_create_ns( 'UTF-8', ' ' );
/**
* Check if this instance supports using this class
+ * @return bool
*/
public static function isSupported() {
return function_exists( 'xml_parser_create_ns' ) && class_exists( 'XMLReader' );
* @throws RuntimeException On invalid data
*/
function char( $parser, $data ) {
-
$data = trim( $data );
if ( trim( $data ) === "" ) {
return;
* @throws RuntimeException
*/
private function endElementNested( $elm ) {
-
/* cur item must be the same as $elm, unless if in MODE_STRUCT
* in which case it could also be rdf:Description */
if ( $this->curItem[0] !== $elm
* @param string $elm Namespace and element
*/
private function endElementModeQDesc( $elm ) {
-
if ( $elm === self::NS_RDF . ' value' ) {
list( $ns, $tag ) = explode( ' ', $this->curItem[0], 2 );
$this->saveValue( $ns, $tag, $this->charContent );
* @throws RuntimeException
*/
function startElement( $parser, $elm, $attribs ) {
-
if ( $elm === self::NS_RDF . ' RDF'
|| $elm === 'adobe:ns:meta/ xmpmeta'
|| $elm === 'adobe:ns:meta/ xapmeta'
* @param string $val Value to save
*/
private function saveValue( $ns, $tag, $val ) {
-
$info =& $this->items[$ns][$tag];
$finalName = isset( $info['map_name'] )
? $info['map_name'] : $tag;