From f577693710e8f97b230c457575f4717f3ed1061b Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 25 Mar 2015 22:29:51 +0100 Subject: [PATCH] cleanup and cs fixer --- .travis.yml | 8 +- Admin/BlogAdmin.php | 5 +- Admin/PostAdmin.php | 5 +- CmfBlogBundle.php | 3 +- Controller/BaseController.php | 18 ++--- Controller/BlogController.php | 17 ++--- DependencyInjection/CmfBlogExtension.php | 76 ++++++++++++------- DependencyInjection/Configuration.php | 29 ++++--- Doctrine/Phpcr/Blog.php | 18 ++--- Doctrine/Phpcr/Post.php | 14 ++-- Model/Blog.php | 32 ++++---- Model/Post.php | 45 ++++++----- Repository/BlogRepository.php | 11 ++- Repository/PostRepository.php | 17 +++-- Resources/config/services.xml | 42 +++++----- Resources/translations/CmfBlogBundle.en.xliff | 5 ++ Tests/Functional/Admin/BlogAdminTest.php | 7 +- Tests/Functional/Admin/PostAdminTest.php | 1 - Tests/Functional/BaseTestCase.php | 15 ++-- Tests/Functional/BlogControllerTest.php | 3 +- Tests/Functional/PostControllerTest.php | 1 - .../DataFixtures/PHPCR/LoadBlogData.php | 1 - Tests/Resources/app/config/routing.php | 1 + Tests/Unit/Util/PostsUtilTest.php | 1 - Util/PostUtils.php | 3 +- composer.json | 6 +- run_tests.sh | 4 - 27 files changed, 206 insertions(+), 182 deletions(-) delete mode 100755 run_tests.sh diff --git a/.travis.yml b/.travis.yml index d334868..bbf22d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,18 +6,20 @@ php: - 5.5 env: - - SYMFONY_VERSION=2.5.* + - SYMFONY_VERSION=2.6.* matrix: allow_failures: - - env: SYMFONY_VERSION=dev-master + - env: SYMFONY_VERSION=2.7.* include: - php: 5.5 env: SYMFONY_VERSION=2.3.* - php: 5.5 env: SYMFONY_VERSION=2.4.* - php: 5.5 - env: SYMFONY_VERSION=dev-master + env: SYMFONY_VERSION=2.5.* + - php: 5.5 + env: SYMFONY_VERSION=2.7.* before_script: - composer self-update diff --git a/Admin/BlogAdmin.php b/Admin/BlogAdmin.php index 89acfb6..bf08545 100644 --- a/Admin/BlogAdmin.php +++ b/Admin/BlogAdmin.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Admin; use Sonata\AdminBundle\Datagrid\ListMapper; @@ -18,7 +17,7 @@ use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin; /** - * Blog Admin + * Blog Admin. * * @author Daniel Leech */ @@ -28,7 +27,7 @@ class BlogAdmin extends Admin protected $blogRoot; /** - * Constructor + * Constructor. * * @param string $code * @param string $class diff --git a/Admin/PostAdmin.php b/Admin/PostAdmin.php index 64c4e26..bda0605 100644 --- a/Admin/PostAdmin.php +++ b/Admin/PostAdmin.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Admin; use Sonata\AdminBundle\Datagrid\ListMapper; @@ -18,7 +17,7 @@ use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin; /** - * Post Admin + * Post Admin. * * @author Daniel Leech */ @@ -28,7 +27,7 @@ class PostAdmin extends Admin protected $blogClass; /** - * Constructor + * Constructor. * * @param string $code * @param string $class diff --git a/CmfBlogBundle.php b/CmfBlogBundle.php index a399649..40be3a1 100644 --- a/CmfBlogBundle.php +++ b/CmfBlogBundle.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle; use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass; @@ -26,7 +25,7 @@ public function build(ContainerBuilder $container) $container->addCompilerPass( DoctrinePhpcrMappingsPass::createXmlMappingDriver( array( - realpath(__DIR__ . '/Resources/config/doctrine-phpcr') => 'Symfony\Cmf\Bundle\BlogBundle\Doctrine\Phpcr', + realpath(__DIR__.'/Resources/config/doctrine-phpcr') => 'Symfony\Cmf\Bundle\BlogBundle\Doctrine\Phpcr', ), array('cmf_blog.persistence.phpcr.manager_name'), false, diff --git a/Controller/BaseController.php b/Controller/BaseController.php index cebdaa8..bafb281 100644 --- a/Controller/BaseController.php +++ b/Controller/BaseController.php @@ -9,25 +9,16 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Controller; -use Knp\Component\Pager\Paginator; -use Symfony\Cmf\Bundle\BlogBundle\Model\Post; -use Symfony\Cmf\Bundle\BlogBundle\Model\Blog; -use Symfony\Cmf\Bundle\BlogBundle\Repository\PostRepository; -use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishWorkflowChecker; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Security\Core\SecurityContextInterface; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use FOS\RestBundle\View\ViewHandlerInterface; use FOS\RestBundle\View\View; /** - * Base Controller - * - * @author Daniel Leech + * Base Controller. */ abstract class BaseController { @@ -47,11 +38,11 @@ abstract class BaseController protected $viewHandler; /** - * Constructor + * Constructor. * - * @param EngineInterface $templating + * @param EngineInterface $templating * @param SecurityContextInterface $securityContext - * @param ViewHandlerInterface $viewHandler + * @param ViewHandlerInterface $viewHandler */ public function __construct( EngineInterface $templating, @@ -68,6 +59,7 @@ protected function renderResponse($contentTemplate, $params) if ($this->viewHandler) { $view = new View($params); $view->setTemplate($contentTemplate); + return $this->viewHandler->handle($view); } diff --git a/Controller/BlogController.php b/Controller/BlogController.php index c2d9189..23e79a9 100644 --- a/Controller/BlogController.php +++ b/Controller/BlogController.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Controller; use Symfony\Cmf\Bundle\BlogBundle\Model\Blog; @@ -19,9 +18,10 @@ use Symfony\Component\Security\Core\SecurityContextInterface; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use FOS\RestBundle\View\ViewHandlerInterface; +use Knp\Component\Pager\Paginator; /** - * Blog Controller + * Blog Controller. * * @author Daniel Leech */ @@ -38,7 +38,7 @@ class BlogController extends BaseController protected $postRepository; /** - * @var \Knp\Component\Pager\Paginator + * @var Paginator */ protected $paginator; @@ -53,7 +53,7 @@ public function __construct( ViewHandlerInterface $viewHandler = null, BlogRepository $blogRepository, PostRepository $postRepository, - $paginator = null, + Paginator $paginator = null, $postsPerPage = 0 ) { parent::__construct($templating, $securityContext, $viewHandler); @@ -64,7 +64,7 @@ public function __construct( } /** - * List blogs + * List blogs. */ public function listAction(Request $request) { @@ -77,7 +77,7 @@ public function listAction(Request $request) } /** - * Blog detail - list posts in a blog, optionally paginated + * Blog detail - list posts in a blog, optionally paginated. */ public function detailAction(Request $request, Blog $contentDocument, $contentTemplate = null) { @@ -87,16 +87,15 @@ public function detailAction(Request $request, Blog $contentDocument, $contentTe 'blogId' => $blog->getId(), )); - $pager = false; if ($this->postsPerPage) { - $pager = $posts = $this->paginator->paginate( + $posts = $this->paginator->paginate( $posts, $request->query->get('page', 1), $this->postsPerPage ); } - $templateFilename = $pager ? 'detailPaginated' : 'detail'; + $templateFilename = $this->postsPerPage ? 'detailPaginated' : 'detail'; $contentTemplate = $this->getTemplateForResponse( $request, $contentTemplate ?: sprintf('CmfBlogBundle:Blog:%s.{_format}.twig', $templateFilename) diff --git a/DependencyInjection/CmfBlogExtension.php b/DependencyInjection/CmfBlogExtension.php index 13cac86..bf9c091 100644 --- a/DependencyInjection/CmfBlogExtension.php +++ b/DependencyInjection/CmfBlogExtension.php @@ -9,18 +9,17 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\DependencyInjection; +use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; - use Symfony\Cmf\Bundle\RoutingBundle\Routing\DynamicRouter; /** - * This is the class that loads and manages your bundle configuration + * This is the class that loads and manages your bundle configuration. * * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} */ @@ -38,25 +37,29 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('services.xml'); if (isset($config['persistence']['phpcr'])) { - $this->loadPhpcrPersistence($config, $loader, $container); + $this->loadPhpcrPersistence($config['persistence']['phpcr'], $loader, $container); } - if (isset($config['sonata_admin']) && $config['sonata_admin']['enabled']) { - $this->loadSonataAdmin($config, $loader, $container); + if ($config['sonata_admin']['enabled']) { + $this->loadSonataAdmin($config['sonata_admin'], $loader, $container); } - if (isset($config['integrate_menu']) && $config['integrate_menu']['enabled']) { - $this->loadMenuIntegration($config, $loader, $container); + if ($config['menu']['enabled']) { + $this->loadMenu($config['menu'], $loader, $container); } - $this->loadPaginationIntegration($config, $container); + if (!$this->handlePagination($config['pagination'], $loader, $container)) { + // this parameter is used in the cmf_blog.blog_controller service definition, so + // it must be defined until it's a viable option to use the expression language instead + $container->setParameter($this->getAlias().'.pagination.posts_per_page', 0); + } } - protected function loadPhpcrPersistence($config, XmlFileLoader $loader, ContainerBuilder $container) + private function loadPhpcrPersistence($config, XmlFileLoader $loader, ContainerBuilder $container) { - $container->setParameter($this->getAlias().'.blog_basepath', $config['persistence']['phpcr']['blog_basepath']); + $container->setParameter($this->getAlias().'.blog_basepath', $config['blog_basepath']); - foreach ($config['persistence']['phpcr']['class'] as $type => $classFqn) { + foreach ($config['class'] as $type => $classFqn) { $container->setParameter( $param = sprintf('cmf_blog.phpcr.%s.class', $type), $classFqn @@ -67,47 +70,64 @@ protected function loadPhpcrPersistence($config, XmlFileLoader $loader, Containe $loader->load('doctrine-phpcr.xml'); } - protected function loadSonataAdmin(array $config, XmlFileLoader $loader, ContainerBuilder $container) + private function loadSonataAdmin(array $config, XmlFileLoader $loader, ContainerBuilder $container) { $bundles = $container->getParameter('kernel.bundles'); if (!isset($bundles['SonataDoctrinePHPCRAdminBundle'])) { - return; + if ('auto' === $config['enabled']) { + return; + } + + throw new InvalidConfigurationException('Explicitly enabled sonata admin integration but SonataDoctrinePHPCRAdminBundle is not loaded'); } $loader->load('admin.xml'); } - protected function loadMenuIntegration(array $config, XmlFileLoader $loader, ContainerBuilder $container) + private function loadMenu(array $config, XmlFileLoader $loader, ContainerBuilder $container) { $bundles = $container->getParameter('kernel.bundles'); if (!isset($bundles['CmfMenuBundle'])) { - return; + if ('auto' === $config['enabled']) { + return; + } + + throw new InvalidConfigurationException('Explicitly enabled menu integration but CmfMenuBundle is not loaded'); } - if (empty($config['integrate_menu']['content_key'])) { + if (empty($config['content_key'])) { if (!class_exists('Symfony\\Cmf\\Bundle\\RoutingBundle\\Routing\\DynamicRouter')) { - throw new \RuntimeException('You need to set the content_key when not using the CmfRoutingBundle DynamicRouter'); + if ('auto' === $config['enabled']) { + return; + } + + throw new InvalidConfigurationException('You need to set the content_key when not using the CmfRoutingBundle DynamicRouter'); } $contentKey = DynamicRouter::CONTENT_KEY; } else { - $contentKey = $config['integrate_menu']['content_key']; + $contentKey = $config['content_key']; } - $container->setParameter('cmf_blog.content_key', $contentKey); + $container->setParameter($this->getAlias().'.content_key', $contentKey); $loader->load('menu.xml'); } - protected function loadPaginationIntegration(array $config, ContainerBuilder $container) + private function handlePagination(array $config, XmlFileLoader $loader, ContainerBuilder $container) { - if (isset($config['pagination']) && $config['pagination']['enabled']) { - $container->setParameter($this->getAlias().'.pagination.enabled', true); - $container->setParameter($this->getAlias().'.pagination.posts_per_page', $config['pagination']['posts_per_page']); - } else { - // this parameter is used in the cmf_blog.blog_controller service definition, so - // it must be defined until it's a viable option to use the expression language instead - $container->setParameter($this->getAlias().'.pagination.posts_per_page', 0); + if (!$config['enabled']) { + return false; } + if (!isset($bundles['KnpPaginatorBundle'])) { + if ('auto' === $config['enabled']) { + return false; + } + + throw new InvalidConfigurationException('Explicitly enabled pagination but KnpPaginatorBundle is not loaded'); + } + $container->setParameter($this->getAlias().'.pagination.posts_per_page', $config['pagination']['posts_per_page']); + + return true; } /** diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 984418a..0ed78dd 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -9,20 +9,19 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\DependencyInjection; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\Builder\TreeBuilder; /** -* This class contains the configuration information for the bundle -* -* This information is solely responsible for how the different configuration -* sections are normalized, and merged. -* -* @author David Buchmann -*/ + * This class contains the configuration information for the bundle. + * + * This information is solely responsible for how the different configuration + * sections are normalized, and merged. + * + * @author David Buchmann + */ class Configuration implements ConfigurationInterface { /** @@ -38,14 +37,22 @@ public function getConfigTreeBuilder() // admin ->arrayNode('sonata_admin') - ->canBeEnabled() + ->children() + ->enumNode('enabled') + ->values(array(true, false, 'auto')) + ->defaultValue('auto') + ->end() + ->end() ->end() // menu - ->arrayNode('integrate_menu') + ->arrayNode('menu') ->addDefaultsIfNotSet() - ->canBeEnabled() ->children() + ->enumNode('enabled') + ->values(array(true, false, 'auto')) + ->defaultValue('auto') + ->end() ->scalarNode('content_key')->defaultNull()->end() ->end() ->end() diff --git a/Doctrine/Phpcr/Blog.php b/Doctrine/Phpcr/Blog.php index f846c79..c3747ff 100644 --- a/Doctrine/Phpcr/Blog.php +++ b/Doctrine/Phpcr/Blog.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Doctrine\Phpcr; use Symfony\Cmf\Bundle\BlogBundle\Model\Blog as BlogModel; @@ -18,7 +17,7 @@ use Doctrine\ODM\PHPCR\Document\Generic; /** - * Blog Document + * Blog Document. * * @author Daniel Leech */ @@ -35,21 +34,21 @@ class Blog extends BlogModel implements RouteReferrersReadInterface protected $slug; /** - * Parent Document + * Parent Document. * * @var Generic */ protected $parentDocument; /** - * Routes (mapped from Route::content) + * Routes (mapped from Route::content). * * @var \Symfony\Component\Routing\Route[] */ protected $routes; /** - * Get id + * Get id. * * @return string */ @@ -59,7 +58,7 @@ public function getId() } /** - * Get slug + * Get slug. * * @return string */ @@ -69,7 +68,7 @@ public function getSlug() } /** - * Get parent document + * Get parent document. * * @return Generic */ @@ -79,9 +78,10 @@ public function getParentDocument() } /** - * Set parent document + * Set parent document. * * @param Generic $parentDocument + * * @return Blog */ public function setParentDocument(Generic $parentDocument) @@ -92,7 +92,7 @@ public function setParentDocument(Generic $parentDocument) } /** - * Get routes that point to this content + * Get routes that point to this content. * * @return \Symfony\Component\Routing\Route[] */ diff --git a/Doctrine/Phpcr/Post.php b/Doctrine/Phpcr/Post.php index 417d232..bbffdb3 100644 --- a/Doctrine/Phpcr/Post.php +++ b/Doctrine/Phpcr/Post.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Doctrine\Phpcr; use Symfony\Cmf\Bundle\BlogBundle\Util\PostUtils; @@ -35,14 +34,14 @@ class Post extends PostModel implements RouteReferrersReadInterface protected $slug; /** - * List of referring routes + * List of referring routes. * * @var \Symfony\Component\Routing\Route[] */ protected $routes; /** - * Get id + * Get id. * * @return string */ @@ -52,7 +51,7 @@ public function getId() } /** - * Get slug + * Get slug. * * @return string */ @@ -74,7 +73,7 @@ public function setTitle($title) } /** - * Get parent document + * Get parent document. * * @return BlogModel */ @@ -84,9 +83,10 @@ public function getParentDocument() } /** - * Set parent document + * Set parent document. * * @param BlogModel $blog + * * @return Post */ public function setParentDocument(BlogModel $blog) @@ -97,7 +97,7 @@ public function setParentDocument(BlogModel $blog) } /** - * Get routes + * Get routes. * * @return \Symfony\Component\Routing\Route[] */ diff --git a/Model/Blog.php b/Model/Blog.php index 1e61e7d..61a5274 100644 --- a/Model/Blog.php +++ b/Model/Blog.php @@ -9,41 +9,40 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Model; use Doctrine\Common\Collections\ArrayCollection; /** - * Blog Model + * Blog Model. * * @author Daniel Leech */ class Blog { /** - * Blog name + * Blog name. * * @var string */ protected $name; /** - * Description of the blog + * Description of the blog. * * @var string */ protected $description; /** - * Posts + * Posts. * * @var ArrayCollection */ protected $posts; /** - * Constructor + * Constructor. */ public function __construct() { @@ -51,7 +50,7 @@ public function __construct() } /** - * Get name + * Get name. * * @return string */ @@ -61,9 +60,10 @@ public function getName() } /** - * Set name + * Set name. * * @param string $name + * * @return Blog */ public function setName($name) @@ -74,7 +74,7 @@ public function setName($name) } /** - * Get description + * Get description. * * @return string */ @@ -84,9 +84,10 @@ public function getDescription() } /** - * Set description + * Set description. * * @param string $description + * * @return Blog */ public function setDescription($description) @@ -97,9 +98,10 @@ public function setDescription($description) } /** - * Add post + * Add post. * * @param Post $post + * * @return Blog */ public function addPost(Post $post) @@ -112,9 +114,10 @@ public function addPost(Post $post) } /** - * Remove post + * Remove post. * * @param Post $post + * * @return Blog */ public function removePost(Post $post) @@ -127,7 +130,7 @@ public function removePost(Post $post) } /** - * Get posts + * Get posts. * * @return ArrayCollection */ @@ -137,9 +140,10 @@ public function getPosts() } /** - * Set posts + * Set posts. * * @param $posts + * * @return $this */ public function setPosts($posts) diff --git a/Model/Post.php b/Model/Post.php index cda3a8d..e6eeae5 100644 --- a/Model/Post.php +++ b/Model/Post.php @@ -9,14 +9,13 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Model; use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishTimePeriodInterface; use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishableInterface; /** - * Post Model + * Post Model. * * @author Daniel Leech */ @@ -63,7 +62,7 @@ class Post implements PublishTimePeriodInterface, PublishableInterface protected $isPublishable = true; /** - * Constructor + * Constructor. */ public function __construct() { @@ -71,7 +70,7 @@ public function __construct() } /** - * Get blog + * Get blog. * * @return Blog */ @@ -81,9 +80,10 @@ public function getBlog() } /** - * Set blog + * Set blog. * * @param Blog $blog + * * @return Post */ public function setBlog(Blog $blog) @@ -94,7 +94,7 @@ public function setBlog(Blog $blog) } /** - * Get title + * Get title. * * @return string */ @@ -104,9 +104,10 @@ public function getTitle() } /** - * Set title + * Set title. * * @param string $title + * * @return Post */ public function setTitle($title) @@ -117,7 +118,7 @@ public function setTitle($title) } /** - * Get body preview + * Get body preview. * * @return string */ @@ -127,9 +128,10 @@ public function getBodyPreview() } /** - * Set body preview + * Set body preview. * * @param string $bodyPreview + * * @return Post */ public function setBodyPreview($bodyPreview) @@ -140,7 +142,7 @@ public function setBodyPreview($bodyPreview) } /** - * Get body (the post's content) + * Get body (the post's content). * * @return string */ @@ -150,9 +152,10 @@ public function getBody() } /** - * Set body (the post's content) + * Set body (the post's content). * * @param string $body + * * @return Post */ public function setBody($body) @@ -163,7 +166,7 @@ public function setBody($body) } /** - * Get publication date + * Get publication date. * * @return \DateTime */ @@ -173,9 +176,10 @@ public function getDate() } /** - * Set publication date + * Set publication date. * * @param \DateTime $date + * * @return Post */ public function setDate($date) @@ -186,7 +190,7 @@ public function setDate($date) } /** - * Is publishable + * Is publishable. * * @return bool */ @@ -196,9 +200,10 @@ public function isPublishable() } /** - * Set publishable + * Set publishable. * * @param bool $publishable + * * @return Post */ public function setPublishable($publishable) @@ -209,7 +214,7 @@ public function setPublishable($publishable) } /** - * Get publish start date + * Get publish start date. * * @return \DateTime */ @@ -219,9 +224,10 @@ public function getPublishStartDate() } /** - * Set publish start date + * Set publish start date. * * @param \DateTime $publishStartDate + * * @return Post */ public function setPublishStartDate(\DateTime $publishStartDate = null) @@ -232,7 +238,7 @@ public function setPublishStartDate(\DateTime $publishStartDate = null) } /** - * Get publish end date + * Get publish end date. * * @return \DateTime */ @@ -242,9 +248,10 @@ public function getPublishEndDate() } /** - * Set publish end date + * Set publish end date. * * @param \DateTime $publishEndDate + * * @return Post */ public function setPublishEndDate(\DateTime $publishEndDate = null) diff --git a/Repository/BlogRepository.php b/Repository/BlogRepository.php index e3af5a8..e049ccd 100644 --- a/Repository/BlogRepository.php +++ b/Repository/BlogRepository.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Repository; use Doctrine\ODM\PHPCR\DocumentRepository; @@ -30,10 +29,10 @@ class BlogRepository extends DocumentRepository protected $basepath; /** - * Constructor + * Constructor. * * @param \Doctrine\ODM\PHPCR\DocumentManager $dm - * @param ClassMetadata $class + * @param ClassMetadata $class */ public function __construct($dm, ClassMetadata $class) { @@ -47,10 +46,11 @@ public function setBasepath($basepath) } /** - * Search for blogs by an array of options + * Search for blogs by an array of options. * * @param array $options - * @return Blog[] When limit is not provided or is greater than 1 + * + * @return Blog[] When limit is not provided or is greater than 1 * @return Blog|null When limit is set to 1 */ public function search(array $options) @@ -104,5 +104,4 @@ protected function setDefaultOptions(OptionsResolver $resolver) return $resolver; } - } diff --git a/Repository/PostRepository.php b/Repository/PostRepository.php index 2bb6a5a..4a3c748 100644 --- a/Repository/PostRepository.php +++ b/Repository/PostRepository.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Repository; use Doctrine\ODM\PHPCR\DocumentRepository; @@ -25,10 +24,10 @@ class PostRepository extends DocumentRepository protected $resolver; /** - * Constructor + * Constructor. * * @param \Doctrine\ODM\PHPCR\DocumentManager $dm - * @param ClassMetadata $class + * @param ClassMetadata $class */ public function __construct($dm, ClassMetadata $class) { @@ -42,10 +41,11 @@ public function __construct($dm, ClassMetadata $class) * - 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) + * - orderBy: array of arrays('field' => $field, 'order' => 'ASC or DESC') (optional). * * @param array $options - * @return Post[] When limit is not provided or is greater than 1 + * + * @return Post[] When limit is not provided or is greater than 1 * @return Post|null When limit is set to 1 */ public function search(array $options) @@ -62,9 +62,10 @@ public function search(array $options) } /** - * Create query builder from search options + * Create query builder from search options. * * @param array $options + * * @return \Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder */ protected function createQueryBuilderFromOptions(array $options) @@ -81,7 +82,6 @@ protected function createQueryBuilderFromOptions(array $options) // order by if (isset($options['orderBy']['field']) && isset($options['orderBy']['order'])) { - $field = $options['orderBy']['field']; $sortOrder = strtolower($options['orderBy']['order']); @@ -97,9 +97,10 @@ protected function createQueryBuilderFromOptions(array $options) } /** - * Set default search options + * Set default search options. * * @param OptionsResolver $resolver + * * @return OptionsResolver */ protected function setDefaultOptions(OptionsResolver $resolver) diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 870f8e3..83fd4ae 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -2,30 +2,30 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - - Symfony\Cmf\Bundle\BlogBundle\Controller\BlogController - Symfony\Cmf\Bundle\BlogBundle\Controller\PostController - + + Symfony\Cmf\Bundle\BlogBundle\Controller\BlogController + Symfony\Cmf\Bundle\BlogBundle\Controller\PostController + - + - - - - - - - - %cmf_blog.pagination.posts_per_page% - + + + + + + + + %cmf_blog.pagination.posts_per_page% + - - - - - - + + + + + + - + diff --git a/Resources/translations/CmfBlogBundle.en.xliff b/Resources/translations/CmfBlogBundle.en.xliff index e11e0fe..2d64e45 100644 --- a/Resources/translations/CmfBlogBundle.en.xliff +++ b/Resources/translations/CmfBlogBundle.en.xliff @@ -87,6 +87,11 @@ Blog + + form.label_description + Description + + form.label_body_preview Body Preview diff --git a/Tests/Functional/Admin/BlogAdminTest.php b/Tests/Functional/Admin/BlogAdminTest.php index e6c4ea7..aab06e1 100644 --- a/Tests/Functional/Admin/BlogAdminTest.php +++ b/Tests/Functional/Admin/BlogAdminTest.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Functional\Admin; use Symfony\Cmf\Bundle\BlogBundle\Tests\Functional\BaseTestCase; @@ -24,14 +23,14 @@ public function testCreate() $formPrefix = $this->getAdminFormNamePrefix($crawler); $form->setValues(array( - $formPrefix.'[name]' => 'Test Blog', - $formPrefix.'[description]' => 'A blog lives here.', + $formPrefix.'[name]' => 'Test Blog', + $formPrefix.'[description]' => 'A blog lives here.', $formPrefix.'[parentDocument]' => '/cms/blogs', )); $this->client->followRedirects(); $crawler = $this->client->submit($form); - +echo ($this->client->getResponse()->getContent()); $this->assertCount(1, $crawler->filter("html:contains('has been successfully created')"), 'Expected a success flash message, but none was found.' ); diff --git a/Tests/Functional/Admin/PostAdminTest.php b/Tests/Functional/Admin/PostAdminTest.php index 0a84e9e..143e5dd 100644 --- a/Tests/Functional/Admin/PostAdminTest.php +++ b/Tests/Functional/Admin/PostAdminTest.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Functional\Admin; use Symfony\Cmf\Bundle\BlogBundle\Tests\Functional\BaseTestCase; diff --git a/Tests/Functional/BaseTestCase.php b/Tests/Functional/BaseTestCase.php index 60da308..42e89c0 100644 --- a/Tests/Functional/BaseTestCase.php +++ b/Tests/Functional/BaseTestCase.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Functional; use Symfony\Bundle\FrameworkBundle\Client; @@ -51,6 +50,7 @@ public function setUp() /** * @param string $serviceId + * * @return object */ protected function get($serviceId) @@ -60,6 +60,7 @@ protected function get($serviceId) /** * @param string $parameter + * * @return mixed */ protected function getParameter($parameter) @@ -70,6 +71,7 @@ protected function getParameter($parameter) /** * @param string $method * @param string $url + * * @return \Symfony\Component\DomCrawler\Crawler */ protected function request($method, $url) @@ -80,7 +82,8 @@ protected function request($method, $url) /** * @param string $method * @param string $route - * @param array $parameters + * @param array $parameters + * * @return \Symfony\Component\DomCrawler\Crawler */ protected function requestRoute($method, $route, array $parameters = array()) @@ -92,10 +95,11 @@ protected function requestRoute($method, $route, array $parameters = array()) } /** - * Returns the unique ID Sonata Admins use to prefix form fields + * Returns the unique ID Sonata Admins use to prefix form fields. * * @param \Symfony\Component\DomCrawler\Crawler $crawler - * @param string $filter + * @param string $filter + * * @return string */ protected function getAdminFormNamePrefix(\Symfony\Component\DomCrawler\Crawler $crawler, $filter = 'input[type=text]') @@ -107,7 +111,8 @@ protected function getAdminFormNamePrefix(\Symfony\Component\DomCrawler\Crawler /** * @param string $command - * @param array $options + * @param array $options + * * @return int */ protected function runConsole($command, array $options = array()) diff --git a/Tests/Functional/BlogControllerTest.php b/Tests/Functional/BlogControllerTest.php index 2abd88b..5ab26e1 100644 --- a/Tests/Functional/BlogControllerTest.php +++ b/Tests/Functional/BlogControllerTest.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Functional; class BlogControllerTest extends BaseTestCase @@ -22,7 +21,7 @@ public function testListAction() } /** - * Pagination disabled + * Pagination disabled. */ public function testDetailAction() { diff --git a/Tests/Functional/PostControllerTest.php b/Tests/Functional/PostControllerTest.php index 376583a..e7a2781 100644 --- a/Tests/Functional/PostControllerTest.php +++ b/Tests/Functional/PostControllerTest.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Functional; class PostControllerTest extends BaseTestCase diff --git a/Tests/Resources/DataFixtures/PHPCR/LoadBlogData.php b/Tests/Resources/DataFixtures/PHPCR/LoadBlogData.php index 499a96f..f11346d 100644 --- a/Tests/Resources/DataFixtures/PHPCR/LoadBlogData.php +++ b/Tests/Resources/DataFixtures/PHPCR/LoadBlogData.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Resources\DataFixtures\PHPCR; use Doctrine\Common\DataFixtures\FixtureInterface; diff --git a/Tests/Resources/app/config/routing.php b/Tests/Resources/app/config/routing.php index ceb49e8..2b42048 100644 --- a/Tests/Resources/app/config/routing.php +++ b/Tests/Resources/app/config/routing.php @@ -9,4 +9,5 @@ $collection->addCollection( $loader->import(__DIR__.'/routing.yml') ); + return $collection; diff --git a/Tests/Unit/Util/PostsUtilTest.php b/Tests/Unit/Util/PostsUtilTest.php index 0474b67..f264dbd 100644 --- a/Tests/Unit/Util/PostsUtilTest.php +++ b/Tests/Unit/Util/PostsUtilTest.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Tests\Unit\Util; use Symfony\Cmf\Bundle\BlogBundle\Util\PostUtils; diff --git a/Util/PostUtils.php b/Util/PostUtils.php index 23a42a0..b58c685 100644 --- a/Util/PostUtils.php +++ b/Util/PostUtils.php @@ -9,11 +9,10 @@ * file that was distributed with this source code. */ - namespace Symfony\Cmf\Bundle\BlogBundle\Util; /** - * Miscilaneous reuseable code + * Miscilaneous reuseable code. * * @author Daniel Leech */ diff --git a/composer.json b/composer.json index 5e7c8d1..875077f 100644 --- a/composer.json +++ b/composer.json @@ -24,12 +24,8 @@ "friendsofsymfony/rest-bundle": "~1.4" }, "require-dev": { - "phpunit/phpunit": "~3.7.28", "symfony-cmf/testing": "1.2.*", - "sonata-project/doctrine-phpcr-admin-bundle": "1.2.*", - "doctrine/orm": "~2.4.7", - "nelmio/alice": "~1.7,>=1.7.2", - "phpcr/phpcr-shell": "@alpha" + "sonata-project/doctrine-phpcr-admin-bundle": "1.2.*" }, "suggest": { "sonata-project/doctrine-phpcr-admin-bundle": "For sonata administration", diff --git a/run_tests.sh b/run_tests.sh deleted file mode 100755 index 277ee13..0000000 --- a/run_tests.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -sh vendor/symfony-cmf/testing/bin/travis/doctrine_orm.sh -sh vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh -bin/phpunit