Skip to content

Bundle standards #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Tests/Resources/app/cache
Tests/Resources/app/logs
composer.lock
vendor
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language: php

php:
- 5.3
- 5.4
- 5.5

env:
- SYMFONY_VERSION=2.2.*
- SYMFONY_VERSION=2.3.*

before_script:
- composer require symfony/framework-bundle:${SYMFONY_VERSION}
- vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh

script: phpunit --coverage-text

notifications:
irc: "irc.freenode.org#symfony-cmf"
email: "[email protected]"
34 changes: 3 additions & 31 deletions Admin/PageAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class PageAdmin extends Admin
{
protected $translationDomain = 'CmfSimpleCmsBundle';

protected $baseRouteName = 'cmf_simplecms_page';
protected $baseRoutePattern = '/cmf/simplecms/page';

private $sortOrder = false;

public function setSortOrder($sortOrder)
Expand Down Expand Up @@ -51,41 +54,10 @@ protected function configureFormFields(FormMapper $formMapper)
->add('label', null, array('required' => false))
->add('title')
->add('createDate')
->add('publishStartDate', null, array('required' => false))
->add('publishEndDate', null, array('required' => false))
->add('body', 'textarea')
;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this. Should we keep it? What is the intention of sidemenu.publish_start_end_date and the other one? /cc @lsmith77

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was a quick hack to add a preview link and also give some documentation on the logic behind the publish workflow. the later part should now be moved to the admin extension somehow. the former is something we really should figure out. we could create a form widget that just lists all the pages that are linked to the given content directly or indirectly (ie. f.e. for a block it would find what content is linked to the block and from there figure out the routes).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would be this issue i think:
sonata-project/SonataDoctrinePhpcrAdminBundle#116

i wonder if we really should build that right into sonata, with an
optional dependeny on CmfRoutingBundle or if we could for example
provide an extension for this. but not sure if extensions can add to the
sidebar...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So are we alright to leave this out for now if we have that issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added a link to the changes here in the sonata issue about the preview link.

i don't really understand what the publish workflow thingy was about, if it just was doing documentation. @lsmith77 can you create an issue on the corebundle if we should add something to the publish workflow admin extensions? maybe providing the label and the help text in the form would be enough?

lets merge this PR, the publish workflow things are already displaying broken, so it seems not too important to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
{
if (!in_array($action, array('edit', 'create'))) {
return;
}

$menu->addChild(
$this->trans('sidemenu.publish_start_end_date')
);

$menu->addChild(
$this->trans('sidemenu.end_date_disable')
);

if ('edit' == $action) {
$page = $this->getSubject();
$uri = $this->routeGenerator->generate($page);
if ($page instanceof MultilangPage) {
$uri.= '#'.$page->getTitle();
}

$menu->addChild(
$this->trans('sidemenu.review'),
array('uri' => $uri)
);
}

}

protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Changelog
=========

* **2013-08-04**: Changed name of Sonata route names / patterns - now /admin/cmf/simplecms/foo instead of /admin/bundle/simplecms/foo

1.0.0-beta3
-----------

Expand Down
8 changes: 4 additions & 4 deletions DependencyInjection/CmfSimpleCmsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public function load(array $configs, ContainerBuilder $container)
$container->setParameter($this->getAlias() . '.menu_basepath', PathHelper::getParentPath($config['basepath']));
$container->setParameter($this->getAlias() . '.uri_filter_regexp', $config['routing']['uri_filter_regexp']);

$loader->load('services/routing.xml');
$loader->load('services/migrator.xml');
$loader->load('routing.xml');
$loader->load('migrator.xml');

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

Expand Down Expand Up @@ -113,7 +113,7 @@ protected function loadMenu($config, XmlFileLoader $loader, ContainerBuilder $co
return;
}

$loader->load('services/menu.xml');
$loader->load('menu.xml');
}

protected function loadSonataAdmin($config, XmlFileLoader $loader, ContainerBuilder $container)
Expand All @@ -129,7 +129,7 @@ protected function loadSonataAdmin($config, XmlFileLoader $loader, ContainerBuil
: false
);

$loader->load('services/admin.xml');
$loader->load('admin.xml');
}

