Skip to content

Commit 9132390

Browse files
Briandbu
Brian
authored andcommitted
Update bundle to current cmf
1 parent 3c27de2 commit 9132390

23 files changed

+111
-187
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
Tests/Resources/app/cache
22
Tests/Resources/app/logs
3-
Tests/Resources/test_db.sqlite
43
bin/
54
composer.lock
65
vendor/

.travis.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ php:
77

88
env:
99
- SYMFONY_VERSION=2.5.*
10-
10+
1111
matrix:
1212
allow_failures:
1313
- env: SYMFONY_VERSION=dev-master
@@ -18,8 +18,6 @@ matrix:
1818
env: SYMFONY_VERSION=2.4.*
1919
- php: 5.5
2020
env: SYMFONY_VERSION=dev-master
21-
22-
2321

2422
before_script:
2523
- composer self-update

Controller/PostController.php

-64
This file was deleted.

DependencyInjection/Configuration.php

-6
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,13 @@ public function getConfigTreeBuilder()
3939
// admin
4040
->arrayNode('sonata_admin')
4141
->canBeEnabled()
42-
->addDefaultsIfNotSet()
43-
->children()
44-
->booleanNode('enabled')->defaultTrue()->end()
45-
->end()
4642
->end()
4743

4844
// menu
4945
->arrayNode('integrate_menu')
5046
->addDefaultsIfNotSet()
5147
->canBeEnabled()
5248
->children()
53-
->booleanNode('enabled')->defaultTrue()->end()
5449
->scalarNode('content_key')->defaultNull()->end()
5550
->end()
5651
->end()
@@ -60,7 +55,6 @@ public function getConfigTreeBuilder()
6055
->addDefaultsIfNotSet()
6156
->canBeEnabled()
6257
->children()
63-
->booleanNode('enabled')->defaultTrue()->end()
6458
->scalarNode('posts_per_page')->defaultValue(5)->end()
6559
->end()
6660
->end()

Repository/BlogRepository.php

-20
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,6 @@ public function setBasepath($basepath)
4646
$this->basepath = $basepath;
4747
}
4848

49-
/**
50-
* Find blog by name
51-
*
52-
* @param string $name
53-
* @return null|Blog
54-
*/
55-
public function findByName($name)
56-
{
57-
return $this->search(array(
58-
'name' => $name,
59-
'limit' => 1,
60-
));
61-
}
62-
6349
/**
6450
* Search for blogs by an array of options
6551
*
@@ -116,12 +102,6 @@ protected function setDefaultOptions(OptionsResolver $resolver)
116102
'limit' => 'int',
117103
));
118104

119-
$resolver->setAllowedValues(array(
120-
'limit' => function($value) {
121-
return $value > 0;
122-
},
123-
));
124-
125105
return $resolver;
126106
}
127107

Repository/PostRepository.php

+1-39
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,10 @@ public function __construct($dm, ClassMetadata $class)
3636
$this->resolver = $this->setDefaultOptions(new OptionsResolver());
3737
}
3838

39-
/**
40-
* Find post by title
41-
*
42-
* @param string $title
43-
* @return Post|null
44-
*/
45-
public function findByTitle($title)
46-
{
47-
return $this->search(array(
48-
'title' => $title,
49-
'limit' => 1,
50-
));
51-
}
52-
5339
/**
5440
* Search for posts by an array of options:
5541
* - blogId: string (required)
56-
* - isPublishable: boolean (optional, default true)
42+
* - isPublishable: boolean (optional, default true) // TODO: https://github.com/symfony-cmf/CoreBundle/issues/126
5743
* - title: string (optional)
5844
* - limit: integer (optional)
5945
* - orderBy: array of arrays('field' => $field, 'order' => 'ASC or DESC') (optional)
@@ -146,30 +132,6 @@ protected function setDefaultOptions(OptionsResolver $resolver)
146132
'orderBy' => 'array',
147133
));
148134

149-
$resolver->setAllowedValues(array(
150-
'limit' => function($value) {
151-
return $value > 0;
152-
},
153-
'orderBy' => function(array $orderBys) {
154-
$validOrderBys = array();
155-
foreach ($orderBys as $orderBy) {
156-
157-
if ($orderByValid = isset($orderBy['order'])) {
158-
if(!in_array(strtolower($orderBy['order']), array('asc', 'desc'), true)) {
159-
throw new \InvalidArgumentException(sprintf(
160-
'Unrecognized orderBy order value "%s". order must be one of ASC or DESC.',
161-
$orderBy['order']
162-
));
163-
}
164-
}
165-
166-
$validOrderBys[] = isset($orderBy['field']) && $orderByValid;
167-
}
168-
169-
return count(array_filter($validOrderBys)) == count($orderBys);
170-
},
171-
));
172-
173135
return $resolver;
174136
}
175137
}

Resources/config/cmf_routing_auto.xml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" ?>
2+
<auto-mapping xmlns="http://cmf.symfony.com/schema/routing_auto">
3+
4+
<mapping class="Symfony\Cmf\Bundle\BlogBundle\Doctrine\Phpcr\Blog" uri-schema="/blogs/{blog}">
5+
6+
<token-provider token="blog" name="content_method">
7+
<option name="method">getName</option>
8+
</token-provider>
9+
10+
</mapping>
11+
12+
<mapping class="Symfony\Cmf\Bundle\BlogBundle\Doctrine\Phpcr\Post" uri-schema="/blogs/{blog}/{date}/{title}">
13+
14+
<token-provider token="blog" name="content_method">
15+
<option name="method">getBlog</option>
16+
</token-provider>
17+
18+
<token-provider token="date" name="content_datetime">
19+
<option name="method">getDate</option>
20+
</token-provider>
21+
22+
<token-provider token="title" name="content_method">
23+
<option name="method">getTitle</option>
24+
</token-provider>
25+
26+
</mapping>
27+
28+
</auto-mapping>

Resources/config/cmf_routing_auto.yml

-11
This file was deleted.

Resources/doc/building-a-blog.rst

-20
This file was deleted.

Resources/views/Blog/detail.html.twig

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
{# CmfBlogBundle:Blog:detail.html.twig #}
2-
31
{% extends "CmfBlogBundle::layout.html.twig" %}
42

53
{% block content %}

Resources/views/Blog/detailPaginated.html.twig

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
{# CmfBlogBundle:Blog:detailPaginated.html.twig #}
2-
31
{% extends "CmfBlogBundle:Blog:detail.html.twig" %}
42

53
{% block content %}

Resources/views/Blog/list.html.twig

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
{# CmfBlogBundle:Blog:list.html.twig #}
2-
31
{% extends "CmfBlogBundle::layout.html.twig" %}
42

53
{% block content %}

Resources/views/Post/detail.html.twig

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{# CmfBlogBundle:Post:detail.html.twig #}
2-
31
{% extends "CmfBlogBundle::layout.html.twig" %}
42

3+
{% set post = cmfMainContent %}
4+
55
{% block content %}
66
<div class="post">
77

Tests/Functional/Admin/BlogAdminTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testEdit()
5454
$crawler = $this->client->submit($form);
5555

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

6060
$dm = $this->db('PHPCR')->getOm();

Tests/Functional/Admin/PostAdminTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2014 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
313
namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Functional\Admin;
414

515
use Symfony\Cmf\Bundle\BlogBundle\Tests\Functional\BaseTestCase;

Tests/Functional/BaseTestCase.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,8 @@ public function setUp()
4444

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

47-
// $this->db('PHPCR')->loadFixtures(array(
48-
// 'Symfony\Cmf\Bundle\BlogBundle\Tests\Resources\DataFixtures\PHPCR\LoadBlogData',
49-
// ));
50-
51-
$this->runConsole('doctrine:phpcr:fixtures:load', array(
52-
'--fixtures' => __DIR__.'/../Resources/DataFixtures/PHPCR',
53-
'--no-interaction' => true,
47+
$this->db('PHPCR')->loadFixtures(array(
48+
'Symfony\Cmf\Bundle\BlogBundle\Tests\Resources\DataFixtures\PHPCR\LoadBlogData',
5449
));
5550
}
5651

Tests/Functional/BlogControllerTest.php

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?php
22

3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2014 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
313
namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Functional;
414

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

1121
$this->assertCount(3, $crawler->filter('h2'));
1222
}
23+
24+
/**
25+
* Pagination disabled
26+
*/
27+
public function testDetailAction()
28+
{
29+
$crawler = $this->request('GET', '/blogs/blog-three');
30+
31+
$this->assertCount(1, $crawler->filter('h2'));
32+
$this->assertCount(12, $crawler->filter('h3'));
33+
}
1334
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2014 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
13+
namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Functional;
14+
15+
class PostControllerTest extends BaseTestCase
16+
{
17+
public function testDetailAction()
18+
{
19+
$crawler = $this->request('GET', '/blogs/blog-one/2014-01-01/first-post');
20+
21+
$this->assertCount(2, $crawler->filter('h1'));
22+
$this->assertCount(1, $crawler->filter("html:contains('First Post')"),
23+
'Expected to find the Post\'s title, but it was not.'
24+
);
25+
}
26+
}

0 commit comments

Comments
 (0)