/** * @inheritdoc */ public function getFileName($data, $format = null) { $basename = $this->getBaseName($data, $format); return FileSystemHelper::basename($basename); }
/** * Gets basename of the file. * @param string $format the name of formatted file version. Null (default) meaning source file. * @return string|null basename of the file. Null meaning file is empty. * @throws InvalidCallException if `$format` is not null but file has not been initialized yet. */ public function getName($format = null) { if ($format === null && $this->_name !== null) { return $this->_name; } if ($this->status === self::STATUS_INITIALIZED_FILE) { $storage = $this->context->getStorage(); if ($storage instanceof Storage) { $result = $storage->getBaseName($this->getData(), $format); } else { $result = urldecode(FileSystemHelper::basename($this->getUrl($format))); } if ($format === null) { $this->_name = $result; } return $result; } elseif ($format !== null) { throw new InvalidCallException('You cannot call ' . __FUNCTION__ . ' for formatted version of file when the last has not been initialized yet.'); } return null; }
/** * Calculates and returns file base name. * @param string $data data that should be used for loading source file. * @param string|null $format if this param is passed the method will return base name of formatted file. * @return string the MIME type. Null is returned if the MIME type cannot be determined. */ public function getBaseName($data, $format = null) { $url = $this->getUrl($data, $format); return urldecode(FileSystemHelper::basename($url)); }