Skip to content

Commit 1e28870

Browse files
committed
Merge pull request #52 from symfony-cmf/bundle_standards
Bundle standards
2 parents aa08d1b + 282002e commit 1e28870

File tree

21 files changed

+269
-47
lines changed

21 files changed

+269
-47
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Tests/Resources/app/cache
2+
Tests/Resources/app/logs
3+
composer.lock
4+
vendor

.travis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
language: php
2+
3+
php:
4+
- 5.3
5+
- 5.4
6+
- 5.5
7+
8+
env:
9+
- SYMFONY_VERSION=2.2.*
10+
- SYMFONY_VERSION=2.3.*
11+
12+
before_script:
13+
- composer require symfony/framework-bundle:${SYMFONY_VERSION}
14+
- vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh
15+
16+
script: phpunit --coverage-text
17+
18+
notifications:
19+
irc: "irc.freenode.org#symfony-cmf"
20+

Admin/PageAdmin.php

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class PageAdmin extends Admin
1616
{
1717
protected $translationDomain = 'CmfSimpleCmsBundle';
1818

19+
protected $baseRouteName = 'cmf_simplecms_page';
20+
protected $baseRoutePattern = '/cmf/simplecms/page';
21+
1922
private $sortOrder = false;
2023

2124
public function setSortOrder($sortOrder)
@@ -51,41 +54,10 @@ protected function configureFormFields(FormMapper $formMapper)
5154
->add('label', null, array('required' => false))
5255
->add('title')
5356
->add('createDate')
54-
->add('publishStartDate', null, array('required' => false))
55-
->add('publishEndDate', null, array('required' => false))
5657
->add('body', 'textarea')
5758
;
5859
}
5960

60-
protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
61-
{
62-
if (!in_array($action, array('edit', 'create'))) {
63-
return;
64-
}
65-
66-
$menu->addChild(
67-
$this->trans('sidemenu.publish_start_end_date')
68-
);
69-
70-
$menu->addChild(
71-
$this->trans('sidemenu.end_date_disable')
72-
);
73-
74-
if ('edit' == $action) {
75-
$page = $this->getSubject();
76-
$uri = $this->routeGenerator->generate($page);
77-
if ($page instanceof MultilangPage) {
78-
$uri.= '#'.$page->getTitle();
79-
}
80-
81-
$menu->addChild(
82-
$this->trans('sidemenu.review'),
83-
array('uri' => $uri)
84-
);
85-
}
86-
87-
}
88-
8961
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
9062
{
9163
$datagridMapper

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Changelog
22
=========
33

4+
* **2013-08-04**: Changed name of Sonata route names / patterns - now /admin/cmf/simplecms/foo instead of /admin/bundle/simplecms/foo
5+
46
1.0.0-beta3
57
-----------
68

DependencyInjection/CmfSimpleCmsExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function load(array $configs, ContainerBuilder $container)
3737
$container->setParameter($this->getAlias() . '.menu_basepath', PathHelper::getParentPath($config['basepath']));
3838
$container->setParameter($this->getAlias() . '.uri_filter_regexp', $config['routing']['uri_filter_regexp']);
3939

40-
$loader->load('services/routing.xml');
41-
$loader->load('services/migrator.xml');
40+
$loader->load('routing.xml');
41+
$loader->load('migrator.xml');
4242

4343
$dynamic = $container->getDefinition($this->getAlias().'.dynamic_router');
4444

@@ -113,7 +113,7 @@ protected function loadMenu($config, XmlFileLoader $loader, ContainerBuilder $co
113113
return;
114114
}
115115

116-
$loader->load('services/menu.xml');
116+
$loader->load('menu.xml');
117117
}
118118

119119
protected function loadSonataAdmin($config, XmlFileLoader $loader, ContainerBuilder $container)
@@ -129,7 +129,7 @@ protected function loadSonataAdmin($config, XmlFileLoader $loader, ContainerBuil
129129
: false
130130
);
131131

132-
$loader->load('services/admin.xml');
132+
$loader->load('admin.xml');
133133
}
134134

