Skip to content

Commit

Permalink
First approach to build layout page editor
Browse files Browse the repository at this point in the history
  • Loading branch information
adampiotrowski committed Mar 26, 2014
1 parent 98c835d commit fc6ccfe
Show file tree
Hide file tree
Showing 17 changed files with 719 additions and 40 deletions.
90 changes: 87 additions & 3 deletions application/Gekosale/Core/ServiceContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,18 @@ public function __construct()
'finder' => 'getFinderService',
'form_helper' => 'getFormHelperService',
'helper' => 'getHelperService',
'home_page.subscriber' => 'getHomePage_SubscriberService',
'image_gallery' => 'getImageGalleryService',
'kernel' => 'getKernelService',
'language.datagrid' => 'getLanguage_DatagridService',
'language.form' => 'getLanguage_FormService',
'language.repository' => 'getLanguage_RepositoryService',
'language.subscriber' => 'getLanguage_SubscriberService',
'layout_manager' => 'getLayoutManagerService',
'layout_page.form' => 'getLayoutPage_FormService',
'layout_page.repository' => 'getLayoutPage_RepositoryService',
'layout_page.subscriber' => 'getLayoutPage_SubscriberService',
'layout_page.tree' => 'getLayoutPage_TreeService',
'layout_theme.datagrid' => 'getLayoutTheme_DatagridService',
'layout_theme.form' => 'getLayoutTheme_FormService',
'layout_theme.repository' => 'getLayoutTheme_RepositoryService',
Expand Down Expand Up @@ -922,8 +927,10 @@ protected function getEventDispatcherService()
$instance->addSubscriberService('currency.subscriber', 'Gekosale\\Plugin\\Currency\\Event\\CurrencyEventSubscriber');
$instance->addSubscriberService('dashboard.subscriber', 'Gekosale\\Plugin\\Dashboard\\Event\\DashboardEventSubscriber');
$instance->addSubscriberService('deliverer.subscriber', 'Gekosale\\Plugin\\Deliverer\\Event\\DelivererEventSubscriber');
$instance->addSubscriberService('home_page.subscriber', 'Gekosale\\Plugin\\HomePage\\Event\\HomePageEventSubscriber');
$instance->addSubscriberService('language.subscriber', 'Gekosale\\Plugin\\Language\\Event\\LanguageEventSubscriber');
$instance->addSubscriberService('layout_theme.subscriber', 'Gekosale\\Plugin\\Layout\\Event\\LayoutThemeEventSubscriber');
$instance->addSubscriberService('layout_theme.subscriber', 'Gekosale\\Plugin\\Layout\\Event\\LayoutPageEventSubscriber');
$instance->addSubscriberService('layout_page.subscriber', 'Gekosale\\Plugin\\Layout\\Event\\LayoutPageEventSubscriber');
$instance->addSubscriberService('payment_method.subscriber', 'Gekosale\\Plugin\\PaymentMethod\\Event\\PaymentMethodEventSubscriber');
$instance->addSubscriberService('paypal.subscriber', 'Gekosale\\Plugin\\PayPal\\Event\\PayPalEventSubscriber');
$instance->addSubscriberService('plugin_manager.subscriber', 'Gekosale\\Plugin\\PluginManager\\Event\\PluginManagerEventSubscriber');
Expand Down Expand Up @@ -1032,6 +1039,19 @@ protected function getHelperService()
return $instance;
}

/**
* Gets the 'home_page.subscriber' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* @return Gekosale\Plugin\HomePage\Event\HomePageEventSubscriber A Gekosale\Plugin\HomePage\Event\HomePageEventSubscriber instance.
*/
protected function getHomePage_SubscriberService()
{
return $this->services['home_page.subscriber'] = new \Gekosale\Plugin\HomePage\Event\HomePageEventSubscriber();
}

/**
* Gets the 'image_gallery' service.
*
Expand Down Expand Up @@ -1146,6 +1166,70 @@ protected function getLayoutManagerService()
return $instance;
}

/**
* Gets the 'layout_page.form' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* @return Gekosale\Plugin\Layout\Form\LayoutPageForm A Gekosale\Plugin\Layout\Form\LayoutPageForm instance.
*/
protected function getLayoutPage_FormService()
{
$this->services['layout_page.form'] = $instance = new \Gekosale\Plugin\Layout\Form\LayoutPageForm();

$instance->setContainer($this);

return $instance;
}

/**
* Gets the 'layout_page.repository' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* @return Gekosale\Plugin\Layout\Repository\LayoutPageRepository A Gekosale\Plugin\Layout\Repository\LayoutPageRepository instance.
*/
protected function getLayoutPage_RepositoryService()
{
$this->services['layout_page.repository'] = $instance = new \Gekosale\Plugin\Layout\Repository\LayoutPageRepository();

$instance->setContainer($this);

return $instance;
}

