Skip to content
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

Version upgrades and cleanups #58

Closed

Conversation

briancappello
Copy link

This PR aims to bring the BlogBundle more in line with the CMF Bundle Standards.

General Changes
  • Updated dependencies to CMF 1.2.*
  • Updated routing configuration to work with RoutingAutoBundle 1.0.*
  • Parameter and service ID names have been changed to match the conventions laid out in the standards
  • DI in general got cleaned up with the intent of making it easier for 3rd party bundles to extend the BlogBundle
Persistence
  • Blog and Post have been refactored into the Model and Doctrine/Phpcr namespaces.
  • Their PHPCR mapping files were likewise relocated into Resources/config/doctrine-phpcr
  • The mapping files are now auto-loaded by a DoctrinePhpcrMappingsPass, if the class is found
  • Added a GenericInitializer service to create the cmf_blog.blog_basepath if it's not found
  • Rewrote the PostRepository to support searching by an array input-verified with the OptionsResolver
Front End
  • Separated BlogController into BlogController and PostController
  • Templates were moved, renamed and refactored accordingly. Added markup for easier styling (still on BS2)
New Features
  • Added (optional) route to list blogs
  • Added (optional) pagination support, using the KnpPaginatorBundle
  • Added (optional) PHPCR data fixture to ease development
Known Issues
  • Make sure configuration is loadable when defined as XML
  • The XML schema file for the config is out-of-date with Configuration
  • Translatable content. It might work; untested.

Addresses issues #53 and #57

group="dashboard.group_blog"
label_catalogue="CmfBlogBundle"
label="dashboard.label_blog"
<service id="cmf_blog.blog_admin" class="%cmf_blog.blog_admin_class%">
Copy link
Author

Choose a reason for hiding this comment

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

parameter name BC break

@lsmith77
Copy link
Member

lsmith77 commented Dec 4, 2014

awesome that you are working on this! in general I would say that you should not concern yourself with BC too much as this was never stable.

))
->add('body', 'textarea')
->add('blog', 'phpcr_document', array(
'class' => 'Symfony\Cmf\Bundle\BlogBundle\Document\Blog',
Copy link
Author

Choose a reason for hiding this comment

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

do not hard-code this

)
);
}
};
Copy link
Author

Choose a reason for hiding this comment

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

This code smells, but I'm not sure how best to improve it.
$allowedFields should not be hard-coded, and $throwIfNotFound isn't testable/reusable (eg if somebody wanted to add 'groupBy' support)

Copy link
Member

Choose a reason for hiding this comment

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

Why do you even need to validate this here? The PHPCR-ODM will throw an exception if you try and order by an invalid field. Given that, do you even need an option resolver?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe just limit the type and let the PHPCR-ODM validate the value.


return $this->renderResponse($contentTemplate, compact('post'));
}

Copy link
Member

Choose a reason for hiding this comment

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

Extra blank line

@dantleech
Copy link
Member

Looking really nice :)

Tagging was an issue for me here -- i.e. I started by writing Tag functionality in the bundle, but it shouldn't be the responsiblity of this bundle at all. i.e. it should be a CMF component which handles tags (or if possible something from another vendor, e.g. Sylius etc).

For my blog I wrote a tagging bundle specifically for PHPCR-ODM, but I won't vouch for its quality/methodology and don't want to maintain it :P

@dbu
Copy link
Member

dbu commented Dec 12, 2014

for tagging, i looked into SyliusTaxonomy but never found time to wrap it up: Sylius/Sylius#647

i suggest to leave tags out completely of this PR for now and instead check the sylius option again and then integrate here.

@dantleech
Copy link
Member

It would also be neat to add functional tests to this bundle as we have done for the others. We have a testing component which lets you easily build a test application.

The idea is that we have almost a "demo" application which you can run as follows:

$ ./vendor/symfony-cmf/testing/bin/server

Functional tests can then be added like in this example from the MenuBundle.

I can help you out here and it needn't be merged with this PR.

@briancappello
Copy link
Author

@dantleech Thanks for taking the time to review this PR! I went ahead and removed all of the tagging-related code for now. I also added a functional test for the BlogAdmin create action. After reviewing the functional test example in the MenuBundle, I wasn't entirely clear on the precise difference between an integration test and more of a web test. I went with the latter, as this is how we've been handling functional testing internally at VDW. Any feedback you have on methodology in that regard would be appreciated!

