Skip to content
Closed
Show file tree
Hide file tree
Changes from 9 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Tests/Resources/app/cache
Tests/Resources/app/logs
bin/
composer.lock
vendor
vendor/
32 changes: 17 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.4
- 5.5
- 5.6
- hhvm

env:
- SYMFONY_VERSION=2.5.*
- SYMFONY_VERSION=2.7.* SYMFONY_DEPRECATIONS_HELPER=weak
Copy link
Member

Choose a reason for hiding this comment

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

are we sure we removed all deprecated usages from this bundle?


matrix:
allow_failures:
- env: SYMFONY_VERSION=dev-master
include:
- php: 5.3
env: SYMFONY_VERSION=2.3.* COMPOSER_FLAGS="--prefer-lowest"
- php: 5.5
env: SYMFONY_VERSION=2.3.*
- php: 5.5
env: SYMFONY_VERSION=2.4.*
env: SYMFONY_VERSION=2.6.*
- php: 5.5
env: SYMFONY_VERSION=dev-master


env: SYMFONY_VERSION=2.7.* SYMFONY_DEPRECATIONS_HELPER=weak
Copy link
Member

Choose a reason for hiding this comment

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

this one is no longer needed as it's the default env

- php: 5.5
env: SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=weak
Copy link
Member

Choose a reason for hiding this comment

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

missing allowed failures for:

  • Symfony 2.8 (which should not set the deprecations helper to weak btw, so we can catch new deprecations in 2.8)
  • Symfony 3.0
  • PHP nightly


before_script:
- composer self-update
- echo 'memory_limit = -1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- composer require symfony/symfony:${SYMFONY_VERSION} --prefer-source
before_install:
- composer self-update || true
- sh -c 'if [ "${TRAVIS_PHP_VERSION}" != "hhvm" ]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi;'
- composer require --no-update symfony/symfony:${SYMFONY_VERSION}
- COMPOSER_ROOT_VERSION=dev-master composer update $COMPOSER_FLAGS --prefer-source --no-interaction
- vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh
Copy link
Member

Choose a reason for hiding this comment

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

I prefer to use things the correct way:

before_install:
  - composer self-update || true
  - sh -c 'if [ "${TRAVIS_PHP_VERSION}" != "hhvm" ]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi;'
  - composer require --no-update symfony/symfony:${SYMFONY_VERSION}

install: COMPOSER_ROOT_VERSION=dev-master composer update $COMPOSER_FLAGS --prefer-source --no-interaction

before_script: vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh

Copy link
Member

Choose a reason for hiding this comment

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

honestly I just wanted the PR to be rebased and the install part to work ..
lets do all of the above things in a new PR, ok?


script: phpunit --coverage-text
Expand Down
55 changes: 32 additions & 23 deletions Admin/BlogAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@
* file that was distributed with this source code.
*/


namespace Symfony\Cmf\Bundle\BlogBundle\Admin;

use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin;
use Symfony\Cmf\Bundle\BlogBundle\Form\PostType;
use Symfony\Cmf\Bundle\BlogBundle\Routing\BlogRouteManager;

/**
* Blog Admin
* Blog Admin.
*
* @author Daniel Leech <[email protected]>
*/
Expand All @@ -30,33 +26,46 @@ class BlogAdmin extends Admin
protected $translationDomain = 'CmfBlogBundle';
protected $blogRoot;

protected function configureFormFields(FormMapper $mapper)
{
$mapper->add('name', 'text');
$mapper->add('parent', 'doctrine_phpcr_odm_tree', array(
'root_node' => $this->blogRoot,
'choice_list' => array(),
'select_root_node' => true)
);
}

protected function configureDatagridFilters(DatagridMapper $dm)
/**
* Constructor.
*
* @param string $code
* @param string $class
* @param string $baseControllerName
* @param string $blogRoot
*/
public function __construct($code, $class, $baseControllerName, $blogRoot)
{
$dm->add('name', 'doctrine_phpcr_string');
parent::__construct($code, $class, $baseControllerName);
$this->blogRoot = $blogRoot;
}

