Skip to content

Commit

Permalink
EZP-30094: User is unable to change object state
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwojs committed Feb 1, 2019
1 parent fe79a54 commit 5940f4a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/bundle/Controller/ObjectStateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@
use EzSystems\EzPlatformAdminUi\Form\Data\ObjectState\ObjectStateDeleteData;
use EzSystems\EzPlatformAdminUi\Form\Data\ObjectState\ObjectStatesDeleteData;
use EzSystems\EzPlatformAdminUi\Form\Data\ObjectState\ObjectStateUpdateData;
use EzSystems\EzPlatformAdminUi\Form\Factory\FormFactory;
use EzSystems\EzPlatformAdminUi\Form\SubmitHandler;
use EzSystems\EzPlatformAdminUi\Form\Type\ObjectState\ContentObjectStateUpdateType;
use EzSystems\EzPlatformAdminUi\Form\Type\ObjectState\ObjectStateCreateType;
use EzSystems\EzPlatformAdminUi\Form\Type\ObjectState\ObjectStateDeleteType;
use EzSystems\EzPlatformAdminUi\Form\Type\ObjectState\ObjectStatesDeleteType;
use EzSystems\EzPlatformAdminUi\Form\Type\ObjectState\ObjectStateUpdateType;
use EzSystems\EzPlatformAdminUi\Notification\NotificationHandlerInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Translation\TranslatorInterface;
Expand All @@ -37,7 +42,7 @@ class ObjectStateController extends Controller
/** @var \eZ\Publish\API\Repository\ObjectStateService */
private $objectStateService;

/** @var \EzSystems\EzPlatformAdminUi\Form\Factory\FormFactory */
/** @var \Symfony\Component\Form\FormFactoryInterface */
private $formFactory;

