Commit f6a767fe authored by Tino Goratsch's avatar Tino Goratsch

simplified the implementations of the AbstractNestedSetModel class

parent 2880ebeb
......@@ -7,65 +7,22 @@
namespace ACP3\Modules\ACP3\Menus\Model;
use ACP3\Core\Helpers\Secure;
use ACP3\Core\Model\AbstractNestedSetModel;
use ACP3\Core\Model\DataProcessor;
use ACP3\Core\NestedSet\Operation\Delete;
use ACP3\Core\NestedSet\Operation\Edit;
use ACP3\Core\NestedSet\Operation\Insert;
use ACP3\Modules\ACP3\Menus\Installer\Schema;
use ACP3\Modules\ACP3\Menus\Model\Repository\MenuItemRepository;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class MenuItemsModel extends AbstractNestedSetModel
{
const EVENT_PREFIX = Schema::MODULE_NAME;
/**
* @var Secure
*/
protected $secure;
/**
* MenuItemsModel constructor.
* @param EventDispatcherInterface $eventDispatcher
* @param DataProcessor $dataProcessor
* @param MenuItemRepository $repository
* @param Insert $insertOperation
* @param Edit $editOperation
* @param Delete $deleteOperation
* @param Secure $secure
*/
public function __construct(
EventDispatcherInterface $eventDispatcher,
DataProcessor $dataProcessor,
MenuItemRepository $repository,
Insert $insertOperation,
Edit $editOperation,
Delete $deleteOperation,
Secure $secure
) {
parent::__construct($eventDispatcher, $dataProcessor, $repository, $insertOperation, $editOperation, $deleteOperation);
$this->secure = $secure;
}
/**
* @param array $formData
* @param array $data
* @param null|int $entryId
* @return bool|int
*/
public function saveMenuItem(array $formData, $entryId = null)
public function saveMenuItem(array $data, $entryId = null)
{
$data = [
'mode' => (int)$formData['mode'],
'block_id' => (int)$formData['block_id'],
'parent_id' => (int)$formData['parent_id'],
'display' => $formData['display'],
'title' => $this->secure->strEncode($formData['title']),
'uri' => $formData['uri'],
'target' => $formData['display'] == 0 ? 1 : $formData['target'],
];
$data['target'] = $data['display'] == 0 ? 1 : $data['target'];
return $this->save($data, $entryId);
}
......
......@@ -25,4 +25,3 @@ services:
- '@menus.nested_set.operation.insert'
- '@menus.nested_set.operation.edit'
- '@menus.nested_set.operation.delete'
- '@core.helpers.secure'
......@@ -7,61 +7,21 @@
namespace ACP3\Modules\ACP3\Permissions\Model;
use ACP3\Core\Helpers\Secure;
use ACP3\Core\Model\AbstractNestedSetModel;
use ACP3\Core\Model\DataProcessor;
use ACP3\Core\NestedSet\Operation\Delete;
use ACP3\Core\NestedSet\Operation\Edit;
use ACP3\Core\NestedSet\Operation\Insert;
use ACP3\Modules\ACP3\Permissions\Installer\Schema;
use ACP3\Modules\ACP3\Permissions\Model\Repository\RoleRepository;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class RolesModel extends AbstractNestedSetModel
{
const EVENT_PREFIX = Schema::MODULE_NAME;
/**
* @var Secure
*/
protected $secure;
/**
* RoleModel constructor.
* @param EventDispatcherInterface $eventDispatcher
* @param DataProcessor $dataProcessor
* @param RoleRepository $roleRepository
* @param Insert $insertOperation
* @param Edit $editOperation
* @param Delete $deleteOperation
* @param Secure $secure
*/
public function __construct(
EventDispatcherInterface $eventDispatcher,
DataProcessor $dataProcessor,
RoleRepository $roleRepository,
Insert $insertOperation,
Edit $editOperation,
Delete $deleteOperation,
Secure $secure
) {
parent::__construct($eventDispatcher, $dataProcessor, $roleRepository, $insertOperation, $editOperation, $deleteOperation);
$this->secure = $secure;
}
/**
* @param array $formData
* @param array $data
* @param int|null $entryId
* @return bool|int
*/
public function saveRole(array $formData, $entryId = null)
public function saveRole(array $data, $entryId = null)
{
$data = [
'name' => $this->secure->strEncode($formData['name']),
'parent_id' => (int)$formData['parent_id'],
];
return $this->save($data, $entryId);
}
......
......@@ -40,7 +40,6 @@ services:
- '@permissions.nested_set.operation.insert'
- '@permissions.nested_set.operation.edit'
- '@menus.nested_set.operation.delete'
- '@core.helpers.secure'
permissions.model.rules_model:
class: ACP3\Modules\ACP3\Permissions\Model\RulesModel
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment