Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
83a8f3fe
Commit
83a8f3fe
authored
Oct 03, 2012
by
webchick
Browse files
Oh hai. How about ALL THE FILES?
parent
2750f60e
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Plugin/Discovery/AlterDecorator.php
0 → 100644
View file @
83a8f3fe
<?php
/**
* @file
* Definition of Drupal\Core\Plugin\Discovery\AlterDiscoveryDecorator.
*/
namespace
Drupal\Core\Plugin\Discovery
;
use
Drupal\Component\Plugin\Discovery\DiscoveryInterface
;
/**
* Enables altering of discovered plugin definitions.
*/
class
AlterDecorator
implements
DiscoveryInterface
{
/**
* The name of the alter hook that will be implemented by this discovery instance.
*
* @var string
*/
protected
$hook
;
/**
* The Discovery object being decorated.
*
* @var Drupal\Component\Plugin\Discovery\DiscoveryInterface
*/
protected
$decorated
;
/**
* Constructs a Drupal\Core\Plugin\Discovery\AlterDecorator object.
*
* It uses the DiscoveryInterface object it should decorate.
*
* @param Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated
* The object implementing DiscoveryInterface that is being decorated.
* @param string $hook
* The name of the alter hook that will be implemented by this discovery instance.
*/
public
function
__construct
(
DiscoveryInterface
$decorated
,
$hook
)
{
$this
->
decorated
=
$decorated
;
$this
->
hook
=
$hook
;
}
/**
* Implements Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinition().
*/
public
function
getDefinition
(
$plugin_id
)
{
$definitions
=
$this
->
getDefinitions
();
return
isset
(
$definitions
[
$plugin_id
])
?
$definitions
[
$plugin_id
]
:
NULL
;
}
/**
* Implements Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinitions().
*/
public
function
getDefinitions
()
{
$definitions
=
$this
->
decorated
->
getDefinitions
();
drupal_alter
(
$this
->
hook
,
$definitions
);
return
$definitions
;
}
/**
* Passes through all unknown calls onto the decorated object.
*/
public
function
__call
(
$method
,
$args
)
{
return
call_user_func_array
(
array
(
$this
->
decorated
,
$method
),
$args
);
}
}
core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/AlterDecoratorTestPluginManager.php
0 → 100644
View file @
83a8f3fe
<?php
/**
* @file
* Definition of Drupal\plugin_test\Plugin\plugin_test\AlterDecoratorTestPluginManager.
*/
namespace
Drupal\plugin_test\Plugin
;
use
Drupal\Core\Plugin\Discovery\AlterDecorator
;
/**
* Defines a plugin manager used by AlterDecorator unit tests.
*/
class
AlterDecoratorTestPluginManager
extends
TestPluginManager
{
public
function
__construct
()
{
parent
::
__construct
();
$this
->
discovery
=
new
AlterDecorator
(
$this
->
discovery
,
'plugin_test'
);
}
}
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