/**
* Gets the 'layout_page.subscriber' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* @return Gekosale\Plugin\Layout\Event\LayoutPageEventSubscriber A Gekosale\Plugin\Layout\Event\LayoutPageEventSubscriber instance.
*/
protected function getLayoutPage_SubscriberService()
{
return $this->services['layout_page.subscriber'] = new \Gekosale\Plugin\Layout\Event\LayoutPageEventSubscriber();
}

/**
* Gets the 'layout_page.tree' service.
*
* This service is shared.
* This method always returns the same instance of the service.
*
* @return Gekosale\Plugin\Layout\Form\LayoutPageTree A Gekosale\Plugin\Layout\Form\LayoutPageTree instance.
*/
protected function getLayoutPage_TreeService()
{
$this->services['layout_page.tree'] = $instance = new \Gekosale\Plugin\Layout\Form\LayoutPageTree();

$instance->setContainer($this);

return $instance;
}

/**
* Gets the 'layout_theme.datagrid' service.
*
Expand Down Expand Up @@ -1204,11 +1288,11 @@ protected function getLayoutTheme_RepositoryService()
* This service is shared.
* This method always returns the same instance of the service.
*
* @return Gekosale\Plugin\Layout\Event\LayoutThemeEventSubscriber A Gekosale\Plugin\Layout\Event\LayoutThemeEventSubscriber instance.
* @return Gekosale\Plugin\Layout\Event\LayoutPageEventSubscriber A Gekosale\Plugin\Layout\Event\LayoutPageEventSubscriber instance.
*/
protected function getLayoutTheme_SubscriberService()
{
return $this->services['layout_theme.subscriber'] = new \Gekosale\Plugin\Layout\Event\LayoutThemeEventSubscriber();
return $this->services['layout_theme.subscriber'] = new \Gekosale\Plugin\Layout\Event\LayoutPageEventSubscriber();
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/*
* Gekosale Open-Source E-Commerce Platform
*
* This file is part of the Gekosale package.
*
* (c) Adam Piotrowski <adam@gekosale.com>
*
* For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code.
*/
namespace Gekosale\Plugin\HomePage\Event;

use Gekosale\Plugin\Layout\Event\LayoutPageFormEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\GenericEvent;

/**
* Class HomePageEventSubscriber
*
* @package Gekosale\Plugin\HomePage\Event
* @author Adam Piotrowski <adam@gekosale.com>
*/
class HomePageEventSubscriber implements EventSubscriberInterface
{

public function onLayoutPageTreeInitAction(GenericEvent $event)
{
$event->setArgument('home_page', 'Home Page');
}

public static function getSubscribedEvents()
{
return array(
LayoutPageFormEvent::TREE_INIT_EVENT => 'onLayoutPageTreeInitAction'
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/*
* Gekosale Open-Source E-Commerce Platform
*
* This file is part of the Gekosale package.
*
* (c) Adam Piotrowski <adam@gekosale.com>
*
* For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code.
*/
namespace Gekosale\Plugin\HomePage\Extension;

use Symfony\Component\HttpKernel\DependencyInjection\Extension,
Symfony\Component\DependencyInjection\Loader\XmlFileLoader,
Symfony\Component\Config\FileLocator,
Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* Class HomePageExtension
*
* @package Gekosale\Plugin\HomePage\Extension
* @author Adam Piotrowski <adam@gekosale.com>
*/
class HomePageExtension extends Extension
{

public function load(array $config, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../config'));
$loader->load('services.xml');
}

public function getNamespace()
{
return 'http://symfony.com/schema/dic/services';
}

public function getAlias()
{
return 'gekosale.plugin.home_page';
}
}
11 changes: 11 additions & 0 deletions application/Gekosale/Plugin/HomePage/config/services.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service id="home_page.subscriber" class="Gekosale\Plugin\HomePage\Event\HomePageEventSubscriber">
<tag name="kernel.event_subscriber" />
</service>
</services>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/*
* Gekosale Open-Source E-Commerce Platform
*
* This file is part of the Gekosale package.
*
* (c) Adam Piotrowski <adam@gekosale.com>
*
* For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code.
*/
namespace Gekosale\Plugin\Layout\Controller\Admin;

use Gekosale\Core\Controller\AdminController;

/**
* Class LayoutPageController
*
* @package Gekosale\Plugin\LayoutPage\Controller\Admin
* @author Adam Piotrowski <adam@gekosale.com>
*/
class LayoutPageController extends AdminController
{
public function indexAction()
{
$tree = $this->getTree()->init();

return Array(
'tree' => $tree
);
}

public function editAction($id)
{
$tree = $this->getTree()->init();

return Array(
'tree' => $tree
);
}

/**
* Get Tree
*/
protected function getTree()
{
return $this->get('layout_page.tree');
}

/**
* {@inheritdoc}
*/
protected function getRepository()
{
return $this->get('layout_page.repository');
}

/**
* {@inheritdoc}
*/
protected function getForm()
{
return $this->get('layout_page.form');
}

/**
* {@inheritdoc}
*/
protected function getDefaultRoute()
{
return 'admin.layout_page.index';
}
}
Loading

0 comments on commit fc6ccfe

Please sign in to comment.