Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Routing 类型3:将fe_用户realurl配置迁移到routeEnhancers_Routing_Typo3_Typo3 9.x_Realurl - Fatal编程技术网

Routing 类型3:将fe_用户realurl配置迁移到routeEnhancers

Routing 类型3:将fe_用户realurl配置迁移到routeEnhancers,routing,typo3,typo3-9.x,realurl,Routing,Typo3,Typo3 9.x,Realurl,类型3:将fe_用户realurl配置迁移到routeEnhancers 目前我正在将TYPO3从版本8更新到版本9。到目前为止,我使用了ext:realurl来生成语音URL。现在,我正在努力让“旧”URL与新的routeEnhancers一起工作 我已在自己的扩展名中扩展了fe\u用户表,扩展名为my\u department。现在,我正在尝试使用以下routeEnhancers使URL正常工作 routeEnhancers: FeusersPlugin: type: Extba

类型3:将fe_用户realurl配置迁移到routeEnhancers

目前我正在将TYPO3从版本8更新到版本9。到目前为止,我使用了
ext:realurl
来生成语音URL。现在,我正在努力让“旧”URL与新的routeEnhancers一起工作

我已在自己的扩展名中扩展了
fe\u用户
表,扩展名为
my\u department
。现在,我正在尝试使用以下routeEnhancers使URL正常工作

routeEnhancers:
  FeusersPlugin:
    type: Extbase
    extension: MyFeusers
    plugin: Users
    #limitToPages: [3,7]
    defaultController: 'FrontendUser::list'
    defaults:
      company_title: ''
      department_title: ''
    routes:
      # Detail view:
      -
        routePath: '/{employee_title}'
        _controller: 'FrontendUser::show'
        _arguments: {'employee_title': 'frontendUser'}
      # List view
      -
        routePath: '{company_title}'
        _controller: 'FrontendUser::list'
        _arguments: {'company_title': 'company'}
      -
        routePath: 'department/{department_title}'
        _controller: 'FrontendUser::list'
        _arguments: {'department_title': 'department'}
    aspects:
      employee_title:
        type: PersistedPatternMapper
        tableName: fe_users
        routeFieldPattern: '^(?P<first_name>.+)-(?P<last_name>\d+)$'
        routeFieldResult: '{first_name}-{last_name}'
      company_title:
        type: StaticValueMapper
        map:
          name-of-company: 'Name of company'
          name-of-other-company: 'Name of other company'
      department_title:
        type: PersistedAliasMapper
        tableName: 'fe_users'
        routeFieldName: 'my_department'

由于找不到其他方法使其工作,我为该部门编写了自己的地图绘制程序:

ext\u localconf.php
中注册映射程序:

$GLOBALS['TYPO3_CONF_VARS']
        ['SYS']
        ['routing']
        ['aspects']
        ['DepartmentStaticMapper'] = \Vendor\Extension\Routing\Aspect\DepartmentStaticMapper::class;
Classes/Routing/Aspect/DepartmentStaticMapper.php
中添加映射器类的文件。映射器不执行任何操作,但返回给定值:

<?php
namespace Vendor\Extension\Routing\Aspect;

use TYPO3\CMS\Core\Routing\Aspect\StaticMappableAspectInterface;

class DepartmentStaticMapper implements StaticMappableAspectInterface
{
    /**
     * @var array
     */
    protected $settings;

    /**
     * @param array $settings
     * @throws \InvalidArgumentException
     */
    public function __construct(array $settings)
    {
        $this->settings = $settings;
    }

    /**
     * {@inheritdoc}
     */
    public function generate(string $value): ?string
    {
        return $value;
    }

    /**
     * {@inheritdoc}
     */
    public function resolve(string $value): ?string
    {
        return $value;
    }
}
<?php
namespace Vendor\Extension\Routing\Aspect;

use TYPO3\CMS\Core\Routing\Aspect\StaticMappableAspectInterface;

class DepartmentStaticMapper implements StaticMappableAspectInterface
{
    /**
     * @var array
     */
    protected $settings;

    /**
     * @param array $settings
     * @throws \InvalidArgumentException
     */
    public function __construct(array $settings)
    {
        $this->settings = $settings;
    }

    /**
     * {@inheritdoc}
     */
    public function generate(string $value): ?string
    {
        return $value;
    }

    /**
     * {@inheritdoc}
     */
    public function resolve(string $value): ?string
    {
        return $value;
    }
}
routeEnhancers:
  FeusersPlugin:
    type: Extbase
    extension: MyFeusers
    plugin: Users
    #limitToPages: [3,7]
    defaultController: 'FrontendUser::list'
    defaults:
      company_title: ''
      department_title: ''
    routes:
      # Detail view:
      -
        routePath: '{employee_title}'
        _controller: 'FrontendUser::show'
        _arguments: {'employee_title': 'frontendUser'}
      # List view
      -
        routePath: '{company_title}'
        _controller: 'FrontendUser::list'
        _arguments: {'company_title': 'company'}
      -
        routePath: 'department/{department_title}'
        _controller: 'FrontendUser::list'
        _arguments: {'department_title': 'department'}
    aspects:
      employee_title:
        type: PersistedPatternMapper
        tableName: fe_users
        routeFieldPattern: '^(?P<first_name>.+)-(?P<last_name>.+)$'
        routeFieldResult: '{first_name}-{last_name}'
      company_title:
        type: StaticValueMapper
        map:
          name-of-company: 'Name of company'
          name-of-other-company: 'Name of other company'
      department_title:
        type: DepartmentStaticMapper