GFPDFHelperHelper_Singleton

The Gravity PDF GFPDF Helper Singleton class.

Defined (1)

The class is defined in the following location(s).

/src/helper/Helper_Singleton.php  
  1. class Helper_Singleton { 
  2.  
  3. /** 
  4. * Location for the classes 
  5. * @var array 
  6. * @since 4.0 
  7. */ 
  8. private $classes = []; 
  9.  
  10. /** 
  11. * Get the class name without the namespace 
  12. * @param object $class 
  13. * @return string 
  14. * @since 4.0 
  15. */ 
  16. private function get_class_name( $class ) { 
  17. $class_name = get_class( $class ); 
  18.  
  19. if ( $pos = strrpos( $class_name, '\\' ) ) { 
  20. return substr( $class_name, $pos + 1 ); 
  21.  
  22. return $class_name; 
  23.  
  24. /** 
  25. * Add the already-initialised class to our singleton data store for later use 
  26. * @param object $class 
  27. * @since 4.0 
  28. */ 
  29. public function add_class( $class ) { 
  30. $class_name = $this->get_class_name( $class ); 
  31.  
  32. $this->classes[ $class_name ] = $class; 
  33.  
  34. /** 
  35. * Retreive the desired class 
  36. * @param string $name 
  37. * @return object|bool 
  38. * @since 4.0 
  39. */ 
  40. public function get_class( $name ) { 
  41. if ( isset( $this->classes[ $name ] ) ) { 
  42. return $this->classes[ $name ]; 
  43.  
  44. return false;