Extracts metadata from a PDF.

@return array
511679
public function readMetadata(): array
    {
        try {
            $parser = new Parser();
            $pdf = $parser->parseFile($this->file->getPathname());

            return $pdf->getDetails();
        } catch (Exception $e) {
            return [];
        }
    }
1113647
public function getAttachmentPdf()
    {
        $response = $this->api->get(
            $this->url() . '/attachment.pdf',
            null,
            'application/json'
        );

        return base64_decode($response->data->content);
    }
870252
public function getMetas()
    {
        $ret = array();

        if (!isset($this->metas['title']) && $this->getParameter('nyroDev_utility.share.title')) {
            $this->setTitle($this->getParameter('nyroDev_utility.share.title'));
        }
        if (!isset($this->metas['description']) && $this->getParameter('nyroDev_utility.share.description')) {
            $this->setDescription($this->getParameter('nyroDev_utility.share.description'));
        }
        if (!isset($this->metas['keywords']) && $this->getParameter('nyroDev_utility.share.keywords')) {
            $this->set('keywords', $this->getParameter('nyroDev_utility.share.keywords'));
        }
        if (!isset($this->metasProp['og:image']) && $this->getParameter('nyroDev_utility.share.image')) {
            $this->setImage($this->getParameter('nyroDev_utility.share.image'));
        }

        if (isset($this->metas['title']) && $this->metas['title']) {
            $ret[] = '<title>'.$this->metas['title'].'</title>';
            unset($this->metas['title']);
        }

        foreach ($this->metas as $k => $v) {
            $ret[] = '<meta name="'.$k.'" content="'.str_replace('"', '&quot;', $v).'" />';
        }
        foreach ($this->metasProp as $k => $v) {
            $ret[] = '<meta property="'.$k.'" content="'.str_replace('"', '&quot;', $v).'" />';
        }

        return implode("\n", $ret);
    }
1361449
protected function initMetadata() {
		if (! is_file($this->metadataPath)) {
			$this->metadata = [];
			
			return $this->metadata;
		}
		
		$metaRaw = file_get_contents($this->metadataPath);

		if ($metaRaw === false) {
			throw new Exceptions\MetadataError('Unable to read the metadata');
		}

		$meta = json_decode($metaRaw);

		if ($meta === null) {
			throw new Exceptions\MetadataError('Error in the metadata; Errorcode: ' . json_last_error());
		}

		$this->metadata = (array) $meta;

		return $this->metadata;
	}
246974
public function getMetadata()
    {
        if ($this->metadata !== null) {
            /* We have already downloaded the metdata. */
            return $this->metadata;
        }

        if (!$this->aggregator->isCacheValid($this->cacheId, $this->cacheTag)) {
            $this->updateCache();
            /** @psalm-suppress TypeDoesNotContainType */
            if ($this->metadata !== null) {
                return $this->metadata;
            }
            /* We were unable to update the cache - use cached metadata. */
        }

        $cacheFile = $this->aggregator->getCacheFile($this->cacheId);

        if (is_null($cacheFile) || !file_exists($cacheFile)) {
            Logger::error($this->logLoc . 'No cached metadata available.');
            return null;
        }

        Logger::debug($this->logLoc.'Using cached metadata from '.var_export($cacheFile, true));

        $metadata = file_get_contents($cacheFile);
        if ($metadata !== false) {
            $this->metadata = unserialize($metadata);
            return $this->metadata;
        }

        return null;
    }
1170504
public function getMetaData(string $path): array
    {
        $location = $this->applyBasePath($path);
        $info     = new SplFileInfo($location);
        $metadata = $this->normalizeFileInfo($info);

        unset($location, $info);

        return $metadata === null ? [] : $metadata;
    }
1057069
private function getMetaAndAliases()
    {
        $arr = explode('.', $this->field);
        $meta = $this->getClassMetadata();
        $metaAnterior = [];
        $parent = '';
        $alias = '';

        for ($i = 0; $i <= $this->position; $i++) {
            $metaAnterior = $meta;

            if ($meta->hasAssociation($arr[$i])) {
                $class = $meta->getAssociationTargetClass($arr[$i]);
            } elseif (count($meta->subClasses) > 0) {
                $temp = $this->getSubClassFields($meta, $arr[$i]);
                if (!empty($temp['meta'])) {
                    $class = $temp['table'];
                }
            }

            $meta = $this->em->getClassMetadata($class);

            if ($i < $this->position) {
                $parent .= $parent != '' ? '_' : '';
                $parent .= $arr[$i];
            }
            if ($i == $this->position) {
                $alias .= $parent;
                $alias .= $parent != '' ? '_' : '';
                $alias .= $arr[$i];
            }
        }

        if ($parent == '' && $alias != '') {
            $parent = self::DEFAULT_TABLE_ALIAS;
        }
        if ($alias == '') {
            $alias = self::DEFAULT_TABLE_ALIAS;
        }

        return [
            'meta'        => $meta,
            'parentMeta'  => $metaAnterior,
            'alias'       => $alias,
            'parentAlias' => $parent,
        ];
    }
