Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix-front-controller' into fix-f…
Browse files Browse the repository at this point in the history
…ront-controller
  • Loading branch information
chihiro-adachi committed Aug 22, 2017
2 parents 28ded27 + e2eaccb commit c3ca858
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 42 deletions.
25 changes: 23 additions & 2 deletions src/Eccube/Controller/Admin/Content/BlockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use Doctrine\ORM\EntityManager;
use Eccube\Annotation\Inject;
use Eccube\Annotation\Component;
use Eccube\Application;
use Eccube\Controller\AbstractController;
use Eccube\Entity\Master\DeviceType;
Expand All @@ -35,13 +36,20 @@
use Eccube\Repository\BlockRepository;
use Eccube\Repository\Master\DeviceTypeRepository;
use Eccube\Util\Str;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
* @Component
* @Route(service=BlockController::class)
*/
class BlockController extends AbstractController
{
/**
Expand Down Expand Up @@ -80,6 +88,10 @@ class BlockController extends AbstractController
*/
protected $deviceTypeRepository;

/**
* @Route("/{_admin}/content/block", name="admin_content_block")
* @Template("Content/block.twig")
*/
public function index(Application $app, Request $request)
{
$DeviceType = $this->deviceTypeRepository
Expand All @@ -97,11 +109,16 @@ public function index(Application $app, Request $request)
);
$this->eventDispatcher->dispatch(EccubeEvents::ADMIN_CONTENT_BLOCK_INDEX_COMPLETE, $event);

return $app->render('Content/block.twig', array(
return [
'Blocks' => $Blocks,
));
];
}

/**
* @Route("/{_admin}/content/block/new", name="admin_content_block_new")
* @Route("/{_admin}/content/block/{id}/edit", requirements={"id" = "\d+"}, name="admin_content_block_edit")
* @Template("Content/block_edit.twig")
*/
public function edit(Application $app, Request $request, $id = null)
{
$DeviceType = $this->deviceTypeRepository
Expand Down Expand Up @@ -197,6 +214,10 @@ public function edit(Application $app, Request $request, $id = null)
));
}

