Utility.php in Views PDF 8
Contains \Drupal\views_pdf\Share\Utility
Namespace
Drupal\views_pdf\ShareFile
src/Share/Utility.phpView source
<?php
/**
* @file
* Contains \Drupal\views_pdf\Share\Utility
*/
namespace Drupal\views_pdf\Share;
trait Utility {
/**
* Create a new reflection class.
*
* @param string $class Class name string
*
* @return \ReflectionClass|NULL
*/
private static function reflectionClass(string $class) {
$reflection = NULL;
try {
$reflection = new \ReflectionClass($class);
} catch (\ReflectionException $e) {
\Drupal::logger('views_pdf')
->error($e
->getMessage());
}
return $reflection;
}
/**
* Help to get the TCPDF path.
*
* @return string
*/
protected static function getPathTcpdf() {
$tcpdfPath = self::reflectionClass(\TCPDF::class);
return $tcpdfPath !== NULL ? dirname($tcpdfPath
->getFileName()) : '';
}
/**
* Help to get the Fonts path from TCPDF.
*
* @return string
*/
protected static function getKPathFonts() {
$tcpdfPath = self::getPathTcpdf();
return !empty($tcpdfPath) ? $tcpdfPath . '/fonts/' : '';
}
}