Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Dev-Hayday-ViettelCO
maychumienphi.com
Commits
c9fbad69
Commit
c9fbad69
authored
5 years ago
by
scila1996
Browse files
Options
Download
Email Patches
Plain Diff
Update Source Code
parent
7c8f8cfa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
64 deletions
+30
-64
app/src/Core/Service/View.php
app/src/Core/Service/View.php
+30
-64
No files found.
app/src/Core/Service/View.php
View file @
c9fbad69
<
<<<<<<
HEAD
<?php
namespace
App\Core\Service
;
use
App\Core\DIService
;
use
Slim\Views\Twig
;
use
Slim\Views\TwigExtension
;
use
Slim\Http\Uri
;
use
Slim\Http\Environment
;
class
View
extends
DIService
{
/**
*
* @var array
*/
protected
$config
=
[];
/**
*
* @var string
*/
protected
$base_path
=
VIEW_PATH
;
public
function
inject
()
{
$views
=
$this
->
path
?
$this
->
path
:
$this
->
container
->
get
(
'settings'
)[
'views'
];
$config
=
$this
->
config
;
$base_path
=
$this
->
base_path
;
$this
->
container
[
self
::
class
]
=
function
(
$container
)
use
(
$views
,
$config
,
$base_path
)
{
$viewObj
=
new
Twig
(
$base_path
,
$config
);
foreach
(
$views
as
$namespace
=>
$view_path
)
{
$viewObj
->
getLoader
()
->
addPath
(
preg_replace
(
'/\/{2,}/'
,
'/'
,
"
{
$base_path
}
/
{
$view_path
}
"
),
$namespace
);
}
// Instantiate and add Slim specific extension
$router
=
$container
->
get
(
'router'
);
$uri
=
Uri
::
createFromEnvironment
(
new
Environment
(
$_SERVER
));
$viewObj
->
addExtension
(
new
TwigExtension
(
$router
,
$uri
));
$viewObj
->
getEnvironment
()
->
setCache
(
FALSE
);
return
$viewObj
;
};
}
}
=======
<?php
namespace
App\Core\Service
;
...
...
@@ -63,23 +10,42 @@ use Slim\Http\Environment;
class
View
extends
DIService
{
/**
*
* @var array
*/
protected
$config
=
[];
/**
*
* @var string
*/
protected
$base_path
=
VIEW_PATH
;
public
function
inject
()
{
$view_config
=
$this
->
container
->
get
(
'settings'
)[
'view'
];
$views
=
$this
->
path
?
$this
->
path
:
$this
->
container
->
get
(
'settings'
)[
'views'
];
$config
=
$this
->
config
;
$base_path
=
$this
->
base_path
;
$this
->
container
[
self
::
class
]
=
function
(
$container
)
use
(
$views
,
$config
,
$base_path
)
{
$this
->
container
[
'view'
]
=
function
(
$container
)
use
(
$view_
config
)
{
$viewObj
=
new
Twig
(
$base_path
,
$
config
)
;
$view
=
new
Twig
(
$view_config
[
'path'
],
[]);
foreach
(
$views
as
$namespace
=>
$view_path
)
{
$viewObj
->
getLoader
()
->
addPath
(
preg_replace
(
'/\/{2,}/'
,
'/'
,
"
{
$base_path
}
/
{
$view_path
}
"
),
$namespace
);
}
// Instantiate and add Slim specific extension
$router
=
$container
->
get
(
'router'
);
$uri
=
Uri
::
createFromEnvironment
(
new
Environment
(
$_SERVER
));
$view
->
addExtension
(
new
TwigExtension
(
$router
,
$uri
));
$view
->
getEnvironment
()
->
setCache
(
FALSE
);
$router
=
$container
->
get
(
'router'
);
$uri
=
Uri
::
createFromEnvironment
(
new
Environment
(
$_SERVER
));
$view
Obj
->
addExtension
(
new
TwigExtension
(
$router
,
$uri
));
$view
Obj
->
getEnvironment
()
->
setCache
(
FALSE
);
return
$view
;
};
}
return
$view
Obj
;
};
}
}
>>>>>>>
072
9
a81cb7c7996fb0edc154bf9e52b58c42847c
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment