Hello Mautic Community,
I just started learning how to make Mautic Plugin. I have not come far yet, but I am not giving up.
I created the following config file, which successfully adds a button to my Mautic (5.0.2) Menu on the left side
<?php
return [
'name' => 'MyPluginBundle',
'description' => 'Do Something with Mautic',
'author' => 'McDiver', // Change this to plugin author
'version' => '0.0.1', // Change this version to your appropriate version'services' => [
'services' => [
'helpers' => [
'plugin.myplugin.model.myplugin' => [
'class' => \MauticPlugin\MyPluginBundle\Model\MyPluginModel::class,
'arguments' => []
]
]
],
'menu' => [
'main' => [
'items' => [
'plugin.myplugin.menu.index' => [
'iconClass' => 'fa-line-chart',
'children' => [
'plugin.myplugin.menu.upload' => [
'route' => 'myplugin_default',
],
],
'priority' => -999,
],
],
],
],
'routes' => [
'main' => [
'myplugin_default' => [
'path' => '/myplugin',
'controller' => 'MyPluginBundle:MyPlugin:default',
],
],
],
];
Next I want to call MyController if I press the submenu in the left bar (plugin.myplugin.menu.upload) Unfortunately, this is where I struggle. Mautic logs that the Controller is not callable. Do I get it right, that Mautic cannot find the controller itself, which I defined in routes path? Do I have to pass the path somewhere special?
The controller is in the Controller subdirectory and looks like this
<?php
/*
* @copyright 2014 Mautic Contributors. All rights reserved
* @author Mautic
*
* @link http://mautic.org
*
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
namespace MauticPlugin\MyPluginBundle\Controller;
use Mautic\CoreBundle\Controller\FormController;
class MyPluginController extends FormController
{
public function defaultAction()
{
$arn = "HelloWorld";
// Here will follow some code...
}
}
The target is that if I press the new menu in the left bar, I can see a mask for inserting some data, which shall later be pushed to some contacts. This is just an idea for learning.
I read all HelloWorld examples, took a look in other Bundles and asked ChatGpt, but unforutnately unsuccessfull.
Please let me know, if you need further information
I am happy to read from you!