1

I installed all the Bundles of Sonata following the documentation step by step. I still have few errors to fix on some actions such as deleting images. All the errors i'm facing right now seem related.

I submited two issues, one SonataMediaBundle and one in SonataClassificationBundle.

Attempted to call method "ifTrue" on class "Sonata\AdminBundle\Form\FormMapper". in vendor/sonata-project/classification-bundle/Admin/ContextAdmin.php at line 27

When i'm trying to access the route "/classification/context/create" or "../edit".

protected function configureFormFields(FormMapper $formMapper)
{
    $formMapper
        ->ifTrue($this->getSubject()->getId() === null)
        ->add('id')
        ->ifEnd()
        ->add('name')

1 - DEBUG - Router Sonata\PageBundle\Route\CmsPageRouter was not able to match, message "No site defined"

"No site defined" makes me guess i should do something on that. I did create a default page with the SonataPageBundle (added in database). I don't know if there is a specific parameter to add in the config. As i said i followed the documentation step by step and i don't see anything related to defining a site. However i'm not sure "no site defined" is related to the main error.

Here my composer.json in case it could be usefull.

"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.6.",
    "doctrine/orm": "~2.2,>=2.2.3",
    "doctrine/doctrine-bundle": "~1.2",
    "twig/extensions": "~1.0",
    "symfony/assetic-bundle": "~2.3",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~3.0.12",
    "sensio/framework-extra-bundle": "~3.0",
    "incenteev/composer-parameter-handler": "~2.0",
    "sonata-project/core-bundle": "~2.2@dev",
    "sonata-project/notification-bundle": "~2.3",
    "knplabs/knp-markdown-bundle": "~1.2",
    "videlalvaro/php-amqplib": "~2.4",
    "liip/monitor-bundle": "~2.0",
    "symfony-cmf/routing-bundle": "1.4.@dev",
    "jms/serializer-bundle": "0.13.*@dev",
    "sonata-project/formatter-bundle": "~2.3",
    "sonata-project/markitup-bundle": "~2.1",
    "sonata-project/intl-bundle": "~2.2",
    "sonata-project/cache-bundle": "~2.2",
    "sonata-project/seo-bundle": "~1.1",
    "sonata-project/easy-extends-bundle": "~2.1",
    "sonata-project/admin-bundle": "~2.3",
    "sonata-project/doctrine-orm-admin-bundle": "~2.3",
    "sonata-project/user-bundle": "~2.2",
    "sonata-project/classification-bundle": "dev-master",
    "sonata-project/news-bundle": "dev-master",
    "sonata-project/timeline-bundle": "~2.2@dev",
    "sonata-project/media-bundle": "~2.4@dev",
    "sonata-project/page-bundle": "~2.3@dev"
}

Any solutions or hints?

3 Answers 3

1

The method ifTrue or ifFalse are going to land in the 2.4 release of SonataAdminBundle. Please use stable version of bundles.

1
1

The method ifTrue doesn't exist in the class FormMapper : https://github.com/sonata-project/SonataAdminBundle/blob/2.3/Form/FormMapper.php.

I don't know where you find you could use it.

You should do this instead :

protected function configureFormFields(FormMapper $formMapper)
{
    if ($this->getSubject()->getId() === null) {
      $formMapper->add('id');
    } 
    $formMapper
         ->add('name')
}

Also I don't know why you want to define the id, it's supposed to be automatically set on create.

About your second error, the Exception comes from this class https://github.com/sonata-project/SonataPageBundle/blob/2.3.8/Route/CmsPageRouter.php#L158, i never used this bundle but my first guess is that you forgot to create a site :

php app/console sonata:page:create-site

More details explained in the documentation : http://sonata-project.org/bundles/page/master/doc/reference/getting_started.html

2
  • Okay apparently i'm not using the stable version so it is normal that ifTrue does not yet exist since it will be in the version 2.4 of sonata. For the second error i did create a page (php app/console sonata:page:create-site) and set it as default. That is why i'm getting really confuse about it since it didn't bring any changes. Thank you for the help.
    – Brieuc
    Feb 2, 2015 at 16:12
  • Second error has also been fixed with the stable versions of the bundles ;).
    – Brieuc
    Feb 2, 2015 at 16:37
1

[edit] Wrong comment see: https://github.com/sonata-project/SonataAdminBundle/pull/2664/files

The ifTrue and ifFalse method have been in the master branch for less than a month and are now removed. The code you refer does not seems to be updated.

In the futur, please use stable release or you might find some WIP bug.

1
  • 1
    Sorry I was wrong, the methods was named if_true and if_false, as they were not compliant with coding standard there are renamed to ifTrue and ifFalse
    – rande
    Feb 2, 2015 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.