Skip to content
This repository was archived by the owner on Aug 8, 2021. It is now read-only.

Commit b943c12

Browse files
committed
Initial Commit
1 parent 4fbcc5a commit b943c12

24 files changed

Lines changed: 1412 additions & 672 deletions

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Composer
2+
/composer.lock
3+
/vendor
4+
5+
# PHPUnit
6+
/build
7+
/phpunit.xml

Admin/MenuAdmin.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace Devtronic\CmsBundle\Admin;
4+
5+
use Sonata\AdminBundle\Admin\Admin;
6+
use Sonata\AdminBundle\Datagrid\DatagridMapper;
7+
use Sonata\AdminBundle\Datagrid\ListMapper;
8+
use Sonata\AdminBundle\Form\FormMapper;
9+
10+
class MenuAdmin extends Admin
11+
{
12+
13+
14+
// Fields to be shown on create/edit forms
15+
protected function configureFormFields(FormMapper $formMapper)
16+
{
17+
$formMapper
18+
->add('name', null, array(
19+
'label' => 'label.cms.admin.menu_name',
20+
))
21+
->add('slug', null, array(
22+
'label' => 'label.cms.admin.menu_slug',
23+
))
24+
;
25+
}
26+
27+
// Fields to be shown on filter forms
28+
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
29+
{
30+
}
31+
32+
// Fields to be shown on lists
33+
protected function configureListFields(ListMapper $listMapper)
34+
{
35+
$listMapper
36+
->addIdentifier('name', null, array(
37+
'label' => 'label.cms.admin.menu_name',
38+
))
39+
->add('slug', null, array(
40+
'label' => 'label.cms.admin.menu_slug',
41+
));
42+
}
43+
44+
}

Admin/MenuItemAdmin.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
3+
namespace Devtronic\CmsBundle\Admin;
4+
5+
use Devtronic\CmsBundle\Form\MenuItemTargetType;
6+
use Sonata\AdminBundle\Admin\Admin;
7+
use Sonata\AdminBundle\Datagrid\DatagridMapper;
8+
use Sonata\AdminBundle\Datagrid\ListMapper;
9+
use Sonata\AdminBundle\Form\FormMapper;
10+
use Sonata\AdminBundle\Show\ShowMapper;
11+
12+
class MenuItemAdmin extends Admin
13+
{
14+
15+
16+
// Fields to be shown on create/edit forms
17+
protected function configureFormFields(FormMapper $formMapper)
18+
{
19+
$formMapper
20+
->with('label.cms.admin.menu_item_generic', array('class' => 'col-md-9'))
21+
->add('title', null, array(
22+
'label' => 'label.cms.admin.menu_item_title',
23+
))
24+
->add('menu', null, array(
25+
'label' => 'label.cms.admin.menu',
26+
))
27+
->add('parentItem', null, array(
28+
'label' => 'label.cms.admin.menu_item_parent',
29+
))
30+
->end()
31+
->with('label.cms.admin.menu_item_target', array('class' => 'col-md-3'))
32+
->add('type', MenuItemTargetType::class, array(
33+
'label' => 'label.cms.admin.menu_item_type',
34+
))
35+
->add('targetPage', null, array(
36+
'label' => 'label.cms.admin.menu_item_target_page',
37+
))
38+
->add('targetUrl', null, array(
39+
'label' => 'label.cms.admin.menu_item_target_address'
40+
))
41+
->end()
42+
;
43+
}
44+
45+
46+
// Fields to be shown on filter forms
47+
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
48+
{
49+
$datagridMapper->add('type', null, array(
50+
'label' => 'label.cms.admin.menu_item_type',
51+
), MenuItemTargetType::class)
52+
;
53+
}
54+
55+
// Fields to be shown on lists
56+
protected function configureListFields(ListMapper $listMapper)
57+
{
58+
$listMapper
59+
->addIdentifier('title', null, array(
60+
'label' => 'label.cms.admin.menu_item_title',
61+
))
62+
->add('parentItem', null, array(
63+
'label' => 'label.cms.admin.menu_item_parent',
64+
))
65+
->add('menu', null, array(
66+
'label' => 'label.cms.admin.menu',
67+
))
68+
;
69+
}
70+
71+
}

