Skip to content
Snippets Groups Projects
Commit 081c74cf authored by Antonio De Marco's avatar Antonio De Marco
Browse files

#91: Fix CS and clean code.

parent b9394492
Branches
Tags
No related merge requests found
......@@ -3,7 +3,6 @@
namespace Drupal\ui_patterns_library\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\ui_patterns\UiPatterns;
use Drupal\ui_patterns\UiPatternsManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -59,7 +58,7 @@ class PatternsLibraryController extends ControllerBase {
$definition['rendered']['#type'] = 'pattern_preview';
$definition['rendered']['#id'] = $name;
$definition['meta']['#theme'] = 'patterns_meta_information';
$definition['meta']['#pattern'] = UiPatterns::getPatternDefinition($name)->toArray();
$definition['meta']['#pattern'] = $this->patternsManager->getDefinition($name)->toArray();
return [
'#theme' => 'patterns_single_page',
......
......@@ -5,7 +5,6 @@ namespace Drupal\ui_patterns\Plugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\TypedData\TypedDataManager;
use Drupal\ui_patterns\Definition\PatternDefinition;
use Symfony\Component\DependencyInjection\ContainerInterface;
......
......@@ -11,6 +11,8 @@ use Drupal\Core\Plugin\DefaultPluginManager;
/**
* Provides the default ui_patterns manager.
*
* @method \Drupal\ui_patterns\Definition\PatternDefinition getDefinition($plugin_id, $exception_on_invalid = TRUE)
*/
class UiPatternsManager extends DefaultPluginManager implements PluginManagerInterface {
......@@ -25,16 +27,6 @@ class UiPatternsManager extends DefaultPluginManager implements PluginManagerInt
/**
* UiPatternsManager constructor.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* Module handler service.
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* Theme handler service.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend service.
*/
public function __construct(\Traversable $namespaces, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, CacheBackendInterface $cache_backend) {
parent::__construct('Plugin/UiPatterns/Pattern', $namespaces, $module_handler, 'Drupal\ui_patterns\Plugin\PatternInterface', 'Drupal\ui_patterns\Annotation\UiPattern');
......@@ -74,7 +66,10 @@ class UiPatternsManager extends DefaultPluginManager implements PluginManagerInt
}
/**
* {@inheritdoc}
* Return pattern definitions.
*
* @return \Drupal\ui_patterns\Definition\PatternDefinition[]
* Pattern definitions.
*/
public function getDefinitions() {
$definitions = $this->getCachedDefinitions();
......
......@@ -5,10 +5,13 @@ use Drupal\ui_patterns\Element\PatternContext;
/**
* Alter UI Patterns definitions.
*
* @param \Drupal\ui_patterns\Definition\PatternDefinition[] $definitions
* Pattern definitions.
*
* @see \Drupal\ui_patterns\UiPatternsManager
*/
function hook_ui_patterns_info_alter(&$definitions) {
$definitions['my_pattern']['label'] = 'My new label';
$definitions['my_pattern']->setLabel('My new label');
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment