Skip to content

Commit

Permalink
Update bundle to current cmf
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian authored and dbu committed Mar 25, 2015
1 parent 289b616 commit b742147
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 187 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Tests/Resources/app/cache
Tests/Resources/app/logs
Tests/Resources/test_db.sqlite
bin/
composer.lock
vendor/
Expand Down
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ php:

env:
- SYMFONY_VERSION=2.5.*

matrix:
allow_failures:
- env: SYMFONY_VERSION=dev-master
Expand All @@ -18,8 +18,6 @@ matrix:
env: SYMFONY_VERSION=2.4.*
- php: 5.5
env: SYMFONY_VERSION=dev-master



before_script:
- composer self-update
Expand Down
64 changes: 0 additions & 64 deletions Controller/PostController.php

This file was deleted.

6 changes: 0 additions & 6 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,13 @@ public function getConfigTreeBuilder()
// admin
->arrayNode('sonata_admin')
->canBeEnabled()
->addDefaultsIfNotSet()
->children()
->booleanNode('enabled')->defaultTrue()->end()
->end()
->end()

// menu
->arrayNode('integrate_menu')
->addDefaultsIfNotSet()
->canBeEnabled()
->children()
->booleanNode('enabled')->defaultTrue()->end()
->scalarNode('content_key')->defaultNull()->end()
->end()
->end()
Expand All @@ -60,7 +55,6 @@ public function getConfigTreeBuilder()
->addDefaultsIfNotSet()
->canBeEnabled()
->children()
->booleanNode('enabled')->defaultTrue()->end()
->scalarNode('posts_per_page')->defaultValue(5)->end()
->end()
->end()
Expand Down
20 changes: 0 additions & 20 deletions Repository/BlogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ public function setBasepath($basepath)
$this->basepath = $basepath;
}

/**
* Find blog by name
*
* @param string $name
* @return null|Blog
*/
public function findByName($name)
{
return $this->search(array(
'name' => $name,
'limit' => 1,
));
}

/**
* Search for blogs by an array of options
*
Expand Down Expand Up @@ -116,12 +102,6 @@ protected function setDefaultOptions(OptionsResolver $resolver)
'limit' => 'int',
));

$resolver->setAllowedValues(array(
'limit' => function($value) {
return $value > 0;
},
));

return $resolver;
}

Expand Down
40 changes: 1 addition & 39 deletions Repository/PostRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,10 @@ public function __construct($dm, ClassMetadata $class)
$this->resolver = $this->setDefaultOptions(new OptionsResolver());
}

/**
* Find post by title
*
* @param string $title
* @return Post|null
*/
public function findByTitle($title)
{
return $this->search(array(
'title' => $title,
'limit' => 1,
));
}

/**
* Search for posts by an array of options:
* - blogId: string (required)
* - isPublishable: boolean (optional, default true)
* - isPublishable: boolean (optional, default true) // TODO: https://github.com/symfony-cmf/CoreBundle/issues/126
* - title: string (optional)
* - limit: integer (optional)
* - orderBy: array of arrays('field' => $field, 'order' => 'ASC or DESC') (optional)
Expand Down Expand Up @@ -146,30 +132,6 @@ protected function setDefaultOptions(OptionsResolver $resolver)
'orderBy' => 'array',
));

$resolver->setAllowedValues(array(
'limit' => function($value) {
return $value > 0;
},
'orderBy' => function(array $orderBys) {
$validOrderBys = array();
foreach ($orderBys as $orderBy) {

if ($orderByValid = isset($orderBy['order'])) {
if(!in_array(strtolower($orderBy['order']), array('asc', 'desc'), true)) {
throw new \InvalidArgumentException(sprintf(
'Unrecognized orderBy order value "%s". order must be one of ASC or DESC.',
$orderBy['order']
));
}
}

$validOrderBys[] = isset($orderBy['field']) && $orderByValid;
}

return count(array_filter($validOrderBys)) == count($orderBys);
},
));

return $resolver;
}
}
28 changes: 28 additions & 0 deletions Resources/config/cmf_routing_auto.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" ?>
<auto-mapping xmlns="http://cmf.symfony.com/schema/routing_auto">

<mapping class="Symfony\Cmf\Bundle\BlogBundle\Doctrine\Phpcr\Blog" uri-schema="/blogs/{blog}">

<token-provider token="blog" name="content_method">
<option name="method">getName</option>
</token-provider>

</mapping>

<mapping class="Symfony\Cmf\Bundle\BlogBundle\Doctrine\Phpcr\Post" uri-schema="/blogs/{blog}/{date}/{title}">

<token-provider token="blog" name="content_method">
<option name="method">getBlog</option>
</token-provider>

<token-provider token="date" name="content_datetime">
<option name="method">getDate</option>
</token-provider>

<token-provider token="title" name="content_method">
<option name="method">getTitle</option>
</token-provider>

</mapping>

</auto-mapping>
11 changes: 0 additions & 11 deletions Resources/config/cmf_routing_auto.yml

This file was deleted.

20 changes: 0 additions & 20 deletions Resources/doc/building-a-blog.rst

This file was deleted.

2 changes: 0 additions & 2 deletions Resources/views/Blog/detail.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{# CmfBlogBundle:Blog:detail.html.twig #}

{% extends "CmfBlogBundle::layout.html.twig" %}

{% block content %}
Expand Down
2 changes: 0 additions & 2 deletions Resources/views/Blog/detailPaginated.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{# CmfBlogBundle:Blog:detailPaginated.html.twig #}

{% extends "CmfBlogBundle:Blog:detail.html.twig" %}

{% block content %}
Expand Down
2 changes: 0 additions & 2 deletions Resources/views/Blog/list.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{# CmfBlogBundle:Blog:list.html.twig #}

{% extends "CmfBlogBundle::layout.html.twig" %}

{% block content %}
Expand Down
4 changes: 2 additions & 2 deletions Resources/views/Post/detail.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{# CmfBlogBundle:Post:detail.html.twig #}

{% extends "CmfBlogBundle::layout.html.twig" %}

{% set post = cmfMainContent %}

{% block content %}
<div class="post">

Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Admin/BlogAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testEdit()
$crawler = $this->client->submit($form);

$this->assertCount(1, $crawler->filter("html:contains('has been successfully updated')"),
'Expected a success flash message, but none as found.'
'Expected a success flash message, but none was found.'
);

$dm = $this->db('PHPCR')->getOm();
Expand Down
10 changes: 10 additions & 0 deletions Tests/Functional/Admin/PostAdminTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php

/*
* This file is part of the Symfony CMF package.
*
* (c) 2011-2014 Symfony CMF
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/


namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Functional\Admin;

use Symfony\Cmf\Bundle\BlogBundle\Tests\Functional\BaseTestCase;
Expand Down
9 changes: 2 additions & 7 deletions Tests/Functional/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,8 @@ public function setUp()

$this->router = $this->get('router');

// $this->db('PHPCR')->loadFixtures(array(
// 'Symfony\Cmf\Bundle\BlogBundle\Tests\Resources\DataFixtures\PHPCR\LoadBlogData',
// ));

$this->runConsole('doctrine:phpcr:fixtures:load', array(
'--fixtures' => __DIR__.'/../Resources/DataFixtures/PHPCR',
'--no-interaction' => true,
$this->db('PHPCR')->loadFixtures(array(
'Symfony\Cmf\Bundle\BlogBundle\Tests\Resources\DataFixtures\PHPCR\LoadBlogData',
));
}

Expand Down
21 changes: 21 additions & 0 deletions Tests/Functional/BlogControllerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?php

/*
* This file is part of the Symfony CMF package.
*
* (c) 2011-2014 Symfony CMF
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/


namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Functional;

class BlogControllerTest extends BaseTestCase
Expand All @@ -10,4 +20,15 @@ public function testListAction()

$this->assertCount(3, $crawler->filter('h2'));
}

/**
* Pagination disabled
*/
public function testDetailAction()
{
$crawler = $this->request('GET', '/blogs/blog-three');

$this->assertCount(1, $crawler->filter('h2'));
$this->assertCount(12, $crawler->filter('h3'));
}
}
26 changes: 26 additions & 0 deletions Tests/Functional/PostControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/*
* This file is part of the Symfony CMF package.
*
* (c) 2011-2014 Symfony CMF
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/


namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Functional;

class PostControllerTest extends BaseTestCase
{
public function testDetailAction()
{
$crawler = $this->request('GET', '/blogs/blog-one/2014-01-01/first-post');

$this->assertCount(2, $crawler->filter('h1'));
$this->assertCount(1, $crawler->filter("html:contains('First Post')"),
'Expected to find the Post\'s title, but it was not.'
);
}
}
Loading

0 comments on commit b742147

Please sign in to comment.