I am in the users controller
<?php
declare(strict_types=1);
namespace App\Controller;
/**
* Users Controller
*
* @property \App\Model\Table\UsersTable $Users
* @method \App\Model\Entity\User[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
*/
class UsersController extends AppController
{
public function initialize() : void
{
parent::initialize();
$this->Auth->allow();
}
public function rigthts(){`Preformatted text`
$this->loadModel('ArosAcos');
$data_arr = [
aco_id' => $acos_id,
'aro_id' => $aros_id,
'_create' => 1,
'_read' => 1,
'_update' => 1,
'_delete' => 1
];
$AcosAro = $this->ArosAcos->newEmptyEntity();
//$AcosAro = $this->ArosAcos->newEntity();
$AcosAro = $this->ArosAcos->patchEntity($AcosAro , $data_arr);
$this->ArosAcos->save($Acos );
}
AFAIK you shouln’t create an ArosAcos entity directly. Instead rely on the AclComponent
$this->Acl->allow(
[
'model' => 'Users',
'foreign_key' => $user->id,
],
'controllers'
);