class OnlyOneAdminToolbar in Allow a content type only once (Only One) 8
Class OnlyOneAdminToolbar.
Hierarchy
- class \Drupal\onlyone_admin_toolbar\OnlyOneAdminToolbar implements OnlyOneAdminToolbarInterface
Expanded class hierarchy of OnlyOneAdminToolbar
1 file declares its use of OnlyOneAdminToolbar
- OnlyOneAdminToolbarTest.php in modules/
onlyone_admin_toolbar/ tests/ src/ Unit/ OnlyOneAdminToolbarTest.php
1 string reference to 'OnlyOneAdminToolbar'
- onlyone_admin_toolbar.services.yml in modules/
onlyone_admin_toolbar/ onlyone_admin_toolbar.services.yml - modules/onlyone_admin_toolbar/onlyone_admin_toolbar.services.yml
1 service uses OnlyOneAdminToolbar
- onlyone.admin_toolbar in modules/
onlyone_admin_toolbar/ onlyone_admin_toolbar.services.yml - Drupal\onlyone_admin_toolbar\OnlyOneAdminToolbar
File
- modules/
onlyone_admin_toolbar/ src/ OnlyOneAdminToolbar.php, line 11
Namespace
Drupal\onlyone_admin_toolbarView source
class OnlyOneAdminToolbar implements OnlyOneAdminToolbarInterface {
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* The route builder.
*
* @var \Drupal\Core\Routing\RouteBuilderInterface
*/
protected $routeBuilder;
/**
* Constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder
* The route builder.
*/
public function __construct(ConfigFactoryInterface $config_factory, RouteBuilderInterface $route_builder) {
$this->configFactory = $config_factory;
$this->routeBuilder = $route_builder;
}
/**
* {@inheritdoc}
*/
public function rebuildMenu($content_type) {
// Getting the configured content types.
$onlyone_content_types = $this->configFactory
->get('onlyone.settings')
->get('onlyone_node_types');
// Checking if the content type is configured.
if (in_array($content_type, $onlyone_content_types)) {
// If is configured then we need to rebuild the menu.
$this->routeBuilder
->rebuild();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OnlyOneAdminToolbar:: |
protected | property | The config factory. | |
OnlyOneAdminToolbar:: |
protected | property | The route builder. | |
OnlyOneAdminToolbar:: |
public | function |
Rebuild the menu to change the menu label in the Admin Toolbar module. Overrides OnlyOneAdminToolbarInterface:: |
|
OnlyOneAdminToolbar:: |
public | function | Constructor. |