1057743
public function getFilename()
    {
        if (isset($this->pdfConfig['filename'])) {
            return $this->pdfConfig['filename'];
        }

        $id = current($this->request->getParam('pass'));

        return strtolower($this->getTemplatePath()) . $id . '.pdf';
    }
966357
public function getMetadata(string $path): array
    {
        $parameters = [
            'path' => $this->normalizePath($path),
        ];

        return $this->rpcEndpointRequest('files/get_metadata', $parameters);
    }
306041
public static function get_meta_data()
    {
        $data = self::$meta_data;
        
        $defaults = array(
            'Description' => _t('DocumentationViewer.OPENSEARCHDESC', 'Search the documentation'),
            'Tags' => _t('DocumentationViewer.OPENSEARCHTAGS', 'documentation'),
            'Contact' => Config::inst()->get('Email', 'admin_email'),
            'ShortName' => _t('DocumentationViewer.OPENSEARCHNAME', 'Documentation Search'),
            'Author' => 'SilverStripe'
        );
        
        foreach ($defaults as $key => $value) {
            if (isset($data[$key])) {
                $defaults[$key] = $data[$key];
            }
        }
        
        return $defaults;
    }
513441
protected function extractTitles()
    {
        $result = [];
        $count = count($this->registries) - 1;
        for ($lot_id = 1; $lot_id < $count; $lot_id++) {
            $buffer = [];

            foreach ($this->registries[$lot_id][1] as $registry) {
                switch ($registry->getType()) {
                    case 'TITLE_T':
                        $data = [
                            'assignment' => $this->detectAssignment($registry)->id ?? null,
                            'our_number' => (int) $registry->our_number,
                            'value' => (float) ($registry->value / 100.0),
                            'tax' => (float) ($registry->tax / 100.0),
                            'due' => static::parseDate($registry->due),
                            'occurrence' => $this->occurrence($registry) ?? $registry->occurrence,
                        ];
                        $data['id'] = static::detectTitle($data);
                        break;

                    case 'TITLE_U':
                        $data = [
                            'value_received' => (float) ($registry->value_received / 100.0),
                            'occurrence_date' => static::parseDate($registry->occurrence_date),
                        ];
                        break;
                }

                $key = $registry->lot_registry;
                $buffer[$key] = array_merge($buffer[$key] ?? [], $data);
            }

            $result = array_merge($result, array_values($buffer));
        }

        return $result;
    }
38802
public function extract($object)
    {
        $pdfConverterHydrator = new PdfConverterHydrator();

        return [
            'responseStatus' => $object->getResponseStatus(),
            'sourceContainer' => $pdfConverterHydrator->extract($object->getSourceContainer()),
            'url' => $object->getUrl(),
        ];
    }
1049385
public function getMetadata()
    {
        $schema = array();
        foreach ($this->from as $path) {
            if (is_dir($path)) {
                $files = glob($path . '/*.yml');
                foreach ($files as $file) {
                    $schema = array_merge($schema, (array) Yaml::parse(file_get_contents($file)));
                }
            } else {
                $schema = array_merge($schema, (array) Yaml::parse(file_get_contents($path)));
            }
        }

        $metadatas = array();
        foreach ($schema as $className => $mappingInformation) {
            $metadatas[] = $this->convertToClassMetadataInfo($className, $mappingInformation);
        }

        return $metadatas;
    }
838006
public function getMetaData()
    {
        $data = [];

        $data['url'] = $this->request->getUri();

        $data['httpMethod'] = $this->request->getMethod();

        $data['params'] = $this->getInput() + $this->request->query->all();

        $data['clientIp'] = $this->request->getClientIp();

        if ($agent = $this->request->headers->get('User-Agent')) {
            $data['userAgent'] = $agent;
        }

        if ($headers = $this->request->headers->all()) {
            $data['headers'] = $headers;
        }

        return ['request' => $data];
    }
874853
public function extractLinks()
    {
        if ($this->extractedLinks) {
            return $this->extractedLinks;
        }

        if (!is_html($this->body)) {
            return [];
        }

        $libxmlPreviousState = libxml_use_internal_errors(true);

        $dom = new DOMDocument;
        $dom->loadHTML($this->body);

        libxml_clear_errors();
        libxml_use_internal_errors($libxmlPreviousState);

        $links = [];

        foreach ($this->tags as $tag => $attribute) {
            foreach ($dom->getElementsByTagName($tag) as $element) {
                $link = $element->getAttribute($attribute);

                if (!$link) {
                    continue;
                }

                $links[] = clean_url(url_to_absolute($this->url, $link), true, true);
            }
        }

        return $this->extractedLinks = array_unique($links);
    }
1253988
public function getAllDocuments(): array
    {
        $documents = [];

        foreach ($this->filesystem->listContents('/'.$this->path) as $info) {
            $id = $info['filename'];

            if ($this->hasDocument($id)) {
                $documents[$id] = $this->getDocument($id);
            }
        }

        return $documents;
    }
343471
public function getMetadata()
    {
        if (isset($this->raw->metadata)) {
            if (is_object($this->raw->metadata)) {
                return (array) $this->raw->metadata;
            }

            return $this->raw->metadata;
        }

        return null;
    }