Admin/PageAdmin.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Devtronic\CmsBundle\Admin;
4+
5+
use Ivory\CKEditorBundle\Form\Type\CKEditorType;
6+
use Sonata\AdminBundle\Admin\Admin;
7+
use Sonata\AdminBundle\Datagrid\DatagridMapper;
8+
use Sonata\AdminBundle\Datagrid\ListMapper;
9+
use Sonata\AdminBundle\Form\FormMapper;
10+
11+
class PageAdmin extends Admin
12+
{
13+
14+
15+
// Fields to be shown on create/edit forms
16+
protected function configureFormFields(FormMapper $formMapper)
17+
{
18+
$formMapper
19+
->add('title', null, array(
20+
'label' => 'label.cms.admin.page_title',
21+
))
22+
->add('slug', null, array(
23+
'label' => 'label.cms.admin.page_slug',
24+
))
25+
->add('content', CKEditorType::class, array(
26+
))
27+
->add('isPublic', null, array(
28+
'label' => 'label.cms.admin.page_is_public',
29+
))
30+
;
31+
}
32+
33+
// Fields to be shown on filter forms
34+
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
35+
{
36+
$datagridMapper->add('title', null, array(
37+
'label' => 'label.cms.admin.page_title',
38+
));
39+
}
40+
41+
// Fields to be shown on lists
42+
protected function configureListFields(ListMapper $listMapper)
43+
{
44+
$listMapper
45+
->addIdentifier('title', null, array(
46+
'label' => 'label.cms.admin.page_title',
47+
))
48+
->add('isPublic', null, array(
49+
'label' => 'label.cms.admin.page_is_public',
50+
))
51+
;
52+
}
53+
}

CmsBundle.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Devtronic\CmsBundle;
4+
5+
use Symfony\Component\HttpKernel\Bundle\Bundle;
6+
7+
class CmsBundle extends Bundle
8+
{
9+
}

Controller/PageController.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Devtronic\CmsBundle\Controller;
4+
5+
use Doctrine\ORM\EntityNotFoundException;
6+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
7+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
10+
11+
class PageController extends Controller
12+
{
13+
/**
14+
* @Route("/{slug}", name="cms_page")
15+
* @Template()
16+
*/
17+
public function pageAction($slug)
18+
{
19+
$em = $this->getDoctrine()->getEntityManager();
20+
$repo = $em->getRepository('CmsBundle:Page');
21+
22+
$page = $repo->findOneBySlug($slug);
23+
24+
25+
26+
return array('page' => $page);
27+
}
28+
29+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Devtronic\CmsBundle\DependencyInjection;
4+
5+
use Symfony\Component\DependencyInjection\ContainerBuilder;
6+
use Symfony\Component\Config\FileLocator;
7+
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
8+
use Symfony\Component\DependencyInjection\Loader;
9+
10+
/**
11+
* This is the class that loads and manages your bundle configuration.
12+
*
13+
* @link http://symfony.com/doc/current/cookbook/bundles/extension.html
14+
*/
15+
class CmsExtension extends Extension
16+
{
17+
/**
18+
* {@inheritdoc}
19+
*/
20+
public function load(array $configs, ContainerBuilder $container)
21+
{
22+
$configuration = new Configuration();
23+
$config = $this->processConfiguration($configuration, $configs);
24+
25+
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
26+
$loader->load('services.yml');
27+
}
28+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Devtronic\CmsBundle\DependencyInjection;
4+
5+
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6+
use Symfony\Component\Config\Definition\ConfigurationInterface;
7+
8+
/**
9+
* This is the class that validates and merges configuration from your app/config files.
10+
*
11+
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
12+
*/
13+
class Configuration implements ConfigurationInterface
14+
{
15+
/**
16+
* {@inheritdoc}
17+
*/
18+
public function getConfigTreeBuilder()
19+
{
20+
$treeBuilder = new TreeBuilder();
21+
$rootNode = $treeBuilder->root('cms');
22+
23+
// Here you should define the parameters that are allowed to
24+
// configure your bundle. See the documentation linked above for
25+
// more information on that topic.
26+
27+
return $treeBuilder;
28+
}
29+
}

0 commit comments

Comments
 (0)