diff --git a/composer.json b/composer.json index 7e8d25f..29aa910 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "minimum-stability": "dev", "require": { "php": "~8.3.0 || ~8.4.0", - "pimcore/pimcore": "^12.0", + "pimcore/pimcore": "^12.3", "symfony/event-dispatcher-contracts": "^3.0" }, "require-dev": { diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 5a1d48a..95db099 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -12,6 +12,7 @@ namespace OutputDataConfigToolkitBundle\Controller; +use Pimcore\Helper\ParameterBagHelper; use OutputDataConfigToolkitBundle\Event\InitializeEvent; use OutputDataConfigToolkitBundle\Event\OutputDataConfigToolkitEvents; use OutputDataConfigToolkitBundle\Event\SaveConfigEvent; @@ -67,7 +68,7 @@ public static function getSubscribedServices(): array #[Route('/initialize')] public function initializeAction(Request $request, EventDispatcherInterface $eventDispatcher) { - $objectId = $request->query->getInt('id'); + $objectId = ParameterBagHelper::getInt($request->query, 'id'); $object = AbstractObject::getById($objectId); if (!$object) { @@ -98,7 +99,7 @@ public function getOutputConfigsAction(Request $request) Service::initChannelsForRootobject(); $channels = Service::getChannels(); - $objectId = $request->request->getInt('object_id'); + $objectId = ParameterBagHelper::getInt($request->request, 'object_id'); $object = AbstractObject::getById($objectId); $classList = $this->getFilteredClassDefinitionList($request); @@ -159,7 +160,7 @@ private function getOutputDefinitionForObjectAndChannel($object, $classId, $chan public function resetOutputConfigAction(Request $request) { try { - $config = OutputDefinition::getById($request->query->getInt('config_id')); + $config = OutputDefinition::getById(ParameterBagHelper::getInt($request->query, 'config_id')); $config->delete(); return $this->jsonResponse(['success' => true]); @@ -179,7 +180,7 @@ public function resetOutputConfigAction(Request $request) public function getOutputConfigAction(Request $request) { try { - $config = OutputDefinition::getById($request->query->getInt('config_id')); + $config = OutputDefinition::getById(ParameterBagHelper::getInt($request->query, 'config_id')); $objectClass = ClassDefinition::getById($config->getClassId()); $configuration = json_decode($config->getConfiguration()); @@ -204,7 +205,7 @@ public function getOutputConfigAction(Request $request) public function getOrCreateOutputConfigAction(Request $request) { try { - $config = OutputDefinition::getById($request->query->getInt('config_id')); + $config = OutputDefinition::getById(ParameterBagHelper::getInt($request->query, 'config_id')); $class = null; if (!$config) { if ($request->query->has('class_id')) { @@ -214,7 +215,7 @@ public function getOrCreateOutputConfigAction(Request $request) throw new \Exception('Class ' . $request->query->getString('class_id') . ' not found.'); } - $config = OutputDefinition::getByObjectIdClassIdChannel($request->query->getInt('objectId'), $class->getId(), $request->query->getString('channel')); + $config = OutputDefinition::getByObjectIdClassIdChannel(ParameterBagHelper::getInt($request->query, 'objectId'), $class->getId(), $request->query->getString('channel')); } if ($config) { @@ -228,7 +229,7 @@ public function getOrCreateOutputConfigAction(Request $request) $config = new OutputDefinition(); $config->setChannel($request->query->getString('channel')); $config->setClassId($class->getId()); - $config->setObjectId($request->query->getInt('objectId')); + $config->setObjectId(ParameterBagHelper::getInt($request->query, 'objectId')); $config->save(); return $this->jsonResponse(['success' => true, 'outputConfig' => $config]); @@ -412,13 +413,13 @@ public function getFieldDefinitionAction(Request $request) public function saveOutputConfigAction(Request $request, EventDispatcherInterface $eventDispatcher) { try { - $config = OutputDefinition::getById($request->request->getInt('config_id')); + $config = OutputDefinition::getById(ParameterBagHelper::getInt($request->request, 'config_id')); - $object = AbstractObject::getById($request->request->getInt('object_id')); + $object = AbstractObject::getById(ParameterBagHelper::getInt($request->request, 'object_id')); if (empty($object)) { - throw new \Exception('Data Object with ID' . $request->request->getInt('object_id') . ' not found.'); + throw new \Exception('Data Object with ID' . ParameterBagHelper::getInt($request->request, 'object_id') . ' not found.'); } - if ($config->getObjectId() != $request->request->getInt('object_id')) { + if ($config->getObjectId() != ParameterBagHelper::getInt($request->request, 'object_id')) { $newConfig = new OutputDefinition(); $newConfig->setChannel($config->getChannel()); $newConfig->setClassId($config->getClassId()); diff --git a/src/Controller/ClassController.php b/src/Controller/ClassController.php index 49cd438..40ef4c7 100644 --- a/src/Controller/ClassController.php +++ b/src/Controller/ClassController.php @@ -12,6 +12,7 @@ namespace OutputDataConfigToolkitBundle\Controller; +use Pimcore\Helper\ParameterBagHelper; use Doctrine\DBAL\Exception\TableNotFoundException; use OutputDataConfigToolkitBundle\Constant\ColumnConfigDisplayMode; use OutputDataConfigToolkitBundle\Event; @@ -54,7 +55,7 @@ public function getClassDefinitionForColumnConfigAction(Request $request, EventD { $classId = $request->query->getString('id'); $class = DataObject\ClassDefinition::getById($classId); - $objectId = $request->query->getInt('oid'); + $objectId = ParameterBagHelper::getInt($request->query, 'oid'); $filteredDefinitions = DataObject\Service::getCustomLayoutDefinitionForGridColumnConfig($class, $objectId); @@ -128,7 +129,7 @@ private function considerClassificationStoreForColumnConfig(Request $request, ?D $enrichment = false; $grouped = $this->getClassificationGroupedDisplay(); if ($displayMode == ColumnConfigDisplayMode::DATA_OBJECT || $displayMode == ColumnConfigDisplayMode::RELEVANT) { - $targetObjectId = $request->query->getInt('target_oid'); + $targetObjectId = ParameterBagHelper::getInt($request->query, 'target_oid'); if ($targetObject = DataObject\Concrete::getById($targetObjectId)) { $class->setFieldDefinitions($fieldDefinitions);