mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 15:06:06 +00:00
controllers refactoring
This commit is contained in:
@@ -29,8 +29,17 @@
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
class GlobalSearch extends \Espo\Core\Controllers\Base
|
||||
use Espo\Core\ServiceFactory;
|
||||
|
||||
class GlobalSearch
|
||||
{
|
||||
protected $serviceFactory;
|
||||
|
||||
public function __construct(ServiceFactory $serviceFactory)
|
||||
{
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
}
|
||||
|
||||
public function actionSearch($params, $data, $request)
|
||||
{
|
||||
$query = $request->get('q');
|
||||
@@ -38,6 +47,6 @@ class GlobalSearch extends \Espo\Core\Controllers\Base
|
||||
$offset = intval($request->get('offset'));
|
||||
$maxSize = intval($request->get('maxSize'));
|
||||
|
||||
return $this->getService('GlobalSearch')->find($query, $offset, $maxSize);
|
||||
return $this->serviceFactory->create('GlobalSearch')->find($query, $offset, $maxSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,12 +29,21 @@
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
class I18n extends \Espo\Core\Controllers\Base
|
||||
use Espo\Core\ServiceFactory;
|
||||
|
||||
class I18n
|
||||
{
|
||||
protected $serviceFactory;
|
||||
|
||||
public function __construct(ServiceFactory $serviceFactory)
|
||||
{
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
}
|
||||
|
||||
public function actionRead($params, $data, $request)
|
||||
{
|
||||
$default = $request->get('default') === 'true';
|
||||
|
||||
return $this->getServiceFactory()->create('Language')->getDataForFrontend($default);
|
||||
return $this->serviceFactory->create('Language')->getDataForFrontend($default);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user