Skip to content

Commit

Permalink
fix: Code Review
Browse files Browse the repository at this point in the history
  • Loading branch information
Nattfarinn committed Mar 12, 2018
1 parent dbd2093 commit 3af9d7b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 95 deletions.
49 changes: 28 additions & 21 deletions src/bundle/Controller/ContentOnTheFlyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use EzSystems\RepositoryForms\Form\Type\Content\ContentEditType;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class ContentOnTheFlyController extends Controller
{
Expand All @@ -36,10 +35,10 @@ class ContentOnTheFlyController extends Controller
private $contentActionDispatcher;

/**
* @param ContentService $contentService
* @param LanguageService $languageService
* @param LocationService $locationService
* @param ContentOnTheFlyDispatcher $contentActionDispatcher
* @param \eZ\Publish\API\Repository\ContentService $contentService
* @param \eZ\Publish\API\Repository\LanguageService $languageService
* @param \eZ\Publish\API\Repository\LocationService $locationService
* @param \EzSystems\EzPlatformAdminUi\RepositoryForms\Dispatcher\ContentOnTheFlyDispatcher $contentActionDispatcher
*/
public function __construct(
ContentService $contentService,
Expand All @@ -54,18 +53,22 @@ public function __construct(
}

/**
* @param Request $request
* @param \Symfony\Component\HttpFoundation\Request $request
* @param string $languageCode
* @param ContentType $contentType
* @param Location $parentLocation
* @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
* @param \eZ\Publish\API\Repository\Values\Content\Location $parentLocation
*
* @return ContentCreateOnTheFlyView|Response
* @return \EzSystems\EzPlatformAdminUi\RepositoryForms\View\ContentCreateOnTheFlyView|null|\Symfony\Component\HttpFoundation\Response
*
* @throws ApiException\NotFoundException
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
* @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType
*/
public function createContentAction(Request $request, string $languageCode, ContentType $contentType, Location $parentLocation)
{
public function createContentAction(
Request $request,
string $languageCode,
ContentType $contentType,
Location $parentLocation
) {
$language = $this->languageService->loadLanguage($languageCode);

$data = (new ContentCreateMapper())->mapToFormData($contentType, [
Expand All @@ -87,7 +90,7 @@ public function createContentAction(Request $request, string $languageCode, Cont
}
}

return new ContentCreateOnTheFlyView(null, [
return new ContentCreateOnTheFlyView('@EzPlatformAdminUi/content/content_on_the_fly/content_create_on_the_fly.html.twig', [
'form' => $form->createView(),
'language' => $language,
'contentType' => $contentType,
Expand All @@ -96,18 +99,22 @@ public function createContentAction(Request $request, string $languageCode, Cont
}

/**
* @param Request $request
* @param \Symfony\Component\HttpFoundation\Request $request
* @param string $languageCode
* @param ContentType $contentType
* @param Location $parentLocation
* @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
* @param \eZ\Publish\API\Repository\Values\Content\Location $parentLocation
*
* @return JsonResponse
* @return \Symfony\Component\HttpFoundation\JsonResponse
*
* @throws ApiException\BadStateException
* @throws ApiException\InvalidArgumentException
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
*/
public function hasCreateAccessAction(Request $request, string $languageCode, ContentType $contentType, Location $parentLocation)
{
public function hasCreateAccessAction(
Request $request,
string $languageCode,
ContentType $contentType,
Location $parentLocation
) {
$response = new JsonResponse();

try {
Expand Down
3 changes: 0 additions & 3 deletions src/bundle/Resources/config/default_parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ parameters:
ezsettings.admin_group.user_edit.templates.update: 'EzPlatformAdminUiBundle:content/content_edit:user_edit.html.twig'
ezsettings.admin_group.user_edit.templates.create: 'EzPlatformAdminUiBundle:content/content_edit:user_create.html.twig'

ezsettings.admin_group.content_on_the_fly.templates.create: 'EzPlatformAdminUiBundle:content/content_on_the_fly:content_create_on_the_fly.html.twig'
ezsettings.default.content_on_the_fly.templates.create: '%ezsettings.admin_group.content_on_the_fly.templates.create%'

ezsettings.global.system_info_view:
pjax_tab:
composer:
Expand Down
4 changes: 2 additions & 2 deletions src/bundle/Resources/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -561,15 +561,15 @@ ezplatform.custom_url.add:
#

ezplatform.content_on_the_fly.create:
path: /content/create/onthefly/{contentTypeIdentifier}/{languageCode}/{locationId}
path: /content/create/on-the-fly/{contentTypeIdentifier}/{languageCode}/{locationId}
methods: ['GET', 'POST']
defaults:
_controller: 'EzPlatformAdminUiBundle:ContentOnTheFly:createContent'
options:
expose: true

ezplatform.content_on_the_fly.has_access:
path: /content/create/onthefly/{contentTypeIdentifier}/{languageCode}/{locationId}/hasaccess
path: /content/create/on-the-fly/{contentTypeIdentifier}/{languageCode}/{locationId}/has-access
methods: ['GET']
defaults:
_controller: 'EzPlatformAdminUiBundle:ContentOnTheFly:hasCreateAccess'
Expand Down
6 changes: 0 additions & 6 deletions src/bundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,6 @@ services:
EzSystems\EzPlatformAdminUi\Form\EventListener\:
resource: '../../../lib/Form/EventListener'

EzSystems\EzPlatformAdminUi\RepositoryForms\View\ViewTemplatesListener:
tags:
- { name: kernel.event_subscriber }
calls:
- [setViewTemplate, ['EzSystems\EzPlatformAdminUi\RepositoryForms\View\ContentCreateOnTheFlyView', '$content_on_the_fly.templates.create$']]

EzSystems\EzPlatformAdminUi\RepositoryForms\Dispatcher\ContentOnTheFlyDispatcher:
calls:
- [setEventDispatcher, ["@event_dispatcher"]]
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class ContentOnTheFlyProcessor implements EventSubscriberInterface
private $twig;

/**
* @param ContentService $contentService
* @param Environment $twig
* @param \eZ\Publish\API\Repository\ContentService $contentService
* @param \Twig\Environment $twig
*/
public function __construct(ContentService $contentService, Environment $twig)
{
Expand All @@ -46,7 +46,7 @@ public static function getSubscribedEvents()
}

/**
* @param FormActionEvent $event
* @param \EzSystems\RepositoryForms\Event\FormActionEvent $event
*
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
Expand All @@ -59,7 +59,6 @@ public static function getSubscribedEvents()
*/
public function processPublish(FormActionEvent $event)
{
/** @var \EzSystems\RepositoryForms\Data\Content\ContentCreateData|\EzSystems\RepositoryForms\Data\Content\ContentUpdateData $data */
$data = $event->getData();
$form = $event->getForm();

Expand Down
59 changes: 0 additions & 59 deletions src/lib/RepositoryForms/View/ViewTemplatesListener.php

This file was deleted.

0 comments on commit 3af9d7b

Please sign in to comment.