I thought I'd figured out how this namespacing works, but apparently not.
I have a component with this model:
administrator/components/com_example/src/Model/FlowsModel.phpMy Controller looks like this:
administrator/components/com_example/src/Controller/FlowsController.phpWhen I run the code I get "Model not found" message, so $this->getModel('Flows', 'Administrator'); is not finding the model. I don't understand why, maybe I'm fundamentally misunderstanding how this is supposed to work.
Any ideas very welcome
I have a component with this model:
administrator/components/com_example/src/Model/FlowsModel.php
Code:
namespace Acme\Component\Example\Administrator\Model;use Joomla\CMS\MVC\Model\ListModel;class FlowsModel extends ListModel{ public function copyflows($ids) { return 'success'; }}
administrator/components/com_example/src/Controller/FlowsController.php
Code:
namespace Acme\Component\Example\Administrator\Controller;use Joomla\CMS\MVC\Controller\AdminController;class FlowsController extends AdminController{ public function copyflows() { // Get the input $pks = $this->input->post->get('cid', array(), 'array'); $pks = ArrayHelper::toInteger($pks); // Get the model $model = $this->getModel('Flows', 'Administrator'); // Check if the model exists and call the copyflows method if ($model) $msg = $model->copyflows($pks); else $msg = 'Model not found';// <<<<< THIS MESSAGE IS DISPLAYED Factory::getApplication()->enqueueMessage($msg, 'notice'); $this->setRedirect(Route::_('index.php?option=com_example&view=flows', false)); }}
Any ideas very welcome
Statistics: Posted by david0058 — Tue Dec 31, 2024 5:16 pm