@@ -5,29 +5,29 @@ |
||
| 5 | 5 | use Hospitalplugin\Twig\EscapePLCharsExtension; |
| 6 | 6 | |
| 7 | 7 | class PLTwig { |
| 8 | - /** |
|
| 9 | - * Loads Twig with polish settings. |
|
| 10 | - * |
|
| 11 | - * @param string $viewsDir |
|
| 12 | - * @return void|\Twig_Environment |
|
| 13 | - */ |
|
| 14 | - public static function load($viewsDir) { |
|
| 15 | - if (! class_exists ( 'Twig_Loader_Filesystem' )) { |
|
| 16 | - echo 'Twig not activated. Make sure you activate the plugin in |
|
| 8 | + /** |
|
| 9 | + * Loads Twig with polish settings. |
|
| 10 | + * |
|
| 11 | + * @param string $viewsDir |
|
| 12 | + * @return void|\Twig_Environment |
|
| 13 | + */ |
|
| 14 | + public static function load($viewsDir) { |
|
| 15 | + if (! class_exists ( 'Twig_Loader_Filesystem' )) { |
|
| 16 | + echo 'Twig not activated. Make sure you activate the plugin in |
|
| 17 | 17 | <a href="/wp-admin/plugins.php#timber">/wp-admin/plugins.php</a>'; |
| 18 | - return; |
|
| 19 | - } |
|
| 20 | - \Twig_Autoloader::register (); |
|
| 21 | - try { |
|
| 22 | - $loader = new \Twig_Loader_Filesystem ( $viewsDir ); |
|
| 23 | - $twig = new \Twig_Environment ( $loader, array () ); |
|
| 24 | - // 'debug' => true |
|
| 25 | - // 'cache' => '/tmp/' |
|
| 26 | - $twig->getExtension ( 'core' )->setTimezone ( 'Europe/Warsaw' ); // |
|
| 27 | - $twig->addExtension ( new EscapePLCharsExtension () ); |
|
| 28 | - return $twig; |
|
| 29 | - } catch ( Exception $e ) { |
|
| 30 | - echo "ERR: " . $e; |
|
| 31 | - } |
|
| 32 | - } |
|
| 18 | + return; |
|
| 19 | + } |
|
| 20 | + \Twig_Autoloader::register (); |
|
| 21 | + try { |
|
| 22 | + $loader = new \Twig_Loader_Filesystem ( $viewsDir ); |
|
| 23 | + $twig = new \Twig_Environment ( $loader, array () ); |
|
| 24 | + // 'debug' => true |
|
| 25 | + // 'cache' => '/tmp/' |
|
| 26 | + $twig->getExtension ( 'core' )->setTimezone ( 'Europe/Warsaw' ); // |
|
| 27 | + $twig->addExtension ( new EscapePLCharsExtension () ); |
|
| 28 | + return $twig; |
|
| 29 | + } catch ( Exception $e ) { |
|
| 30 | + echo "ERR: " . $e; |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | 33 | } |
| 34 | 34 | \ No newline at end of file |
@@ -12,22 +12,22 @@ |
||
| 12 | 12 | * @return void|\Twig_Environment |
| 13 | 13 | */ |
| 14 | 14 | public static function load($viewsDir) { |
| 15 | - if (! class_exists ( 'Twig_Loader_Filesystem' )) { |
|
| 15 | + if (!class_exists('Twig_Loader_Filesystem')) { |
|
| 16 | 16 | echo 'Twig not activated. Make sure you activate the plugin in |
| 17 | 17 | <a href="/wp-admin/plugins.php#timber">/wp-admin/plugins.php</a>'; |
| 18 | 18 | return; |
| 19 | 19 | } |
| 20 | - \Twig_Autoloader::register (); |
|
| 20 | + \Twig_Autoloader::register(); |
|
| 21 | 21 | try { |
| 22 | - $loader = new \Twig_Loader_Filesystem ( $viewsDir ); |
|
| 23 | - $twig = new \Twig_Environment ( $loader, array () ); |
|
| 22 | + $loader = new \Twig_Loader_Filesystem($viewsDir); |
|
| 23 | + $twig = new \Twig_Environment($loader, array()); |
|
| 24 | 24 | // 'debug' => true |
| 25 | 25 | // 'cache' => '/tmp/' |
| 26 | - $twig->getExtension ( 'core' )->setTimezone ( 'Europe/Warsaw' ); // |
|
| 27 | - $twig->addExtension ( new EscapePLCharsExtension () ); |
|
| 26 | + $twig->getExtension('core')->setTimezone('Europe/Warsaw'); // |
|
| 27 | + $twig->addExtension(new EscapePLCharsExtension()); |
|
| 28 | 28 | return $twig; |
| 29 | - } catch ( Exception $e ) { |
|
| 30 | - echo "ERR: " . $e; |
|
| 29 | + } catch (Exception $e) { |
|
| 30 | + echo "ERR: ".$e; |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | \ No newline at end of file |
@@ -1,26 +1,26 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Menu |
|
| 4 | - * |
|
| 5 | - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED |
|
| 6 | - * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. |
|
| 7 | - * |
|
| 8 | - * Permission is hereby granted to use or copy this program |
|
| 9 | - * for any purpose, provided the above notices are retained on all copies. |
|
| 10 | - * Permission to modify the code and to distribute modified code is granted, |
|
| 11 | - * provided the above notices are retained, and a notice that the code was |
|
| 12 | - * modified is included with the above copyright notice. |
|
| 13 | - * |
|
| 14 | - * @category Wp |
|
| 15 | - * @package Punction |
|
| 16 | - * @author Andrzej Marcinkowski <[email protected]> |
|
| 17 | - * @copyright 2014 Wojewódzki Szpital Zespolony, Kalisz |
|
| 18 | - * @license MIT http://opensource.org/licenses/MIT |
|
| 19 | - * @version 1.0 $Format:%H$ |
|
| 20 | - * @link http:// |
|
| 21 | - * @since File available since Release 1.0.0 |
|
| 22 | - * PHP Version 5 |
|
| 23 | - */ |
|
| 3 | + * Menu |
|
| 4 | + * |
|
| 5 | + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED |
|
| 6 | + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. |
|
| 7 | + * |
|
| 8 | + * Permission is hereby granted to use or copy this program |
|
| 9 | + * for any purpose, provided the above notices are retained on all copies. |
|
| 10 | + * Permission to modify the code and to distribute modified code is granted, |
|
| 11 | + * provided the above notices are retained, and a notice that the code was |
|
| 12 | + * modified is included with the above copyright notice. |
|
| 13 | + * |
|
| 14 | + * @category Wp |
|
| 15 | + * @package Punction |
|
| 16 | + * @author Andrzej Marcinkowski <[email protected]> |
|
| 17 | + * @copyright 2014 Wojewódzki Szpital Zespolony, Kalisz |
|
| 18 | + * @license MIT http://opensource.org/licenses/MIT |
|
| 19 | + * @version 1.0 $Format:%H$ |
|
| 20 | + * @link http:// |
|
| 21 | + * @since File available since Release 1.0.0 |
|
| 22 | + * PHP Version 5 |
|
| 23 | + */ |
|
| 24 | 24 | namespace Hospitalplugin\WP; |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * |
| 81 | - * @return entityManager EntityManager |
|
| 81 | + * @return EntityManager EntityManager |
|
| 82 | 82 | */ |
| 83 | 83 | private static function _getInstance() { |
| 84 | 84 | $isDevMode = true; |
@@ -44,76 +44,76 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | class DoctrineBootstrap { |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * entity manager |
|
| 49 | - * |
|
| 50 | - * @var _entityManager EnitytManager |
|
| 51 | - */ |
|
| 52 | - private static $_entityManager; |
|
| 47 | + /** |
|
| 48 | + * entity manager |
|
| 49 | + * |
|
| 50 | + * @var _entityManager EnitytManager |
|
| 51 | + */ |
|
| 52 | + private static $_entityManager; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * loading envs |
|
| 56 | - */ |
|
| 57 | - private static function _loadEnv() { |
|
| 58 | - if (getenv ( 'DB_NAME' ) != null && getenv ( 'DB_NAME' ) != "") { |
|
| 59 | - return; |
|
| 60 | - } |
|
| 61 | - if (defined ( 'ABSPATH' )) { |
|
| 62 | - \Dotenv::load ( ABSPATH ); |
|
| 63 | - } else { |
|
| 64 | - \Dotenv::load ( getenv ( 'HOME' ) ); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - private static function getPaths() { |
|
| 68 | - if (file_exists ( getcwd () . "/src/Entities" )) { |
|
| 69 | - return array ( |
|
| 70 | - getcwd () . "/src/Entities" |
|
| 71 | - ); |
|
| 72 | - } else { |
|
| 73 | - return array ( |
|
| 74 | - getcwd () . "/vendor/amarcinkowski/hospitalplugin/src/Entities" |
|
| 75 | - ); |
|
| 76 | - } |
|
| 77 | - } |
|
| 54 | + /** |
|
| 55 | + * loading envs |
|
| 56 | + */ |
|
| 57 | + private static function _loadEnv() { |
|
| 58 | + if (getenv ( 'DB_NAME' ) != null && getenv ( 'DB_NAME' ) != "") { |
|
| 59 | + return; |
|
| 60 | + } |
|
| 61 | + if (defined ( 'ABSPATH' )) { |
|
| 62 | + \Dotenv::load ( ABSPATH ); |
|
| 63 | + } else { |
|
| 64 | + \Dotenv::load ( getenv ( 'HOME' ) ); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + private static function getPaths() { |
|
| 68 | + if (file_exists ( getcwd () . "/src/Entities" )) { |
|
| 69 | + return array ( |
|
| 70 | + getcwd () . "/src/Entities" |
|
| 71 | + ); |
|
| 72 | + } else { |
|
| 73 | + return array ( |
|
| 74 | + getcwd () . "/vendor/amarcinkowski/hospitalplugin/src/Entities" |
|
| 75 | + ); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * |
|
| 81 | - * @return entityManager EntityManager |
|
| 82 | - */ |
|
| 83 | - private static function _getInstance() { |
|
| 84 | - $isDevMode = true; |
|
| 85 | - $config = Setup::createAnnotationMetadataConfiguration ( self::getPaths (), $isDevMode ); |
|
| 86 | - self::_loadEnv (); |
|
| 87 | - $conn = array ( |
|
| 88 | - 'dbname' => getenv ( 'DB_NAME' ), |
|
| 89 | - 'user' => getenv ( 'DB_USER' ), |
|
| 90 | - 'password' => getenv ( 'DB_PASSWORD' ), |
|
| 91 | - 'host' => getenv ( 'DB_HOST' ), |
|
| 92 | - 'driver' => 'pdo_mysql', |
|
| 93 | - 'charset' => 'utf8', |
|
| 94 | - 'driverOptions' => array ( |
|
| 95 | - 1002 => 'SET NAMES utf8' |
|
| 96 | - ), |
|
| 97 | - 'mapping_types' => 'enum:string' |
|
| 98 | - ); |
|
| 99 | - return EntityManager::create ( $conn, $config ); |
|
| 100 | - } |
|
| 79 | + /** |
|
| 80 | + * |
|
| 81 | + * @return entityManager EntityManager |
|
| 82 | + */ |
|
| 83 | + private static function _getInstance() { |
|
| 84 | + $isDevMode = true; |
|
| 85 | + $config = Setup::createAnnotationMetadataConfiguration ( self::getPaths (), $isDevMode ); |
|
| 86 | + self::_loadEnv (); |
|
| 87 | + $conn = array ( |
|
| 88 | + 'dbname' => getenv ( 'DB_NAME' ), |
|
| 89 | + 'user' => getenv ( 'DB_USER' ), |
|
| 90 | + 'password' => getenv ( 'DB_PASSWORD' ), |
|
| 91 | + 'host' => getenv ( 'DB_HOST' ), |
|
| 92 | + 'driver' => 'pdo_mysql', |
|
| 93 | + 'charset' => 'utf8', |
|
| 94 | + 'driverOptions' => array ( |
|
| 95 | + 1002 => 'SET NAMES utf8' |
|
| 96 | + ), |
|
| 97 | + 'mapping_types' => 'enum:string' |
|
| 98 | + ); |
|
| 99 | + return EntityManager::create ( $conn, $config ); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * returns enitytManager |
|
| 104 | - * |
|
| 105 | - * @return EntityManager |
|
| 106 | - */ |
|
| 107 | - public static function getEntityManager() { |
|
| 108 | - if (self::$_entityManager == null) { |
|
| 109 | - self::$_entityManager = self::_getInstance (); |
|
| 110 | - } |
|
| 111 | - return self::$_entityManager; |
|
| 112 | - } |
|
| 113 | - public static function getCli() { |
|
| 114 | - $em = DoctrineBootstrap::getEntityManager (); |
|
| 115 | - $em->getConnection ()->getDatabasePlatform ()->registerDoctrineTypeMapping ( 'enum', 'string' ); |
|
| 116 | - return ConsoleRunner::createHelperSet ( $em ); |
|
| 117 | - } |
|
| 102 | + /** |
|
| 103 | + * returns enitytManager |
|
| 104 | + * |
|
| 105 | + * @return EntityManager |
|
| 106 | + */ |
|
| 107 | + public static function getEntityManager() { |
|
| 108 | + if (self::$_entityManager == null) { |
|
| 109 | + self::$_entityManager = self::_getInstance (); |
|
| 110 | + } |
|
| 111 | + return self::$_entityManager; |
|
| 112 | + } |
|
| 113 | + public static function getCli() { |
|
| 114 | + $em = DoctrineBootstrap::getEntityManager (); |
|
| 115 | + $em->getConnection ()->getDatabasePlatform ()->registerDoctrineTypeMapping ( 'enum', 'string' ); |
|
| 116 | + return ConsoleRunner::createHelperSet ( $em ); |
|
| 117 | + } |
|
| 118 | 118 | } |
| 119 | 119 | |
@@ -55,23 +55,23 @@ discard block |
||
| 55 | 55 | * loading envs |
| 56 | 56 | */ |
| 57 | 57 | private static function _loadEnv() { |
| 58 | - if (getenv ( 'DB_NAME' ) != null && getenv ( 'DB_NAME' ) != "") { |
|
| 58 | + if (getenv('DB_NAME') != null && getenv('DB_NAME') != "") { |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | - if (defined ( 'ABSPATH' )) { |
|
| 62 | - \Dotenv::load ( ABSPATH ); |
|
| 61 | + if (defined('ABSPATH')) { |
|
| 62 | + \Dotenv::load(ABSPATH); |
|
| 63 | 63 | } else { |
| 64 | - \Dotenv::load ( getenv ( 'HOME' ) ); |
|
| 64 | + \Dotenv::load(getenv('HOME')); |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | private static function getPaths() { |
| 68 | - if (file_exists ( getcwd () . "/src/Entities" )) { |
|
| 69 | - return array ( |
|
| 70 | - getcwd () . "/src/Entities" |
|
| 68 | + if (file_exists(getcwd()."/src/Entities")) { |
|
| 69 | + return array( |
|
| 70 | + getcwd()."/src/Entities" |
|
| 71 | 71 | ); |
| 72 | 72 | } else { |
| 73 | - return array ( |
|
| 74 | - getcwd () . "/vendor/amarcinkowski/hospitalplugin/src/Entities" |
|
| 73 | + return array( |
|
| 74 | + getcwd()."/vendor/amarcinkowski/hospitalplugin/src/Entities" |
|
| 75 | 75 | ); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -82,21 +82,21 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | private static function _getInstance() { |
| 84 | 84 | $isDevMode = true; |
| 85 | - $config = Setup::createAnnotationMetadataConfiguration ( self::getPaths (), $isDevMode ); |
|
| 86 | - self::_loadEnv (); |
|
| 87 | - $conn = array ( |
|
| 88 | - 'dbname' => getenv ( 'DB_NAME' ), |
|
| 89 | - 'user' => getenv ( 'DB_USER' ), |
|
| 90 | - 'password' => getenv ( 'DB_PASSWORD' ), |
|
| 91 | - 'host' => getenv ( 'DB_HOST' ), |
|
| 85 | + $config = Setup::createAnnotationMetadataConfiguration(self::getPaths(), $isDevMode); |
|
| 86 | + self::_loadEnv(); |
|
| 87 | + $conn = array( |
|
| 88 | + 'dbname' => getenv('DB_NAME'), |
|
| 89 | + 'user' => getenv('DB_USER'), |
|
| 90 | + 'password' => getenv('DB_PASSWORD'), |
|
| 91 | + 'host' => getenv('DB_HOST'), |
|
| 92 | 92 | 'driver' => 'pdo_mysql', |
| 93 | 93 | 'charset' => 'utf8', |
| 94 | - 'driverOptions' => array ( |
|
| 94 | + 'driverOptions' => array( |
|
| 95 | 95 | 1002 => 'SET NAMES utf8' |
| 96 | 96 | ), |
| 97 | 97 | 'mapping_types' => 'enum:string' |
| 98 | 98 | ); |
| 99 | - return EntityManager::create ( $conn, $config ); |
|
| 99 | + return EntityManager::create($conn, $config); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public static function getEntityManager() { |
| 108 | 108 | if (self::$_entityManager == null) { |
| 109 | - self::$_entityManager = self::_getInstance (); |
|
| 109 | + self::$_entityManager = self::_getInstance(); |
|
| 110 | 110 | } |
| 111 | 111 | return self::$_entityManager; |
| 112 | 112 | } |
| 113 | 113 | public static function getCli() { |
| 114 | - $em = DoctrineBootstrap::getEntityManager (); |
|
| 115 | - $em->getConnection ()->getDatabasePlatform ()->registerDoctrineTypeMapping ( 'enum', 'string' ); |
|
| 116 | - return ConsoleRunner::createHelperSet ( $em ); |
|
| 114 | + $em = DoctrineBootstrap::getEntityManager(); |
|
| 115 | + $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); |
|
| 116 | + return ConsoleRunner::createHelperSet($em); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |