Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
491bd633
Commit
491bd633
authored
Sep 14, 2013
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1987870
by disasm: Convert theme_test() callbacks to a new style controller.
parent
0aa6f4e5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
84 deletions
+109
-84
core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php
.../theme_test/lib/Drupal/theme_test/ThemeTestController.php
+70
-9
core/modules/system/tests/modules/theme_test/theme_test.module
...modules/system/tests/modules/theme_test/theme_test.module
+2
-75
core/modules/system/tests/modules/theme_test/theme_test.routing.yml
...es/system/tests/modules/theme_test/theme_test.routing.yml
+37
-0
No files found.
core/modules/system/tests/modules/theme_test/lib/Drupal/theme_test/ThemeTestController.php
View file @
491bd633
...
...
@@ -7,28 +7,89 @@
namespace
Drupal\theme_test
;
use
Drupal\Core\DependencyInjection\ContainerInjectionInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Drupal\Core\Controller\ControllerBase
;
/**
* Controller routines for theme test routes.
*/
class
ThemeTestController
implem
en
t
s
Cont
ainerInjectionInterfac
e
{
class
ThemeTestController
ext
en
d
s
Cont
rollerBas
e
{
/**
* {@inheritdoc}
* A theme template that overrides a theme function.
*
* @return array
* Render array containing a theme.
*/
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
();
public
function
functionTemplateOverridden
()
{
return
array
(
'#theme'
=>
'theme_test_function_template_override'
,
);
}
/**
* Menu callback for testing that a theme template overrides a theme function.
* Adds stylesheets to test theme .info.yml property processing.
*
* @return array
* A render array containing custom stylesheets.
*/
function
functionTemplateOverridden
()
{
public
function
testInfoStylesheets
()
{
$path
=
drupal_get_path
(
'module'
,
'theme_test'
);
return
array
(
'#theme'
=>
'theme_test_function_template_override'
,
'#attached'
=>
array
(
'css'
=>
array
(
"
$path
/css/base-override.css"
,
"
$path
/css/base-override.sub-remove.css"
,
"
$path
/css/base-remove.css"
,
"
$path
/css/base-remove.sub-override.css"
,
"
$path
/css/sub-override.css"
,
"
$path
/css/sub-remove.css"
,
),
),
);
}
/**
* Tests template overridding based on filename.
*
* @return array
* A render array containing a theme override.
*/
public
function
testTemplate
()
{
return
theme
(
'theme_test_template_test'
);
}
/**
* Calls a theme hook suggestion.
*
* @return string
* An HTML string containing the themed output.
*/
public
function
testSuggestion
()
{
return
theme
(
array
(
'theme_test__suggestion'
,
'theme_test'
),
array
());
}
/**
* This is for testing that the theme can have hook_*_alter() implementations
* that run during page callback execution, even before theme() is called for
* the first time.
*
* @return string
* A string containing the altered data.
*/
public
function
testAlter
()
{
$data
=
'foo'
;
$this
->
moduleHandler
()
->
alter
(
'theme_test_alter'
,
$data
);
return
"The altered data is
$data
."
;
}
/**
* Tests themed output generated in a request listener.
*
* @return string
* Content in theme_test_output GLOBAL.
*/
public
function
testRequestListener
()
{
return
$GLOBALS
[
'theme_test_output'
];
}
}
core/modules/system/tests/modules/theme_test/theme_test.module
View file @
491bd633
...
...
@@ -46,32 +46,13 @@ function theme_test_system_theme_info() {
*/
function
theme_test_menu
()
{
$items
[
'theme-test/suggestion'
]
=
array
(
'title'
=>
'Suggestion'
,
'page callback'
=>
'_theme_test_suggestion'
,
'access callback'
=>
TRUE
,
'route_name'
=>
'theme_test_suggestion'
,
'theme callback'
=>
'_theme_custom_theme'
,
'type'
=>
MENU_CALLBACK
,
);
$items
[
'theme-test/alter'
]
=
array
(
'title'
=>
'Suggestion'
,
'page callback'
=>
'_theme_test_alter'
,
'access callback'
=>
TRUE
,
'theme callback'
=>
'_theme_custom_theme'
,
'type'
=>
MENU_CALLBACK
,
);
$items
[
'theme-test/request-listener'
]
=
array
(
'page callback'
=>
'theme_test_request_listener_page_callback'
,
'access callback'
=>
TRUE
,
'type'
=>
MENU_CALLBACK
,
);
$items
[
'theme-test/template-test'
]
=
array
(
'page callback'
=>
'theme_test_template_test_page_callback'
,
'access callback'
=>
TRUE
,
'type'
=>
MENU_CALLBACK
,
);
$items
[
'theme-test/info/stylesheets'
]
=
array
(
'page callback'
=>
'theme_test_info_stylesheets'
,
'access callback'
=>
TRUE
,
'route_name'
=>
'theme_test_alter'
,
'type'
=>
MENU_CALLBACK
,
);
$items
[
'theme-test/function-template-overridden'
]
=
array
(
...
...
@@ -80,7 +61,6 @@ function theme_test_menu() {
);
return
$items
;
}
/**
* Fake registry loading callback.
*/
...
...
@@ -89,39 +69,6 @@ function _theme_test_load_registry() {
return
array
();
}
/**
* Menu callback for testing themed output generated in a request listener.
*/
function
theme_test_request_listener_page_callback
()
{
return
$GLOBALS
[
'theme_test_output'
];
}
/**
* Menu callback for testing template overridding based on filename.
*/
function
theme_test_template_test_page_callback
()
{
return
theme
(
'theme_test_template_test'
);
}
/**
* Page callback; Adds stylesheets to test theme .info.yml property processing.
*
* @see test_basetheme.info.yml
* @see test_subtheme.info.yml
* @see \Drupal\system\Tests\Theme\ThemeInfoStylesTest
* @see http://drupal.org/node/967266#comment-3689670
*/
function
theme_test_info_stylesheets
()
{
$path
=
drupal_get_path
(
'module'
,
'theme_test'
);
drupal_add_css
(
"
$path
/css/base-override.css"
);
drupal_add_css
(
"
$path
/css/base-override.sub-remove.css"
);
drupal_add_css
(
"
$path
/css/base-remove.css"
);
drupal_add_css
(
"
$path
/css/base-remove.sub-override.css"
);
drupal_add_css
(
"
$path
/css/sub-override.css"
);
drupal_add_css
(
"
$path
/css/sub-remove.css"
);
return
''
;
}
/**
* Custom theme callback.
*/
...
...
@@ -129,26 +76,6 @@ function _theme_custom_theme() {
return
'test_theme'
;
}
/**
* Page callback, calls drupal_alter().
*
* This is for testing that the theme can have hook_*_alter() implementations
* that run during page callback execution, even before theme() is called for
* the first time.
*/
function
_theme_test_alter
()
{
$data
=
'foo'
;
drupal_alter
(
'theme_test_alter'
,
$data
);
return
"The altered data is
$data
."
;
}
/**
* Page callback, calls a theme hook suggestion.
*/
function
_theme_test_suggestion
()
{
return
theme
(
array
(
'theme_test__suggestion'
,
'theme_test'
),
array
());
}
/**
* Implements hook_preprocess_HOOK() for html.tpl.php.
*/
...
...
core/modules/system/tests/modules/theme_test/theme_test.routing.yml
View file @
491bd633
...
...
@@ -4,3 +4,40 @@ function_template_override:
_content
:
'
\Drupal\theme_test\ThemeTestController::functionTemplateOverridden'
requirements
:
_permission
:
'
access
content'
theme_test_info_stylesheets
:
pattern
:
'
/theme-test/info/stylesheets'
defaults
:
_content
:
'
\Drupal\theme_test\ThemeTestController::testInfoStylesheets'
requirements
:
_access
:
'
TRUE'
theme_test_template_test
:
pattern
:
'
/theme-test/template-test'
defaults
:
_content
:
'
\Drupal\theme_test\ThemeTestController::testTemplate'
requirements
:
_access
:
'
TRUE'
theme_test_suggestion
:
pattern
:
'
/theme-test/suggestion'
defaults
:
_content
:
'
\Drupal\theme_test\ThemeTestController::testSuggestion'
_title
:
'
Suggestion'
requirements
:
_access
:
'
TRUE'
theme_test_alter
:
pattern
:
'
/theme-test/alter'
defaults
:
_content
:
'
\Drupal\theme_test\ThemeTestController::testAlter'
_title
:
'
Suggestion'
requirements
:
_access
:
'
TRUE'
theme_test_request_listener
:
pattern
:
'
/theme-test/request-listener'
defaults
:
_content
:
'
\Drupal\theme_test\ThemeTestController::testRequestListener'
requirements
:
_access
:
'
TRUE'
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