aboutsummaryrefslogtreecommitdiffhomepage
path: root/main/app/sprinkles/core/src/Twig
diff options
context:
space:
mode:
authorMarvin Borner2018-05-23 22:23:28 +0200
committerMarvin Borner2018-05-23 22:23:28 +0200
commitb66a61addb6c8e66cb26fcf74b532d68891267e4 (patch)
tree05e9449ff25bdc98f68105f41923ccb9f6ef5095 /main/app/sprinkles/core/src/Twig
parent1d4ef435177a5f9b6d1a289800d933e49be0c550 (diff)
Refactored code, many fixes and improvements in chat backend+frontend
Diffstat (limited to 'main/app/sprinkles/core/src/Twig')
-rw-r--r--main/app/sprinkles/core/src/Twig/CacheHelper.php13
-rw-r--r--main/app/sprinkles/core/src/Twig/CoreExtension.php28
2 files changed, 18 insertions, 23 deletions
diff --git a/main/app/sprinkles/core/src/Twig/CacheHelper.php b/main/app/sprinkles/core/src/Twig/CacheHelper.php
index 14aea49..a3c11c6 100644
--- a/main/app/sprinkles/core/src/Twig/CacheHelper.php
+++ b/main/app/sprinkles/core/src/Twig/CacheHelper.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Twig;
use Interop\Container\ContainerInterface;
@@ -28,8 +29,7 @@ class CacheHelper
*
* @param ContainerInterface $ci The global container object, which holds all your services.
*/
- public function __construct(ContainerInterface $ci)
- {
+ public function __construct(ContainerInterface $ci) {
$this->ci = $ci;
}
@@ -39,20 +39,19 @@ class CacheHelper
* @access public
* @return bool true/false if operation is successfull
*/
- public function clearCache()
- {
+ public function clearCache() {
// Get location
- $path = $this->ci->locator->findResource('cache://twig', true, true);
+ $path = $this->ci->locator->findResource('cache://twig', TRUE, TRUE);
// Get Filesystem instance
$fs = new FileSystem;
// Make sure directory exist and delete it
if ($fs->exists($path)) {
- return $fs->deleteDirectory($path, true);
+ return $fs->deleteDirectory($path, TRUE);
}
// It's still considered a success if directory doesn't exist yet
- return true;
+ return TRUE;
}
}
diff --git a/main/app/sprinkles/core/src/Twig/CoreExtension.php b/main/app/sprinkles/core/src/Twig/CoreExtension.php
index 6a89d12..2837e84 100644
--- a/main/app/sprinkles/core/src/Twig/CoreExtension.php
+++ b/main/app/sprinkles/core/src/Twig/CoreExtension.php
@@ -5,6 +5,7 @@
* @link https://github.com/userfrosting/UserFrosting
* @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
*/
+
namespace UserFrosting\Sprinkle\Core\Twig;
use Interop\Container\ContainerInterface;
@@ -28,8 +29,7 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*
* @param ContainerInterface $services The global container object, which holds all your services.
*/
- public function __construct(ContainerInterface $services)
- {
+ public function __construct(ContainerInterface $services) {
$this->services = $services;
}
@@ -38,8 +38,7 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*
* @return string
*/
- public function getName()
- {
+ public function getName() {
return 'userfrosting/core';
}
@@ -48,11 +47,10 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*
* @return array[\Twig_SimpleFunction]
*/
- public function getFunctions()
- {
+ public function getFunctions() {
return array(
// Add Twig function for fetching alerts
- new \Twig_SimpleFunction('getAlerts', function ($clear = true) {
+ new \Twig_SimpleFunction('getAlerts', function ($clear = TRUE) {
if ($clear) {
return $this->services['alerts']->getAndClearMessages();
} else {
@@ -72,13 +70,12 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*
* @return array[\Twig_SimpleFilter]
*/
- public function getFilters()
- {
+ public function getFilters() {
return array(
/**
* Converts phone numbers to a standard format.
*
- * @param String $num A unformatted phone number
+ * @param String $num A unformatted phone number
* @return String Returns the formatted phone number
*/
new \Twig_SimpleFilter('phone', function ($num) {
@@ -95,8 +92,7 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
*
* @return array[mixed]
*/
- public function getGlobals()
- {
+ public function getGlobals() {
// CSRF token name and value
$csrfNameKey = $this->services->csrf->getTokenNameKey();
$csrfValueKey = $this->services->csrf->getTokenValueKey();
@@ -104,12 +100,12 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
$csrfValue = $this->services->csrf->getTokenValue();
$csrf = [
- 'csrf' => [
+ 'csrf' => [
'keys' => [
- 'name' => $csrfNameKey,
+ 'name' => $csrfNameKey,
'value' => $csrfValueKey
],
- 'name' => $csrfName,
+ 'name' => $csrfName,
'value' => $csrfValue
]
];
@@ -117,7 +113,7 @@ class CoreExtension extends \Twig_Extension implements \Twig_Extension_GlobalsIn
$site = array_replace_recursive($this->services->config['site'], $csrf);
return [
- 'site' => $site,
+ 'site' => $site,
'assets' => $this->services->assets
];
}