You are here

trait Utility in Views PDF 8

Hierarchy

  • trait \Drupal\views_pdf\Share\Utility
1 file declares its use of Utility
ViewsPdfBase.php in src/ViewsPdfBase.php
Contains \Drupal\views_pdf\ViewsPdfTemplate.

File

src/Share/Utility.php, line 10
Contains \Drupal\views_pdf\Share\Utility

Namespace

Drupal\views_pdf\Share
View source
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/' : '';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Utility::getKPathFonts protected static function Help to get the Fonts path from TCPDF.
Utility::getPathTcpdf protected static function Help to get the TCPDF path.
Utility::reflectionClass private static function Create a new reflection class.