use override table trait to allow for easily customzing table a controller uses
This commit is contained in:
@@ -8,6 +8,7 @@ use Cake\Log\Log;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\ORM\TableRegistry;
|
||||
use CakeProducts\Controller\AppController;
|
||||
use CakeProducts\Controller\Traits\OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* ExternalProductCatalogs Controller
|
||||
@@ -16,26 +17,16 @@ use CakeProducts\Controller\AppController;
|
||||
*/
|
||||
class ExternalProductCatalogsController extends AppController
|
||||
{
|
||||
/**
|
||||
* @var Table|null
|
||||
*/
|
||||
protected ?Table $_table = null;
|
||||
use OverrideTableTrait;
|
||||
|
||||
/**
|
||||
* Gets the table instance
|
||||
*
|
||||
* @return Table
|
||||
* @return void
|
||||
*/
|
||||
public function getTable()
|
||||
public function initialize(): void
|
||||
{
|
||||
if ($this->_table instanceof Table) {
|
||||
return $this->_table;
|
||||
}
|
||||
$this->_table = TableRegistry::getTableLocator()->get(
|
||||
Configure::read('CakeProducts.ExternalProductCatalogs.table', 'CakeProducts.ExternalProductCatalogs')
|
||||
);
|
||||
|
||||
return $this->_table;
|
||||
parent::initialize(); // TODO: Change the autogenerated stub
|
||||
$this->_defaultTable = 'CakeProducts.ExternalProductCatalogs';
|
||||
$this->_tableConfigKey = 'CakeProducts.ExternalProductCatalogs.table';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user