/**
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function getConfigTreeBuilder()
->fixXmlConfig('controller_by_alias', 'controllers_by_alias')
->fixXmlConfig('controller_by_class', 'controllers_by_class')
->fixXmlConfig('template_by_class', 'templates_by_class')
->addDefaultsIfNotSet()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want that? its a change in behaviour in case you want to disable something

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the DI extension uses keys from $config['routing']. It crashes if these defaults are not defined - the test uses the most minimal configuration, so this hasn't been noticed before presumably.

Not sure I see why its bad, although I can certainly see a case for tidying up the DI extension, its a bit chaotic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok with your change then.

->children()
->scalarNode('content_repository_id')->defaultValue('cmf_routing.content_repository')->end()
->scalarNode('uri_filter_regexp')->defaultValue('')->end()
Expand Down
7 changes: 6 additions & 1 deletion Migrator/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
use Doctrine\Bundle\PHPCRBundle\Migrator\MigratorInterface;
use Doctrine\ODM\PHPCR\DocumentManager;

/**
* Doctrine migrator for pages
*
* Provides a way of creating and maintaining pages from YAML files.
*/
class Page implements MigratorInterface
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
/**
Expand Down Expand Up @@ -131,4 +136,4 @@ public function migrate($path = '/', $depth = -1)

return 0;
}
}
}
44 changes: 33 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
# Symfony Cmf Simple CMS Bundle
# Symfony CMF SimpleCms Bundle

[![Build Status](https://secure.travis-ci.org/symfony-cmf/SimpleCmsBundle.png)](http://travis-ci.org/symfony-cmf/SimpleCmsBundle)
[![Latest Stable Version](https://poser.pugx.org/symfony-cmf/simple-cms-bundle/version.png)](https://packagist.org/packages/symfony-cmf/simple-cms-bundle)
[![Total Downloads](https://poser.pugx.org/symfony-cmf/simple-cms-bundle/d/total.png)](https://packagist.org/packages/symfony-cmf/simple-cms-bundle)

This bundle is part of the [Symfony Content Management Framework (CMF)](http://cmf.symfony.com/)
and licensed under the [MIT License](LICENSE).

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

## Links
## Requirements

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

## Documentation

http://symfony.com/doc/master/cmf/getting_started/simplecms.html
For the install guide and reference, see:

* [SimpleCmsBundle documentation](http://symfony.com/doc/master/cmf/bundles/simple-cms-bundle.html)

See also:

* [All Symfony CMF documentation](http://symfony.com/doc/master/cmf/index.html)- complete Symfony CMF reference
* [Symfony CMF Website](http://cmf.symfony.com/) - introduction, live demo, support and community links


## Contributing

Pull requests are welcome. Please see our
[CONTRIBUTING](https://github.com/symfony-cmf/SimpleCmsBundle/blob/master/CONTRIBUTING.md)
guide.

Unit and/or functional tests exist for this bundle. See the
[Testing documentation](http://symfony.com/doc/master/cmf/components/testing.html)
for a guide to running the tests.

Thanks to
[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.
File renamed without changes.
39 changes: 39 additions & 0 deletions Tests/Resources/DataFixtures/Phpcr/LoadPageData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Symfony\Cmf\Bundle\SimpleCmsBundle\Tests\Resources\DataFixtures\Phpcr;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\ODM\PHPCR\Document\Generic;
use Symfony\Cmf\Bundle\SimpleCmsBundle\Document\Page;

class LoadPageData implements FixtureInterface, DependentFixtureInterface
{
public function getDependencies()
{
return array(
'Symfony\Cmf\Component\Testing\DataFixtures\PHPCR\LoadBaseData',
);
}

public function load(ObjectManager $manager)
{
$root = $manager->find(null, '/test');
$base = new Generic;
$base->setNodename('page');
$base->setParent($root);
$manager->persist($base);

$page = new Page;
$page->setName('homepage');
$page->setTitle('Homepage');
$page->setLabel('homepage');
$page->setPublishable(true);
$page->setParent($base);

$manager->persist($page);

$manager->flush();
}
}
28 changes: 28 additions & 0 deletions Tests/Resources/app/AppKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Symfony\Cmf\Component\Testing\HttpKernel\TestKernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends TestKernel
{
public function configure()
{
$this->requireBundleSets(array(
'default',
'phpcr_odm',
'sonata_admin',
));

$this->addBundles(array(
new \Symfony\Cmf\Bundle\SimpleCmsBundle\CmfSimpleCmsBundle(),
new \Symfony\Cmf\Bundle\MenuBundle\CmfMenuBundle(),
new \Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
new \Symfony\Cmf\Bundle\CoreBundle\CmfCoreBundle(),
));
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config.php');
}
}
10 changes: 10 additions & 0 deletions Tests/Resources/app/config/cmf_simple_cms.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services">

<config xmlns="http://cmf.symfony.com/schema/dic/simplecms"
basepath="/test/page"
>
</config>

</container>

6 changes: 6 additions & 0 deletions Tests/Resources/app/config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

$loader->import(CMF_TEST_CONFIG_DIR.'/default.php');
$loader->import(CMF_TEST_CONFIG_DIR.'/phpcr_odm.php');
$loader->import(CMF_TEST_CONFIG_DIR.'/sonata_admin.php');
$loader->import(__DIR__.'/cmf_simple_cms.xml');
13 changes: 13 additions & 0 deletions Tests/Resources/app/config/routing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use Symfony\Component\Routing\RouteCollection;

$collection = new RouteCollection();
$collection->addCollection(
$loader->import(CMF_TEST_CONFIG_DIR.'/routing/sonata_routing.yml')
);
//$collection->addCollection(
// $loader->import(__DIR__.'/routing/my_test_routing.yml')
//);

return $collection;
64 changes: 64 additions & 0 deletions Tests/WebTest/Admin/PageAdminTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace Symfony\Cmf\Bundle\SimpleCmsBundle\Tests\WebTest\Admin;

use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;

class PageAdminTest extends BaseTestCase
{
public function setUp()
{
$this->db('PHPCR')->loadFixtures(array(
'Symfony\Cmf\Bundle\SimpleCmsBundle\Tests\Resources\DataFixtures\Phpcr\LoadPageData',
));
$this->client = $this->createClient();
}

public function testPageList()
{
$crawler = $this->client->request('GET', '/admin/cmf/simplecms/page/list');
$res = $this->client->getResponse();
$this->assertEquals(200, $res->getStatusCode());
$this->assertCount(1, $crawler->filter('html:contains("homepage")'));
}

public function testPageEdit()
{
$crawler = $this->client->request('GET', '/admin/cmf/simplecms/page/test/pages/homepage/edit');
$res = $this->client->getResponse();
$this->assertEquals(200, $res->getStatusCode());
$this->assertCount(1, $crawler->filter('input[value="homepage"]'));
}

public function testPageShow()
{
return;
$crawler = $this->client->request('GET', '/admin/cmf/simplecms/page/test/pages/homepage/show');
$res = $this->client->getResponse();
$this->assertEquals(200, $res->getStatusCode());
$this->assertCount(2, $crawler->filter('td:contains("test-page")'));
}

public function testPageCreate()
{
$crawler = $this->client->request('GET', '/admin/cmf/simplecms/page/create');
$res = $this->client->getResponse();
$this->assertEquals(200, $res->getStatusCode());

$button = $crawler->selectButton('Create');
$form = $button->form();
$node = $form->getFormNode();
$actionUrl = $node->getAttribute('action');
$uniqId = substr(strchr($actionUrl, '='), 1);

$form[$uniqId.'[parent]'] = '/test/pages';
$form[$uniqId.'[title]'] = 'foo-page';
$form[$uniqId.'[label]'] = 'Foo Page';

$this->client->submit($form);
$res = $this->client->getResponse();

// If we have a 302 redirect, then all is well
$this->assertEquals(302, $res->getStatusCode());
}
}
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@
"symfony/framework-bundle": "~2.2",
"symfony-cmf/core-bundle": "~1.0.0-RC1",
"symfony-cmf/routing-bundle": "~1.1.0-RC1",
"symfony-cmf/menu-bundle": "~1.0.0-RC1",
"symfony-cmf/content-bundle": "~1.0.0-RC1",
"symfony-cmf/core-bundle": "~1.0.0-RC1",
"doctrine/phpcr-bundle": "1.0.*",
"doctrine/phpcr-odm": "1.0.*"
},
"require-dev": {
"symfony-cmf/testing": "1.0.*",
"sonata-project/doctrine-phpcr-admin-bundle": "1.0.*",
"symfony/monolog-bundle": "2.2.*"
},
"suggest": {
"symfony-cmf/create-bundle": "1.0.*",
"symfony-cmf/menu-bundle": "~1.0.0-RC1",
Expand Down
Loading