@@ -1,4 +1,7 @@
Tests/Resources/app/cache
Tests/Resources/app/logs
Tests/Resources/test_db.sqlite
Copy link
Member

Choose a reason for hiding this comment

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

You could also put this in app/cache

@dantleech
Copy link
Member

I wasn't entirely clear on the precise difference between an integration test and more of a web test.

The web tests test are HTTP tests, integration tests would be things that test services from the container
directly. So the WebTests are the right thing here.

The idea of the web test is that we should be able to test an implentation of the BlogBundle, i.e. the
Kernel in Tests/Resources/app/AppKernel should be treated as a working web application. (as I may have
mentioned before it is even possible to run a webserver using the vendor/symfony-cmf/testing/bin/server
script)

For example, in addition to the admin, we should test viewing a post via the
BlogController.

use Symfony\Cmf\Bundle\BlogBundle\Document\Post;
use Doctrine\ODM\PHPCR\Mapping\ClassMetadata;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Cmf\Bundle\BlogBundle\Doctrine\Phpcr\Post;

class PostRepository extends DocumentRepository
Copy link
Member

Choose a reason for hiding this comment

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

@dantleech how do you feel about the repositories. it seems correct to do this, but half of this is not blog specific - and afaik we did not do it in other bundles. i wonder if we should provide the base for most of this in the ContentBundle?

i am a bit unsure about the options resolver things we do. in the end, we wrap the query builder some more...

Copy link
Member

Choose a reason for hiding this comment

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

The search method seems only to be called to find the posts which belong to a particular blog.

In which case I would recommend removing it and replacing it with a findForBlog method if required -- and I am not sure it is as we could switch to the PageFanta paginator and its native PHPCR-ODM "driver".

So basically .. I think we could remove this, what do you think @briancappello ?

Copy link
Author

Choose a reason for hiding this comment

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

I would be fine with removing this repository class and switching to PagerFanta

Copy link
Member

Choose a reason for hiding this comment

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

maybe lets do this in another PR after this one is merged?

@lsmith77
Copy link
Member

didn't review this PR .. but I wonder if we shouldn't just merge at some point. then we can more easily collaborate on the details to tweak.

* @param string $title
* @return Post|null
*/
public function findByTitle($title)
Copy link
Member

Choose a reason for hiding this comment

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

Where does this get called?

Copy link
Author

Choose a reason for hiding this comment

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

I don't think it's used - no objections on my end to removing it

"symfony-cmf/routing-auto-bundle": "1.0.*",
"doctrine/phpcr-bundle": "1.0.*",
"doctrine/phpcr-odm": "1.0.*"
"sonata-project/doctrine-extensions": "~1.0.2",
Copy link
Member

Choose a reason for hiding this comment

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

should this be ~1.0.2|1.1 ?

Copy link
Member

Choose a reason for hiding this comment

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

or ~1.0,>=1.0.2 ?

@lsmith77
Copy link
Member

lsmith77 commented Feb 6, 2015

ping

@jrmyio
Copy link

jrmyio commented Mar 22, 2015

any update on this?

In oct. 2014 briancappello asked for updated deps, in december he did all the work, in march 2015 still nothing was merged. Why is this bundle even here if nobody maintains it and any help gets ignored.

im trying out symfony cmf but this is really discouraging

@wouterj
Copy link
Member

wouterj commented Mar 22, 2015

@connxnl keep in mind that this bundle is one of the showcase bundles of the CMF. It's goal is not so much of providing functionality, but more of providing examples of how to combine multiple CMF bundles.

Seems like this PR is ready to be merged, but we didn't get a notice of the update (maintainers only get a notice about comments). So thanks for your head up!

composer.lock
vendor
vendor/
.idea
Copy link
Member

Choose a reason for hiding this comment

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

this is the responsibility of the global git configuration of the developer, it is not specific to the project but to specific development environments. please remove this line.

@dbu
Copy link
Member

dbu commented Mar 23, 2015

@dantleech can you check if you see any blockers in here? i can do some minimal cleanup, squash the commits and merge.

/**
* Base Controller
*
* @author Daniel Leech <[email protected]>
Copy link
Member

Choose a reason for hiding this comment

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

I didn't write this :)

@dbu
Copy link
Member

dbu commented Mar 25, 2015

cleaned up and created a new branch in this repo

@dbu dbu closed this Mar 25, 2015
@dbu dbu mentioned this pull request Mar 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants