在TYPO3中无法确定扩展和插件的默认控制器为ERROR [英] The default controller for extension and plugin can not be determined ERROR in TYPO3

查看:81
本文介绍了在TYPO3中无法确定扩展和插件的默认控制器为ERROR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我构建了一个扩展程序,并且想在将插件添加到页面时添加插件选项

 Extension Name : hotels

在酒店模式下,

 <?php
    class Hotel{
          ... get set methods ...
      }
  ?>

在HotelController.php中

 <?php
  namespace TYPO3\Hotels\Controller; 

   class HotelController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController{

    public function listAction(){
      //    $this->view->assign('result', array('test' => 'hello, u r in list'));               }
   }
 ?>

在ext_localconf.php中

 \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'TYPO3.' . $_EXTKEY,
    'hotels',
     array('Hotel' => 'list,single,display,update,save,preview,edit')
    );

在ext_tables.php中

  \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
    $_EXTKEY,
    'hotels',
   'list of Hotels'
   );

 $pluginSignature = str_replace('_','',$_EXTKEY) . '_hotels';

 $TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] ='pi_flexform';

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/flexform_myhotel.xml');

不知何故,我想我缺少了一些东西.这给出了一个错误:

添加扩展名时,我可以在后端看到该选项,但是当我想显示(查看)添加扩展名的页面时,会产生错误.

----> The default controller for extension "Hotels" and plugin "hotels" can not be determined. Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.

请引导我

解决方案

在TYPO3 6.x中,建议您使用命名空间类并告知configurePlugin方法您的供应商名称.

由于您未包含任何控制器代码,因此我将尝试对其进行草绘:

  1. 首先,请确保使用命名空间控制器类-记住来设置供应商名称.
  2. 请确保您的操作以*Action后缀
  3. 命名

EXT:myext/Classes/Controller/HotelController

namespace MyVendor\MyExt\Controller;
class HotelController {
    /**
    * @return void
    */
     public function listAction(){
     }
}

接下来,像这样在configurePlugin中提及名称空间:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'MyVendor.' . $_EXTKEY,
    // UpperCamelCase please, refer to [1]
    'Hotels',
     array('Hotel' => 'list,single,display,update,save,preview,edit')
);

这允许类定位器正确解析类.

要进行验证,请确保您重新安装扩展程序.

PS:请尽可能在6.x中使用命名空间类.旧的Tx_*类只是别名,会给您的解释器带来额外的负担.

1 >

更新:

有很多可能的错误.

  1. 您连接了FlexForm.您是否正确设置了switchableControllerActions?
  2. 我不止一次看到的一件事:f:link.action(或分别为f:uri.action)不喜欢没有适当的controller属性
  3. 您显然错过了命名空间概念:)将ControllerClass重命名为HotelController,并且文件必须位于Classes/Controller/HotelController.php中,然后对configurePlugin()进行调整以反映我所描述的vendorName

I built an extension and I would like to add plugin options at the time of adding the plugin to the page

 Extension Name : hotels

in Hotel model ,

 <?php
    class Hotel{
          ... get set methods ...
      }
  ?>

in HotelController.php

 <?php
  namespace TYPO3\Hotels\Controller; 

   class HotelController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController{

    public function listAction(){
      //    $this->view->assign('result', array('test' => 'hello, u r in list'));               }
   }
 ?>

in ext_localconf.php

 \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'TYPO3.' . $_EXTKEY,
    'hotels',
     array('Hotel' => 'list,single,display,update,save,preview,edit')
    );

in ext_tables.php

  \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
    $_EXTKEY,
    'hotels',
   'list of Hotels'
   );

 $pluginSignature = str_replace('_','',$_EXTKEY) . '_hotels';

 $TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] ='pi_flexform';

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/flexform_myhotel.xml');

Somehow, I think i'm missing something. This gives an error :

I can see the option in backend side at time of adding extension but when i want to show (view) that Page where I add that extension , generates an error .

----> The default controller for extension "Hotels" and plugin "hotels" can not be determined. Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.

Please Guide me

解决方案

In TYPO3 6.x, you are advised to use namespaced classes and tell the configurePlugin method your vendor name.

As you didnt include any of your controller code, I'll try to sketch it:

  1. At first, make sure, you use a namespaced controller class-remember to set a Vendor name.
  2. Make sure, your actions are named with the *Action suffix

EXT: myext/Classes/Controller/HotelController

namespace MyVendor\MyExt\Controller;
class HotelController {
    /**
    * @return void
    */
     public function listAction(){
     }
}

Next, mention the namespace in configurePlugin like this:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'MyVendor.' . $_EXTKEY,
    // UpperCamelCase please, refer to [1]
    'Hotels',
     array('Hotel' => 'list,single,display,update,save,preview,edit')
);

This allows the class locator to resolve the classes correctly.

To verify it, make sure you re-install your extension.

PS: Please use the namespaced classes whenever possible in 6.x. The old Tx_* classes are only aliases and put additional load on your interpreter.

1 - TYPO3 API Docs for ExtensionUtility::configurePlugin()

Update:

There is a multitude of possible errors.

  1. You wired a FlexForm. Did you set the switchableControllerActions appropriately?
  2. One thing I saw more than once: The f:link.action (or f:uri.action respectively) doesnt like to be without an appropriate controller attribute
  3. You clearly missed the namespace concept :) Rename your ControllerClass to HotelController and the file must live in Classes/Controller/HotelController.php, then do the adjustments to configurePlugin() to reflect the vendorName as I described

这篇关于在TYPO3中无法确定扩展和插件的默认控制器为ERROR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