135135
/**

DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function getConfigTreeBuilder()
3838
->fixXmlConfig('controller_by_alias', 'controllers_by_alias')
3939
->fixXmlConfig('controller_by_class', 'controllers_by_class')
4040
->fixXmlConfig('template_by_class', 'templates_by_class')
41+
->addDefaultsIfNotSet()
4142
->children()
4243
->scalarNode('content_repository_id')->defaultValue('cmf_routing.content_repository')->end()
4344
->scalarNode('uri_filter_regexp')->defaultValue('')->end()

Migrator/Page.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
use Doctrine\Bundle\PHPCRBundle\Migrator\MigratorInterface;
1414
use Doctrine\ODM\PHPCR\DocumentManager;
1515

16+
/**
17+
* Doctrine migrator for pages
18+
*
19+
* Provides a way of creating and maintaining pages from YAML files.
20+
*/
1621
class Page implements MigratorInterface
1722
{
1823
/**
@@ -131,4 +136,4 @@ public function migrate($path = '/', $depth = -1)
131136

132137
return 0;
133138
}
134-
}
139+
}

README.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
1-
# Symfony Cmf Simple CMS Bundle
1+
# Symfony CMF SimpleCms Bundle
2+
3+
[![Build Status](https://secure.travis-ci.org/symfony-cmf/SimpleCmsBundle.png)](http://travis-ci.org/symfony-cmf/SimpleCmsBundle)
4+
[![Latest Stable Version](https://poser.pugx.org/symfony-cmf/simple-cms-bundle/version.png)](https://packagist.org/packages/symfony-cmf/simple-cms-bundle)
5+
[![Total Downloads](https://poser.pugx.org/symfony-cmf/simple-cms-bundle/d/total.png)](https://packagist.org/packages/symfony-cmf/simple-cms-bundle)
6+
7+
This bundle is part of the [Symfony Content Management Framework (CMF)](http://cmf.symfony.com/)
8+
and licensed under the [MIT License](LICENSE).
29

310
A trivial content management system based on the [Symfony Cmf](https://github.com/symfony-cmf/symfony-cmf)
411

5-
## Links
12+
## Requirements
613

7-
- GitHub: <https://github.com/symfony-cmf/symfony-cmf>
8-
- Sandbox: <https://github.com/symfony-cmf/cmf-sandbox>
9-
- Web: <http://cmf.symfony.com/>
10-
- Uncyclo: <http://github.com/symfony-cmf/symfony-cmf/wiki>
11-
- Issue Tracker: <http://cmf.symfony-project.org/redmine/>
12-
- IRC: irc://freenode/#symfony-cmf
13-
- Users mailing list: <http://groups.google.com/group/symfony-cmf-users>
14-
- Devs mailing list: <http://groups.google.com/group/symfony-cmf-devs>
14+
* Symfony 2.2.x
15+
* See also the `require` section of [composer.json](composer.json)
1516

1617
## Documentation
1718

18-
http://symfony.com/doc/master/cmf/getting_started/simplecms.html
19+
For the install guide and reference, see:
20+
21+
* [SimpleCmsBundle documentation](http://symfony.com/doc/master/cmf/bundles/simple-cms-bundle.html)
22+
23+
See also:
24+
25+
* [All Symfony CMF documentation](http://symfony.com/doc/master/cmf/index.html)- complete Symfony CMF reference
26+
* [Symfony CMF Website](http://cmf.symfony.com/) - introduction, live demo, support and community links
27+
28+
29+
## Contributing
30+
31+
Pull requests are welcome. Please see our
32+
[CONTRIBUTING](https://github.com/symfony-cmf/SimpleCmsBundle/blob/master/CONTRIBUTING.md)
33+
guide.
34+
35+
Unit and/or functional tests exist for this bundle. See the
36+
[Testing documentation](http://symfony.com/doc/master/cmf/components/testing.html)
37+
for a guide to running the tests.
38+
39+
Thanks to
40+
[everyone who has contributed](https://github.com/symfony-cmf/SimpleCmsBundle/contributors) already.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace Symfony\Cmf\Bundle\SimpleCmsBundle\Tests\Resources\DataFixtures\Phpcr;
4+
5+
use Doctrine\Common\DataFixtures\FixtureInterface;
6+
use Doctrine\Common\Persistence\ObjectManager;
7+
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
8+
use Doctrine\ODM\PHPCR\Document\Generic;
9+
use Symfony\Cmf\Bundle\SimpleCmsBundle\Document\Page;
10+
11+
class LoadPageData implements FixtureInterface, DependentFixtureInterface
12+
{
13+
public function getDependencies()
14+
{
15+
return array(
16+
'Symfony\Cmf\Component\Testing\DataFixtures\PHPCR\LoadBaseData',
17+
);
18+
}
19+
20+
public function load(ObjectManager $manager)
21+
{
22+
$root = $manager->find(null, '/test');
23+
$base = new Generic;
24+
$base->setNodename('page');
25+
$base->setParent($root);
26+
$manager->persist($base);
27+
28+
$page = new Page;
29+
$page->setName('homepage');
30+
$page->setTitle('Homepage');
31+
$page->setLabel('homepage');
32+
$page->setPublishable(true);
33+
$page->setParent($base);
34+
35+
$manager->persist($page);
36+
37+
$manager->flush();
38+
}
39+
}

Tests/Resources/app/AppKernel.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Symfony\Cmf\Component\Testing\HttpKernel\TestKernel;
4+
use Symfony\Component\Config\Loader\LoaderInterface;
5+
6+
class AppKernel extends TestKernel
7+
{
8+
public function configure()
9+
{
10+
$this->requireBundleSets(array(
11+
'default',
12+
'phpcr_odm',
13+
'sonata_admin',
14+
));
15+
16+
$this->addBundles(array(
17+
new \Symfony\Cmf\Bundle\SimpleCmsBundle\CmfSimpleCmsBundle(),
18+
new \Symfony\Cmf\Bundle\MenuBundle\CmfMenuBundle(),
19+
new \Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
20+
new \Symfony\Cmf\Bundle\CoreBundle\CmfCoreBundle(),
21+
));
22+
}
23+
24+
public function registerContainerConfiguration(LoaderInterface $loader)
25+
{
26+
$loader->load(__DIR__.'/config/config.php');
27+
}
28+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services">
3+
4+
<config xmlns="http://cmf.symfony.com/schema/dic/simplecms"
5+
basepath="/test/page"
6+
>
7+
</config>
8+
9+
</container>
10+

Tests/Resources/app/config/config.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
$loader->import(CMF_TEST_CONFIG_DIR.'/default.php');
4+
$loader->import(CMF_TEST_CONFIG_DIR.'/phpcr_odm.php');
5+
$loader->import(CMF_TEST_CONFIG_DIR.'/sonata_admin.php');
6+
$loader->import(__DIR__.'/cmf_simple_cms.xml');
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
use Symfony\Component\Routing\RouteCollection;
4+
5+
$collection = new RouteCollection();
6+
$collection->addCollection(
7+
$loader->import(CMF_TEST_CONFIG_DIR.'/routing/sonata_routing.yml')
8+
);
9+
//$collection->addCollection(
10+
// $loader->import(__DIR__.'/routing/my_test_routing.yml')
11+
//);
12+
13+
return $collection;

Tests/WebTest/Admin/PageAdminTest.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
namespace Symfony\Cmf\Bundle\SimpleCmsBundle\Tests\WebTest\Admin;
4+
5+
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
6+
7+
class PageAdminTest extends BaseTestCase
8+
{
9+
public function setUp()
10+
{
11+
$this->db('PHPCR')->loadFixtures(array(
12+
'Symfony\Cmf\Bundle\SimpleCmsBundle\Tests\Resources\DataFixtures\Phpcr\LoadPageData',
13+
));
14+
$this->client = $this->createClient();
15+
}
16+
17+
public function testPageList()
18+
{
19+
$crawler = $this->client->request('GET', '/admin/cmf/simplecms/page/list');
20+
$res = $this->client->getResponse();
21+
$this->assertEquals(200, $res->getStatusCode());
22+
$this->assertCount(1, $crawler->filter('html:contains("homepage")'));
23+
}
24+
25+
public function testPageEdit()
26+
{
27+
$crawler = $this->client->request('GET', '/admin/cmf/simplecms/page/test/pages/homepage/edit');
28+
$res = $this->client->getResponse();
29+
$this->assertEquals(200, $res->getStatusCode());
30+
$this->assertCount(1, $crawler->filter('input[value="homepage"]'));
31+
}
32+
33+
public function testPageShow()
34+
{
35+
return;
36+
$crawler = $this->client->request('GET', '/admin/cmf/simplecms/page/test/pages/homepage/show');
37+
$res = $this->client->getResponse();
38+
$this->assertEquals(200, $res->getStatusCode());
39+
$this->assertCount(2, $crawler->filter('td:contains("test-page")'));
40+
}
41+
42+
public function testPageCreate()
43+
{
44+
$crawler = $this->client->request('GET', '/admin/cmf/simplecms/page/create');
45+
$res = $this->client->getResponse();
46+
$this->assertEquals(200, $res->getStatusCode());
47+
48+
$button = $crawler->selectButton('Create');
49+
$form = $button->form();
50+
$node = $form->getFormNode();
51+
$actionUrl = $node->getAttribute('action');
52+
$uniqId = substr(strchr($actionUrl, '='), 1);
53+
54+
$form[$uniqId.'[parent]'] = '/test/pages';
55+
$form[$uniqId.'[title]'] = 'foo-page';
56+
$form[$uniqId.'[label]'] = 'Foo Page';
57+
58+
$this->client->submit($form);
59+
$res = $this->client->getResponse();
60+
61+
// If we have a 302 redirect, then all is well
62+
$this->assertEquals(302, $res->getStatusCode());
63+
}
64+
}

composer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@
1717
"symfony/framework-bundle": "~2.2",
1818
"symfony-cmf/core-bundle": "~1.0.0-RC1",
1919
"symfony-cmf/routing-bundle": "~1.1.0-RC1",
20+
"symfony-cmf/menu-bundle": "~1.0.0-RC1",
2021
"symfony-cmf/content-bundle": "~1.0.0-RC1",
22+
"symfony-cmf/core-bundle": "~1.0.0-RC1",
2123
"doctrine/phpcr-bundle": "1.0.*",
2224
"doctrine/phpcr-odm": "1.0.*"
2325
},
26+
"require-dev": {
27+
"symfony-cmf/testing": "1.0.*",
28+
"sonata-project/doctrine-phpcr-admin-bundle": "1.0.*",
29+
"symfony/monolog-bundle": "2.2.*"
30+
},
2431
"suggest": {
2532
"symfony-cmf/create-bundle": "1.0.*",
2633
"symfony-cmf/menu-bundle": "~1.0.0-RC1",

0 commit comments

Comments
 (0)