# Controller not found

**URL:** <https://kanboard.discourse.group/t/controller-not-found/754>\
**Category:** Plugins\
**Created:** [October 7, 2019, 12:01pm UTC](https://kanboard.discourse.group/t/controller-not-found/754 "2019-10-07T12:01:26Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![av-ipunkt](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@av-ipunkt](https://kanboard.discourse.group/u/av-ipunkt)\
**Post date:** [October 7, 2019, 12:01pm UTC](https://kanboard.discourse.group/t/controller-not-found/754/1 "2019-10-07T12:01:26Z")

</div>

I am trying to develop a Plugin, with overriden class. The problem seems to be simple, but I am missing something.

Is it correct to override class in Plugin.php?:

```
public function getClasses()
{
 return array('plugins\CommentActions\Controller' => array('CommentActionsController'));
}

```

CommentActionsController.php:

```
class CommentActionsController extends CommentController
{

```

I get:

```
Internal Error: Controller not found
```

---

<div class="post-metadata">

**Author:** ![BlueTeck](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/blueteck/32/519_2.png) [@BlueTeck](https://kanboard.discourse.group/u/BlueTeck)\
**Post date:** [October 7, 2019, 4:23pm UTC](https://kanboard.discourse.group/t/controller-not-found/754/2 "2019-10-07T16:23:14Z")

</div>

Could you share your whole CommentActionsController.php and Plugin.php file?

---

<div class="post-metadata">

**Author:** ![av-ipunkt](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@av-ipunkt](https://kanboard.discourse.group/u/av-ipunkt)\
**Post date:** [October 8, 2019, 6:33am UTC](https://kanboard.discourse.group/t/controller-not-found/754/3 "2019-10-08T06:33:55Z")

</div>

```
<?php

namespace Kanboard\Plugin\CommentActions;

use Kanboard\Core\Filter\LexerBuilder;
use Kanboard\Core\Plugin\Base;
use Kanboard\Core\Security\Role;
use Kanboard\Core\Translator;

class Plugin extends Base
{
public function initialize()
{
    $this->template->hook->attach("template:config:sidebar",
        "CommentActions:config/sidebar");
    $this->route->addRoute('settings/commentactions', 'CommentActionsSettingsController', 'index',
        'CommentActions');
    $this->template->setTemplateOverride('task_comments/create', 'CommentActions:task_comments/create');

}

public function onStartup()
{
}

public function getClasses()
{
 return array('plugins\CommentActions\Controller' => array('CommentActionsController'));
}

public function getPluginName()
{
    return 'CommentActions';
}

```

CommentActionsController.php

```
<?php

namespace Kanboard\Plugin\CommentActions\Controller;

use Kanboard\Controller\CommentController;
use Kanboard\Core\Controller\AccessForbiddenException;
use Kanboard\Core\Controller\PageNotFoundException;
use Kanboard\Model\ConfigModel;

class CommentActionsController extends CommentController
{

/**
 * Add comment form
 *
 * @access public
 * @param array $values
 * @param array $errors
 * @throws AccessForbiddenException
 * @throws PageNotFoundException
 */
public function create(array $values = array(), array $errors = array())
{
    $project = $this->getProject();
    $task = $this->getTask();
    $values['project_id'] = $task['project_id'];
    $this->response->html($this->helper->layout->task('task_comments/create', array(
        'values' => $values,
        'errors' => $errors,
        'task' => $task,
        'project' => $project,
        'comment_actions_enabled' => $this->isCommentActionsEnabled()
    )));
}

/**
 * Add a comment
 *
 * @access public
 */
public function save()
{
    $task = $this->getTask();
    $values = $this->request->getValues();
    $values['task_id'] = $task['id'];
    $values['user_id'] = $this->userSession->getId();
    $actionPluginEnabled = $this->isCommentActionsEnabled();

    $actionsEnabled = isset($values['assign_issue']) && $values['assign_issue'];
    if( $actionPluginEnabled && $actionsEnabled ) {
     // do something
    }

    list($valid, $errors) = $this->commentValidator->validateCreation($values);

    if ($valid) {
        if ($this->commentModel->create($values) !== false) {
            $this->flash->success(t('Comment added successfully.'));
        } else {
            $this->flash->failure(t('Unable to create your comment.'));
        }

        $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'), true);
    } else {
        $this->create($values, $errors);
    }
}

protected function isCommentActionsEnabled() {
    return $this->configModel->getOption('comment_actions');
}

```

}

---

<div class="post-metadata">

**Author:** ![av-ipunkt](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@av-ipunkt](https://kanboard.discourse.group/u/av-ipunkt)\
**Post date:** [October 9, 2019, 6:52am UTC](https://kanboard.discourse.group/t/controller-not-found/754/4 "2019-10-09T06:52:52Z")

</div>

did I initialize controller correct or not ? someone?

---

<div class="post-metadata">

**Author:** ![rafaelcamargo](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/rafaelcamargo/32/279_2.png) [@rafaelcamargo](https://kanboard.discourse.group/u/rafaelcamargo)\
**Post date:** [October 9, 2019, 12:34pm UTC](https://kanboard.discourse.group/t/controller-not-found/754/5 "2019-10-09T12:34:15Z")

</div>

> [@av-ipunkt](#):
>
> ```auto
> return array('plugins\CommentActions\Controller' => array('CommentActionsController'));
> 
> ```

should be like the CommentActionsController namespace:

```auto
return array('Plugin\CommentActions\Controller' => array('CommentActionsController'));

```

---

<div class="post-metadata">

**Author:** ![av-ipunkt](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@av-ipunkt](https://kanboard.discourse.group/u/av-ipunkt)\
**Post date:** [October 9, 2019, 12:36pm UTC](https://kanboard.discourse.group/t/controller-not-found/754/6 "2019-10-09T12:36:21Z")

</div>

sure, I’ve noticed that after I’ve posted this comment here. I’ve changed to Plugin… but it didn’t do the trick- Still no plugin found. And the second one is also not found. But the class for settings page is working

```
  $this->route->addRoute('settings/commentactions', 'CommentActionsSettingsController', 'index',
        'CommentActions');

```

![Bildschirmfoto%20von%202019-10-09%2014-37-01](https://global.discourse-cdn.com/free1/uploads/kanboard1/original/1X/b3ce9759f5e4eadc1a853dbed57572e80c895b4f.png)

---

<div class="post-metadata">

**Author:** ![rafaelcamargo](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/rafaelcamargo/32/279_2.png) [@rafaelcamargo](https://kanboard.discourse.group/u/rafaelcamargo)\
**Post date:** [October 9, 2019, 12:51pm UTC](https://kanboard.discourse.group/t/controller-not-found/754/7 "2019-10-09T12:51:35Z")

</div>

When is the error happening?  
Is it when you are accessing an url to the controller? If so, can you provide the full path being accessed?  
Are you trying to override Kanboard’s CommentController with your CommentActionsController? Or CommentActionsController should be registered as a new controller, named CommentActionsController?

---

<div class="post-metadata">

**Author:** ![av-ipunkt](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@av-ipunkt](https://kanboard.discourse.group/u/av-ipunkt)\
**Post date:** [October 9, 2019, 12:56pm UTC](https://kanboard.discourse.group/t/controller-not-found/754/8 "2019-10-09T12:56:41Z")

</div>

> When is the error happening?

by saving the comment / by posting

```
<form method="post"
  action="<?= $this->url->href('CommentActionsController', 'save',
      array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"

```

localhost/?controller=CommentActionsController&action=save&task\_id=1&project\_id=1  
error: Internal Error: Controller not found

> Are you trying to override Kanboard’s CommentController with your CommentActionsController?

I quess, I am trying to override CommentController class with my own.

> CommentActionsController should be registered as a new controller, named CommentActionsController?

Am I not registering/overriding my CommentActionsController with getClasses() as new Controller?

---

<div class="post-metadata">

**Author:** ![rafaelcamargo](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/rafaelcamargo/32/279_2.png) [@rafaelcamargo](https://kanboard.discourse.group/u/rafaelcamargo)\
**Post date:** [October 9, 2019, 1:10pm UTC](https://kanboard.discourse.group/t/controller-not-found/754/9 "2019-10-09T13:10:13Z")

</div>

The problem is that your controller URL is missing your plugin name.  
You should change your form url to this:

```auto
<form method="post"
  action="<?= $this->url->href('CommentActionsController', 'save',
      array('plugin' => 'CommentActions', 'task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>"

```

> [@av-ipunkt](#):
>
> Am I not registering/overriding my CommentActionsController with getClasses() as new Controller?

Actually, you are registering a new Controller.  
The default controller, CommentController, will still be accessible. When you want to point to your new controller you have to make sure to send the “plugin” parameter with your plugin name along with the controller name

---

<div class="post-metadata">

**Author:** ![rafaelcamargo](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/rafaelcamargo/32/279_2.png) [@rafaelcamargo](https://kanboard.discourse.group/u/rafaelcamargo)\
**Post date:** [October 9, 2019, 1:11pm UTC](https://kanboard.discourse.group/t/controller-not-found/754/10 "2019-10-09T13:11:17Z")

</div>

> [@av-ipunkt](#):
>
> localhost/?controller=CommentActionsController&action=save&task\_id=1&project\_id=1

Then your URL will look like this:  
`localhost/?plugin=CommentActions&controller=CommentActionsController&action=save&task_id=1&project_id=1`

---

<div class="post-metadata">

**Author:** ![av-ipunkt](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@av-ipunkt](https://kanboard.discourse.group/u/av-ipunkt)\
**Post date:** [October 9, 2019, 1:17pm UTC](https://kanboard.discourse.group/t/controller-not-found/754/11 "2019-10-09T13:17:38Z")

</div>

Strange, I tried also inserting ‘plugin’ =\> ‘CommentActions’ but to the end of array, like this:

```
<form method="post"
 action="<?= $this->url->href('CommentActionsController', 'save',
  array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'plugin' => 'CommentActions')) ?>"the 

```

page was just freezing.

Did , how you wrote and the URL is such:

localhost/?controller=CommentActionsController&action=save&plugin=CommentActions&task\_id=1&project\_id=1

plugin name goes after save action. But I think it is not important.  
Thank you very much, I’ve struggled over this blocker for allmost 2 days. Now I have other bugs, but that will be in another story ))

---

<div class="post-metadata">

**Author:** ![rafaelcamargo](https://yyz2.discourse-cdn.com/free1/user_avatar/kanboard.discourse.group/rafaelcamargo/32/279_2.png) [@rafaelcamargo](https://kanboard.discourse.group/u/rafaelcamargo)\
**Post date:** [October 9, 2019, 1:49pm UTC](https://kanboard.discourse.group/t/controller-not-found/754/12 "2019-10-09T13:49:44Z")

</div>

The order of the params and the order of the elements inside the array should not matter

---

<div class="post-metadata">

**Author:** ![av-ipunkt](https://avatars.discourse-cdn.com/v4/letter/a/a87d85/32.png) [@av-ipunkt](https://kanboard.discourse.group/u/av-ipunkt)\
**Post date:** [October 9, 2019, 1:51pm UTC](https://kanboard.discourse.group/t/controller-not-found/754/13 "2019-10-09T13:51:10Z")

</div>

good to know.  
Thank you once more for your time and help )
