ForumAliasType.php in Pathauto 8
File
src/Plugin/pathauto/AliasType/ForumAliasType.php
View source
<?php
namespace Drupal\pathauto\Plugin\pathauto\AliasType;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ForumAliasType extends EntityAliasTypeBase implements ContainerFactoryPluginInterface {
protected $configFactory;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager, EntityTypeManagerInterface $entity_type_manager, KeyValueFactoryInterface $key_value, Connection $database, ConfigFactoryInterface $config_factory) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $module_handler, $language_manager, $entity_type_manager, $key_value, $database);
$this->configFactory = $config_factory;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('module_handler'), $container
->get('language_manager'), $container
->get('entity_type.manager'), $container
->get('keyvalue'), $container
->get('database'), $container
->get('config.factory'));
}
protected function getEntityTypeId() {
return 'taxonomy_term';
}
public function getSourcePrefix() {
return '/forum/';
}
public function applies($object) {
if (parent::applies($object)) {
$vid = $this->configFactory
->get('forum.settings')
->get('vocabulary');
return $object
->bundle() == $vid;
}
return FALSE;
}
}