Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
229
Merge Requests
229
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
6b46e5d3
Commit
6b46e5d3
authored
Feb 06, 2014
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2188991
by tim.plunkett: Use ThemeHandler instead of list_themes() in unit tests.
parent
dca2d601
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
79 deletions
+58
-79
core/modules/block/lib/Drupal/block/Plugin/Derivative/ThemeLocalTask.php
...ock/lib/Drupal/block/Plugin/Derivative/ThemeLocalTask.php
+17
-3
core/modules/block/tests/Drupal/block/Tests/Menu/BlockLocalTasksTest.php
...ock/tests/Drupal/block/Tests/Menu/BlockLocalTasksTest.php
+28
-29
core/modules/config_translation/config_translation.services.yml
...odules/config_translation/config_translation.services.yml
+1
-0
core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php
...ion/lib/Drupal/config_translation/ConfigMapperManager.php
+4
-20
core/modules/config_translation/tests/Drupal/config_translation/Tests/ConfigMapperManagerTest.php
...upal/config_translation/Tests/ConfigMapperManagerTest.php
+8
-27
No files found.
core/modules/block/lib/Drupal/block/Plugin/Derivative/ThemeLocalTask.php
View file @
6b46e5d3
...
...
@@ -9,6 +9,7 @@
use
Drupal\Component\Plugin\Derivative\DerivativeBase
;
use
Drupal\Core\Config\ConfigFactory
;
use
Drupal\Core\Extension\ThemeHandlerInterface
;
use
Drupal\Core\Plugin\Discovery\ContainerDerivativeInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
...
...
@@ -24,21 +25,34 @@ class ThemeLocalTask extends DerivativeBase implements ContainerDerivativeInterf
*/
protected
$config
;
/**
* The theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected
$themeHandler
;
/**
* Constructs a new ThemeLocalTask.
*
* @param \Drupal\Core\Config\ConfigFactory $config_factory
* The config factory.
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* The theme handler.
*/
public
function
__construct
(
ConfigFactory
$config_factory
)
{
public
function
__construct
(
ConfigFactory
$config_factory
,
ThemeHandlerInterface
$theme_handler
)
{
$this
->
config
=
$config_factory
->
get
(
'system.theme'
);
$this
->
themeHandler
=
$theme_handler
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
,
$base_plugin_id
)
{
return
new
static
(
$container
->
get
(
'config.factory'
));
return
new
static
(
$container
->
get
(
'config.factory'
),
$container
->
get
(
'theme_handler'
)
);
}
/**
...
...
@@ -47,7 +61,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) {
public
function
getDerivativeDefinitions
(
array
$base_plugin_definition
)
{
$default_theme
=
$this
->
config
->
get
(
'default'
);
foreach
(
list_themes
()
as
$theme_name
=>
$theme
)
{
foreach
(
$this
->
themeHandler
->
listInfo
()
as
$theme_name
=>
$theme
)
{
if
(
$theme
->
status
)
{
$this
->
derivatives
[
$theme_name
]
=
$base_plugin_definition
;
$this
->
derivatives
[
$theme_name
][
'title'
]
=
$theme
->
info
[
'name'
];
...
...
core/modules/block/tests/Drupal/block/Tests/Menu/BlockLocalTasksTest.php
View file @
6b46e5d3
...
...
@@ -5,9 +5,10 @@
* Contains \Drupal\block\Tests\Menu\BlockLocalTasksTest.
*/
namespace
Drupal\block\Tests\Menu
{
namespace
Drupal\block\Tests\Menu
;
use
Drupal\Tests\Core\Menu\LocalTaskIntegrationTest
;
use
Symfony\Component\DependencyInjection\ContainerBuilder
;
/**
* Tests existence of block local tasks.
...
...
@@ -32,7 +33,32 @@ public function setUp() {
$config_factory
=
$this
->
getConfigFactoryStub
(
array
(
'system.theme'
=>
array
(
'default'
=>
'test_c'
,
)));
\
Drupal
::
getContainer
()
->
set
(
'config.factory'
,
$config_factory
);
$themes
=
array
();
$themes
[
'test_a'
]
=
(
object
)
array
(
'status'
=>
0
,
);
$themes
[
'test_b'
]
=
(
object
)
array
(
'status'
=>
1
,
'info'
=>
array
(
'name'
=>
'test_b'
,
),
);
$themes
[
'test_c'
]
=
(
object
)
array
(
'status'
=>
1
,
'info'
=>
array
(
'name'
=>
'test_c'
,
),
);
$theme_handler
=
$this
->
getMock
(
'Drupal\Core\Extension\ThemeHandlerInterface'
);
$theme_handler
->
expects
(
$this
->
any
())
->
method
(
'listInfo'
)
->
will
(
$this
->
returnValue
(
$themes
));
$container
=
new
ContainerBuilder
();
$container
->
set
(
'config.factory'
,
$config_factory
);
$container
->
set
(
'theme_handler'
,
$theme_handler
);
\
Drupal
::
setContainer
(
$container
);
}
/**
...
...
@@ -62,30 +88,3 @@ public function providerTestBlockAdminDisplay() {
}
}
}
namespace
{
if
(
!
function_exists
(
'list_themes'
))
{
function
list_themes
()
{
$themes
=
array
();
$themes
[
'test_a'
]
=
(
object
)
array
(
'status'
=>
0
,
);
$themes
[
'test_b'
]
=
(
object
)
array
(
'status'
=>
1
,
'info'
=>
array
(
'name'
=>
'test_b'
,
),
);
$themes
[
'test_c'
]
=
(
object
)
array
(
'status'
=>
1
,
'info'
=>
array
(
'name'
=>
'test_c'
,
),
);
return
$themes
;
}
}
}
core/modules/config_translation/config_translation.services.yml
View file @
6b46e5d3
...
...
@@ -24,3 +24,4 @@ services:
-
'
@language_manager'
-
'
@module_handler'
-
'
@config.typed'
-
'
@theme_handler'
core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php
View file @
6b46e5d3
...
...
@@ -13,6 +13,7 @@
use
Drupal\Core\Config\Schema\ArrayElement
;
use
Drupal\Core\Config\TypedConfigManager
;
use
Drupal\Core\Extension\ModuleHandlerInterface
;
use
Drupal\Core\Extension\ThemeHandlerInterface
;
use
Drupal\Core\Language\LanguageManagerInterface
;
use
Drupal\Core\Plugin\DefaultPluginManager
;
use
Drupal\Core\Plugin\Discovery\InfoHookDecorator
;
...
...
@@ -55,7 +56,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
* @param \Drupal\Core\Config\TypedConfigManager $typed_config_manager
* The typed config manager.
*/
public
function
__construct
(
CacheBackendInterface
$cache_backend
,
LanguageManagerInterface
$language_manager
,
ModuleHandlerInterface
$module_handler
,
TypedConfigManager
$typed_config_manager
)
{
public
function
__construct
(
CacheBackendInterface
$cache_backend
,
LanguageManagerInterface
$language_manager
,
ModuleHandlerInterface
$module_handler
,
TypedConfigManager
$typed_config_manager
,
ThemeHandlerInterface
$theme_handler
)
{
$this
->
typedConfigManager
=
$typed_config_manager
;
// Look at all themes and modules.
...
...
@@ -63,8 +64,8 @@ public function __construct(CacheBackendInterface $cache_backend, LanguageManage
foreach
(
$module_handler
->
getModuleList
()
as
$module
=>
$filename
)
{
$directories
[
$module
]
=
dirname
(
$filename
);
}
foreach
(
$th
is
->
getThemeList
()
as
$theme
)
{
$directories
[
$theme
->
name
]
=
d
rupal_get_path
(
'theme'
,
$theme
->
name
);
foreach
(
$th
eme_handler
->
listInfo
()
as
$theme
)
{
$directories
[
$theme
->
name
]
=
d
irname
(
$theme
->
file
name
);
}
// Check for files named MODULE.config_translation.yml and
...
...
@@ -80,23 +81,6 @@ public function __construct(CacheBackendInterface $cache_backend, LanguageManage
$this
->
setCacheBackend
(
$cache_backend
,
$language_manager
,
'config_translation_info_plugins'
);
}
/**
* Returns the list of themes on the site.
*
* @param bool $refresh
* Whether to refresh the cached theme list.
*
* @return array
* An associative array of the currently available themes. The keys are the
* themes' machine names and the values are objects. See list_themes() for
* documentation on those objects.
*
* @todo Remove this once https://drupal.org/node/2109287 is fixed in core.
*/
protected
function
getThemeList
(
$refresh
=
FALSE
)
{
return
list_themes
(
$refresh
);
}
/**
* {@inheritdoc}
*/
...
...
core/modules/config_translation/tests/Drupal/config_translation/Tests/ConfigMapperManagerTest.php
View file @
6b46e5d3
...
...
@@ -5,7 +5,7 @@
* Contains \Drupal\config_translation\Tests\ConfigMapperManagerTest.
*/
namespace
Drupal\config_translation\Tests
{
namespace
Drupal\config_translation\Tests
;
use
Drupal\config_translation
\
ConfigMapperManager
;
use
Drupal\Core\Language\Language
;
...
...
@@ -62,12 +62,17 @@ public function setUp() {
->
method
(
'getModuleList'
)
->
with
()
->
will
(
$this
->
returnValue
(
array
()));
$theme_handler
=
$this
->
getMock
(
'Drupal\Core\Extension\ThemeHandlerInterface'
);
$theme_handler
->
expects
(
$this
->
any
())
->
method
(
'listInfo'
)
->
will
(
$this
->
returnValue
(
array
()));
$this
->
configMapperManager
=
new
Test
ConfigMapperManager
(
$this
->
configMapperManager
=
new
ConfigMapperManager
(
$this
->
getMock
(
'Drupal\Core\Cache\CacheBackendInterface'
),
$language_manager
,
$module_handler
,
$this
->
typedConfigManager
$this
->
typedConfigManager
,
$theme_handler
);
}
...
...
@@ -187,27 +192,3 @@ protected function getNestedElement(array $elements) {
}
}
/**
* Subclass of the tested class to avoid global function calls.
*
* @todo Remove this once https://drupal.org/node/2109287 is fixed in core.
*/
class
TestConfigMapperManager
extends
ConfigMapperManager
{
/**
* {@inheritdoc}
*/
protected
function
getThemeList
(
$refresh
=
FALSE
)
{
return
array
();
}
}
}
// @todo Remove this once https://drupal.org/node/2109287 is fixed in core.
namespace
{
if
(
!
function_exists
(
'drupal_get_path'
))
{
function
drupal_get_path
()
{}
}
}
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