public function detect(InternetMediaTypeParserInterface $internetMediaTypeParser, $input = null, Metadata $metadata = null)
 {
     if (null === $metadata) {
         return null;
     }
     $filepath = $metadata->get(Metadata::RESOURCE_NAME_KEY);
     if (null === $filepath) {
         return null;
     }
     $extension = strtolower(pathinfo($filepath, PATHINFO_EXTENSION));
     $type = $this->repository->findType($extension);
     if (null !== $type) {
         return $internetMediaTypeParser->parse($type);
     }
     return null;
 }
Example #2
0
 public function detectFromFilename($filename)
 {
     $metadata = new Metadata();
     $metadata->set(Metadata::RESOURCE_NAME_KEY, $filename);
     return $this->normalizeInternetMediaType($this->detector->detect($this->internetMediaTypeParser, null, $metadata));
 }