/** @var \EzSystems\EzPlatformAdminUi\Form\SubmitHandler */
Expand All @@ -53,7 +58,7 @@ class ObjectStateController extends Controller
* @param \EzSystems\EzPlatformAdminUi\Notification\NotificationHandlerInterface $notificationHandler
* @param \Symfony\Component\Translation\TranslatorInterface $translator
* @param \eZ\Publish\API\Repository\ObjectStateService $objectStateService
* @param \EzSystems\EzPlatformAdminUi\Form\Factory\FormFactory $formFactory
* @param \Symfony\Component\Form\FormFactoryInterface $formFactory
* @param \EzSystems\EzPlatformAdminUi\Form\SubmitHandler $submitHandler
* @param \eZ\Publish\API\Repository\PermissionResolver $permissionResolver
* @param array $languages
Expand All @@ -62,7 +67,7 @@ public function __construct(
NotificationHandlerInterface $notificationHandler,
TranslatorInterface $translator,
ObjectStateService $objectStateService,
FormFactory $formFactory,
FormFactoryInterface $formFactory,
SubmitHandler $submitHandler,
PermissionResolver $permissionResolver,
array $languages
Expand All @@ -86,7 +91,8 @@ public function listAction(ObjectStateGroup $objectStateGroup): Response
/** @var ObjectState[] $objectStates */
$objectStates = $this->objectStateService->loadObjectStates($objectStateGroup);

$deleteObjectStatesForm = $this->formFactory->deleteObjectStates(
$deleteObjectStatesForm = $this->formFactory->create(
ObjectStatesDeleteType::class,
new ObjectStatesDeleteData($this->getObjectStatesIds($objectStates))
);

Expand All @@ -112,7 +118,8 @@ public function listAction(ObjectStateGroup $objectStateGroup): Response
*/
public function viewAction(ObjectState $objectState): Response
{
$deleteForm = $this->formFactory->deleteObjectState(
$deleteForm = $this->formFactory->create(
ObjectStateDeleteType::class,
new ObjectStateDeleteData($objectState)
)->createView();

Expand All @@ -135,7 +142,8 @@ public function addAction(Request $request, ObjectStateGroup $objectStateGroup):
$this->denyAccessUnlessGranted(new Attribute('state', 'administrate'));
$defaultLanguageCode = reset($this->languages);

$form = $this->formFactory->createObjectState(
$form = $this->formFactory->create(
ObjectStateCreateType::class,
new ObjectStateCreateData()
);
$form->handleRequest($request);
Expand Down Expand Up @@ -183,7 +191,8 @@ function (ObjectStateCreateData $data) use ($defaultLanguageCode, $objectStateGr
public function deleteAction(Request $request, ObjectState $objectState): Response
{
$this->denyAccessUnlessGranted(new Attribute('state', 'administrate'));
$form = $this->formFactory->deleteObjectState(
$form = $this->formFactory->create(
ObjectStateDeleteType::class,
new ObjectStateDeleteData($objectState)
);
$form->handleRequest($request);
Expand Down Expand Up @@ -224,7 +233,8 @@ public function deleteAction(Request $request, ObjectState $objectState): Respon
public function bulkDeleteAction(Request $request, int $objectStateGroupId): Response
{
$this->denyAccessUnlessGranted(new Attribute('state', 'administrate'));
$form = $this->formFactory->deleteObjectStates(
$form = $this->formFactory->create(
ObjectStatesDeleteType::class,
new ObjectStatesDeleteData()
);
$form->handleRequest($request);
Expand Down Expand Up @@ -265,7 +275,8 @@ public function bulkDeleteAction(Request $request, int $objectStateGroupId): Res
public function updateAction(Request $request, ObjectState $objectState): Response
{
$this->denyAccessUnlessGranted(new Attribute('state', 'administrate'));
$form = $this->formFactory->updateObjectState(
$form = $this->formFactory->create(
ObjectStateUpdateType::class,
new ObjectStateUpdateData($objectState)
);
$form->handleRequest($request);
Expand Down Expand Up @@ -327,7 +338,8 @@ public function updateContentStateAction(
throw $exception;
}

$form = $this->formFactory->updateContentObjectState(
$form = $this->formFactory->create(
ContentObjectStateUpdateType::class,
new ContentObjectStateUpdateData($contentInfo, $objectStateGroup)
);
$form->handleRequest($request);
Expand Down
10 changes: 10 additions & 0 deletions src/lib/Form/Factory/FormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,8 @@ public function updateObjectStateGroup(
* @param null|string $name
*
* @return FormInterface
*
* @deprecated since version 2.2, to be removed in 3.0. Use Use \Symfony\Component\Form\FormFactoryInterface::create directly instead.
*/
public function createObjectState(
?ObjectStateCreateData $data = null,
Expand All @@ -1155,6 +1157,8 @@ public function createObjectState(
* @param null|string $name
*
* @return FormInterface
*
* @deprecated since version 2.2, to be removed in 3.0. Use Use \Symfony\Component\Form\FormFactoryInterface::create directly instead.
*/
public function deleteObjectState(
ObjectStateDeleteData $data = null,
Expand All @@ -1172,6 +1176,8 @@ public function deleteObjectState(
* @return FormInterface
*
* @throws InvalidOptionsException
*
* @deprecated since version 2.2, to be removed in 3.0. Use Use \Symfony\Component\Form\FormFactoryInterface::create directly instead.
*/
public function deleteObjectStates(
ObjectStatesDeleteData $data = null,
Expand All @@ -1187,6 +1193,8 @@ public function deleteObjectStates(
* @param null|string $name
*
* @return FormInterface
*
* @deprecated since version 2.2, to be removed in 3.0. Use Use \Symfony\Component\Form\FormFactoryInterface::create directly instead.
*/
public function updateObjectState(
ObjectStateUpdateData $data = null,
Expand All @@ -1202,6 +1210,8 @@ public function updateObjectState(
* @param null|string $name
*
* @return FormInterface
*
* @deprecated since version 2.2, to be removed in 3.0. Use Use \Symfony\Component\Form\FormFactoryInterface::create directly instead.
*/
public function updateContentObjectState(
ContentObjectStateUpdateData $data,
Expand Down

0 comments on commit 5940f4a

Please sign in to comment.