The controller “X” is not allowed by this plugin

守給你的承諾、 提交于 2019-12-13 12:36:21

问题


I try to add a new controller which has one action called confirmAgbAction.

<?php
namespace Eddcapone\MyExtension\Controller;

/**
 * CustomController
 */
class CustomController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController 
{

    /**
     * action list
     *
     * @return void
     */
    public function confirmAgbAction()
    {
        echo "<p>HALLO WELT</p>";    
    }
}

I even added it to ext_localconf.php

<?php
if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'Eddcapone.' . $_EXTKEY,
    'Myfilelist',
    array(
        'Category' => 'list,show',
        'File' => 'show',
        'Download' => 'download',
        'Custom' => 'confirmAgb'
    ),
    // non-cacheable actions
    array(
        'Category' => 'list,show',
        'File' => 'topFive',
        'Download' => 'download',
        'Custom' => 'confirmAgb'
    )
);

This is how I call the action in the template:

<f:link.action controller="Custom" action="confirmAgb" pluginName="Myfilelist" class="mbButton">Download</f:link.action>

However, i always get:

#1313855173: The controller "Custom" is not allowed by this plugin. Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.


回答1:


There are two common possibilities for your error:

  1. You use a flexform to embed your plugin. Either you have not added Custom->confirmAgb to the allowed calls in your flexform or you have added it but did not update the plugin (plugin configuration only updates when you save the plugin/tt_content element)
  2. You have two plugins on the page and the error is triggered by the other plugin because there the controller->action combination is not allowed.

PS: try adding this to your TS (setup.txt) and the plugins now should pick the default action if the given one is not found:

plugin.tx_yourextensionmvc.callDefaultActionIfActionCantBeResolved = 1

There could be more uncommon cases




回答2:


You should absolutely avoid using $_EXTKEY in configurePlugin and other Extbase contexts. Extbase requires the Vendor.ExtensionName format - $_EXTKEY is in the lowercase_underscored format. Defining those parameters as hardcoded values should solve your problem with resolving controllers for your given plugin.

To be precise: use Eddcapone.Myextension as extension name parameter in your command(s) to register/configure plugins.



来源:https://stackoverflow.com/questions/40150145/the-controller-x-is-not-allowed-by-this-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!