protected function configureListFields(ListMapper $dm)
protected function configureFormFields(FormMapper $formMapper)
{
$dm->addIdentifier('name');
$formMapper
->with('dashboard.label_blog')
->add('name', 'text')
->add('description', 'textarea')
->add('parentDocument', 'doctrine_phpcr_odm_tree', array(
'root_node' => $this->blogRoot,
'choice_list' => array(),
'select_root_node' => true,
))
->end()
;
}

public function setBlogRoot($blogRoot)
protected function configureDatagridFilters(DatagridMapper $filterMapper)
{
$this->blogRoot = $blogRoot;
$filterMapper
->add('name', 'doctrine_phpcr_string')
;
}

public function validate(ErrorElement $ee, $obj)
protected function configureListFields(ListMapper $listMapper)
{
$ee->with('name')->assertNotBlank()->end();
$listMapper
->addIdentifier('name')
;
}
}
72 changes: 37 additions & 35 deletions Admin/PostAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,67 @@
* file that was distributed with this source code.
*/


namespace Symfony\Cmf\Bundle\BlogBundle\Admin;

use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\DoctrinePHPCRAdminBundle\Admin\Admin;
use Symfony\Cmf\Bundle\BlogBundle\Form\PostType;
use Symfony\Cmf\Bundle\BlogBundle\Form\DataTransformer\CsvToArrayTransformer;

/**
* Post Admin
* Post Admin.
*
* @author Daniel Leech <[email protected]>
*/
class PostAdmin extends Admin
{
protected $translationDomain = 'CmfBlogBundle';
protected $blogClass;

protected function configureFormFields(FormMapper $mapper)
/**
* Constructor.
*
* @param string $code
* @param string $class
* @param string $baseControllerName
* @param string $blogClass
*/
public function __construct($code, $class, $baseControllerName, $blogClass)
{
// @todo: I think this would be better as a service,
// but I don't know how integrate the form
// AND have all the Sonata magic from the
// FormMapper->add method.

// $csvToArrayTransformer = new CsvToArrayTransformer;

$mapper->add('title');
$mapper->add('date', 'datetime', array(
'widget' => 'single_text',
));

$mapper->add('body', 'textarea');
$mapper->add('blog', 'phpcr_document', array(
'class' => 'Symfony\Cmf\Bundle\BlogBundle\Document\Blog',
));

//$tags = $mapper->create('tags', 'text')
// ->addModelTransformer($csvToArrayTransformer);

// $mapper->add($tags);
parent::__construct($code, $class, $baseControllerName);
$this->blogClass = $blogClass;
}

protected function configureDatagridFilters(DatagridMapper $dm)
protected function configureFormFields(FormMapper $formMapper)
{
$dm->add('title', 'doctrine_phpcr_string');
$formMapper
->with('dashboard.label_post')
->add('title')
->add('date', 'datetime', array(
'widget' => 'single_text',
))
->add('bodyPreview', 'textarea')
->add('body', 'textarea')
->add('blog', 'phpcr_document', array(
'class' => $this->blogClass,
))
->end()
;
}

protected function configureListFields(ListMapper $dm)
protected function configureDatagridFilters(DatagridMapper $filterMapper)
{
$dm->add('blog');
$dm->add('date', 'datetime');
$dm->addIdentifier('title');
$filterMapper
->add('title', 'doctrine_phpcr_string')
;
}

public function validate(ErrorElement $ee, $obj)
protected function configureListFields(ListMapper $listMapper)
{
$ee->with('title')->assertNotBlank()->end();
$listMapper
->addIdentifier('title')
->add('blog')
->add('date', 'datetime')
;
}
}
62 changes: 0 additions & 62 deletions Block/TagCloudBlock.php

This file was deleted.

20 changes: 19 additions & 1 deletion CmfBlogBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,29 @@
* file that was distributed with this source code.
*/


namespace Symfony\Cmf\Bundle\BlogBundle;

use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class CmfBlogBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);

if (class_exists('Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass')) {
$container->addCompilerPass(
DoctrinePhpcrMappingsPass::createXmlMappingDriver(
array(
realpath(__DIR__.'/Resources/config/doctrine-phpcr') => 'Symfony\Cmf\Bundle\BlogBundle\Doctrine\Phpcr',
),
array('cmf_blog.persistence.phpcr.manager_name'),
false,
array('CmfBlogBundle' => 'Symfony\Cmf\Bundle\BlogBundle\Doctrine\Phpcr')
)
);
}
}
}
Loading