class OnlyOneRoutes in Allow a content type only once (Only One) 8
Defines dynamic routes.
Hierarchy
- class \Drupal\onlyone\Routing\OnlyOneRoutes implements ContainerInjectionInterface
Expanded class hierarchy of OnlyOneRoutes
File
- src/
Routing/ OnlyOneRoutes.php, line 13
Namespace
Drupal\onlyone\RoutingView source
class OnlyOneRoutes implements ContainerInjectionInterface {
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Constructs a NodeController object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
*/
public function __construct(ConfigFactoryInterface $config_factory) {
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'));
}
/**
* {@inheritdoc}
*/
public function routes() {
$routes = [];
// Checking if we need to show the route.
if ($this->configFactory
->get('onlyone.settings')
->get('onlyone_new_menu_entry')) {
// Defining the route.
$routes['onlyone.add_page'] = new Route('/onlyone/add', [
'_controller' => '\\Drupal\\onlyone\\Controller\\OnlyOneController::addPage',
'_title' => 'Add content (Only One)',
], [
'_node_add_access' => 'node',
], [
'_node_operation_route' => TRUE,
]);
}
return $routes;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OnlyOneRoutes:: |
protected | property | The config factory. | |
OnlyOneRoutes:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
OnlyOneRoutes:: |
public | function | ||
OnlyOneRoutes:: |
public | function | Constructs a NodeController object. |