/**
* @Method("DELETE")
* @Route("/{_admin}/content/news/{id}/delete", requirements={"id" = "\d+"}, name="admin_content_block_delete")
*/
public function delete(Application $app, Request $request, $id)
{
$this->isTokenValid($app);
Expand Down
16 changes: 13 additions & 3 deletions src/Eccube/Controller/Admin/Content/CacheController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,21 @@

use Doctrine\ORM\EntityManager;
use Eccube\Annotation\Inject;
use Eccube\Annotation\Component;
use Eccube\Application;
use Eccube\Controller\AbstractController;
use Eccube\Form\Type\Admin\CacheType;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\HttpFoundation\Request;

/**
* @Component
* @Route(service=CacheController::class)
*/
class CacheController extends AbstractController
{
/**
Expand All @@ -54,7 +61,10 @@ class CacheController extends AbstractController
*/
protected $formFactory;


/**
* @Route("/{_admin}/content/cache", name="admin_content_cache")
* @Template("Content/cache.twig")
*/
public function index(Application $app, Request $request)
{

Expand Down Expand Up @@ -91,9 +101,9 @@ public function index(Application $app, Request $request)
$app->addSuccess('admin.content.cache.save.complete', 'admin');
}

return $app->render('Content/cache.twig', array(
return [
'form' => $form->createView(),
));
];
}

protected function deleteDoctrineCache(\Doctrine\Common\Cache\Cache $cacheDriver)
Expand Down
47 changes: 33 additions & 14 deletions src/Eccube/Controller/Admin/Content/LayoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,28 @@
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\NoResultException;
use Eccube\Annotation\Inject;
use Eccube\Annotation\Component;
use Eccube\Application;
use Eccube\Controller\AbstractController;
use Eccube\Entity\BlockPosition;
use Eccube\Entity\Layout;
use Eccube\Form\Type\Master\DeviceTypeType;
use Eccube\Repository\BlockRepository;
use Eccube\Repository\LayoutRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Validator\Constraints\NotBlank;

// todo プレビュー実装
/**
* @Component
* @Route(service=LayoutController::class)
*/
class LayoutController extends AbstractController
{
/**
Expand All @@ -61,18 +69,23 @@ class LayoutController extends AbstractController
*/
protected $layoutRepository;

/**
* @Route("/{_admin}/content/layout", name="admin_content_layout")
* @Template("Content/layout_list.twig")
*/
public function index(Application $app, Request $request)
{
$Layouts = $this->layoutRepository->findBy([], ['id' => 'DESC']);

return $app->render(
'Content/layout_list.twig',
[
'Layouts' => $Layouts,
]
);
return [
'Layouts' => $Layouts,
];
}

/**
* @Method("DELETE")
* @Route("/{_admin}/content/layout/{id}/delete", requirements={"id" = "\d+"}, name="admin_content_layout_delete")
*/
public function delete(Application $app, Request $request, $id)
{
$this->isTokenValid($app);
Expand All @@ -93,6 +106,11 @@ public function delete(Application $app, Request $request, $id)
return $app->redirect($app->url('admin_content_layout'));
}

/**
* @Route("/{_admin}/content/layout/new", name="admin_content_layout_new")
* @Route("/{_admin}/content/layout/{id}/edit", requirements={"id" = "\d+"}, name="admin_content_layout_edit")
* @Template("Content/layout.twig")
*/
public function edit(Application $app, Request $request, $id = null)
{
if (is_null($id)) {
Expand Down Expand Up @@ -201,16 +219,17 @@ public function edit(Application $app, Request $request, $id = null)
return $app->redirect($app->url('admin_content_layout_edit', array('id' => $Layout->getId())));
}

return $app->render(
'Content/layout.twig',
array(
'form' => $form->createView(),
'Layout' => $Layout,
'UnusedBlocks' => $UnusedBlocks,
)
);
return [
'form' => $form->createView(),
'Layout' => $Layout,
'UnusedBlocks' => $UnusedBlocks,
];
}

/**
* @Method("POST")
* @Route("/{_admin}/content/layout/view_block", name="admin_content_layout_view_block")
*/
public function viewBlock(Application $app, Request $request)
{
if (!$request->isXmlHttpRequest()) {
Expand Down
25 changes: 23 additions & 2 deletions src/Eccube/Controller/Admin/Content/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use Doctrine\ORM\EntityManager;
use Eccube\Annotation\Inject;
use Eccube\Annotation\Component;
use Eccube\Application;
use Eccube\Controller\AbstractController;
use Eccube\Entity\Master\DeviceType;
Expand All @@ -37,12 +38,19 @@
use Eccube\Repository\Master\DeviceTypeRepository;
use Eccube\Repository\PageLayoutRepository;
use Eccube\Util\Str;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\HttpFoundation\Request;

/**
* @Component
* @Route(service=PageController::class)
*/
class PageController extends AbstractController
{
/**
Expand Down Expand Up @@ -81,6 +89,10 @@ class PageController extends AbstractController
*/
protected $deviceTypeRepository;

/**
* @Route("/{_admin}/content/page", name="admin_content_page")
* @Template("Content/page.twig")
*/
public function index(Application $app, Request $request)
{
$DeviceType = $this->deviceTypeRepository
Expand All @@ -102,6 +114,11 @@ public function index(Application $app, Request $request)
));
}

/**
* @Route("/{_admin}/content/page/new", name="admin_content_page_new")
* @Route("/{_admin}/content/page/{id}/edit", requirements={"id" = "\d+"}, name="admin_content_page_edit")
* @Template("Content/page_edit.twig")
*/
public function edit(Application $app, Request $request, $id = null)
{
$DeviceType = $this->deviceTypeRepository
Expand Down Expand Up @@ -229,14 +246,18 @@ public function edit(Application $app, Request $request, $id = null)

$templatePath = $this->pageLayoutRepository->getWriteTemplatePath($editable);

return $app->render('Content/page_edit.twig', array(
return [
'form' => $form->createView(),
'page_id' => $PageLayout->getId(),
'editable' => $editable,
'template_path' => $templatePath,
));
];
}

/**
* @Method("DELETE")
* @Route("/{_admin}/content/page/{id}/delete", requirements={"id" = "\d+"}, name="admin_content_page_delete")
*/
public function delete(Application $app, Request $request, $id = null)
{
$this->isTokenValid($app);
Expand Down
20 changes: 0 additions & 20 deletions src/Eccube/ControllerProvider/AdminControllerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,6 @@ public function connect(Application $app)
$c->requireHttps();
}

// content
$c->match('/content/layout', '\Eccube\Controller\Admin\Content\LayoutController::index')->bind('admin_content_layout');
$c->match('/content/layout/new', '\Eccube\Controller\Admin\Content\LayoutController::edit')->bind('admin_content_layout_new');
$c->match('/content/layout/{id}/edit', '\Eccube\Controller\Admin\Content\LayoutController::edit')->assert('id', '\d+')->bind('admin_content_layout_edit');
$c->match('/content/layout/{id}/preview', '\Eccube\Controller\Admin\Content\LayoutController::preview')->assert('id', '\d+')->bind('admin_content_layout_preview');
$c->delete('/content/layout/{id}/delete', '\Eccube\Controller\Admin\Content\LayoutController::delete')->assert('id', '\d+')->bind('admin_content_layout_delete');
$c->post('/content/layout/view_block', '\Eccube\Controller\Admin\Content\LayoutController::viewBlock')->bind('admin_content_layout_view_block');

$c->match('/content/block', '\Eccube\Controller\Admin\Content\BlockController::index')->bind('admin_content_block');
$c->match('/content/block/new', '\Eccube\Controller\Admin\Content\BlockController::edit')->bind('admin_content_block_new');
$c->match('/content/block/{id}/edit', '\Eccube\Controller\Admin\Content\BlockController::edit')->assert('id', '\d+')->bind('admin_content_block_edit');
$c->delete('/content/block/{id}/delete', '\Eccube\Controller\Admin\Content\BlockController::delete')->assert('id', '\d+')->bind('admin_content_block_delete');

$c->match('/content/page', '\Eccube\Controller\Admin\Content\PageController::index')->bind('admin_content_page');
$c->match('/content/page/new', '\Eccube\Controller\Admin\Content\PageController::edit')->bind('admin_content_page_new');
$c->match('/content/page/{id}/edit', '\Eccube\Controller\Admin\Content\PageController::edit')->assert('id', '\d+')->bind('admin_content_page_edit');
$c->delete('/content/page/{id}/delete', '\Eccube\Controller\Admin\Content\PageController::delete')->assert('id', '\d+')->bind('admin_content_page_delete');

$c->match('/content/cache', '\Eccube\Controller\Admin\Content\CacheController::index')->bind('admin_content_cache');

// shop
// $c->match('/setting/shop', '\Eccube\Controller\Admin\Setting\Shop\ShopController::index')->bind('admin_setting_shop');

Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Resource/template/admin/Content/page_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
{{ form_label(form.url) }}
<div class="col-sm-9 col-lg-10 form-inline">
{% if editable %}
{{ url('top') }}{{ app.config.user_data_route }}/{{ form_widget(form.url) }}
{{ url('homepage') }}{{ app.config.user_data_route }}/{{ form_widget(form.url) }}
{% else %}
{{ app.request_stack.currentrequest.schemeAndHttpHost }}{{ app.request_stack.currentrequest.basePath }}{{ app.routes.get(form.url.vars.value).path }}
{{ form_widget(form.url, { type : 'hidden' } ) }}
Expand Down

0 comments on commit c3ca858

Please sign in to comment.