FOSCommentBundle icon indicating copy to clipboard operation
FOSCommentBundle copied to clipboard

Compatible with easyadmin

Open acamilleri opened this issue 8 years ago • 7 comments

Hi, in my project i use FOSCommentBundle and EasyAdmin on SF2.8

Your method "isCommentable" in Model\Thread.php is not modify with easyadmin....

config.yml for easyadmin: My Class Article is extend of BaseThread

Article: 
            class: AppBundle\Entity\Article
            list: 
                fields:
                    - { property: 'id' } 
                    - { property: 'isCommentable'}

EasyAdmin return this error:

Neither the property "isCommentable" nor one of the methods "addIsCommentable()"/"removeIsCommentable()", "setIsCommentable()", "isCommentable()", "__set()" or "__call()" exist and have public access in class "AppBundle\Entity\Article".

The problem: line 58 in Model\ThreadInterface.php (replace setCommentable with setisCommentable) line 105 in Model\Thread.php (replace setCommentable with setisCommentable)

Do you have solution to bypass this error or override these model ?

Thank you Best regards, Alexis.

acamilleri avatar Apr 25 '16 12:04 acamilleri

same probleme for me and not only for isCommentable, i cannot access to other parameter like permalink or updateAt

NodokaMurmevent avatar Apr 28 '16 19:04 NodokaMurmevent

I've never used FOSCommentBundle, but according to its docs (See https://github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/Resources/doc/2a-mapping_orm.md) you must create your own Thread or Comment class. So maybe you can solve your problem defining this method in your own Thread class:

// src/MyProject/MyBundle/Entity/Thread.php

namespace MyProject\MyBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use FOS\CommentBundle\Entity\Thread as BaseThread;

/**
 * @ORM\Entity
 * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
 */
class Thread extends BaseThread
{
    // ...

    public function setIsCommentable($isCommentable)
    {
        $this->setCommentable($isCommentable);
    }
}

javiereguiluz avatar May 14 '16 14:05 javiereguiluz

tomorow i will try this.

NodokaMurmevent avatar May 14 '16 14:05 NodokaMurmevent

it's better, the toggle is_commentable work but when i use update function it's don't work.

i have absolutely no post request when i click on save.

NodokaMurmevent avatar May 15 '16 07:05 NodokaMurmevent

lol ok it's work but i need to erase this line *@ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT") on tread entity EDIT : i also need to override this :

    /**
     * @return string
     */
    public function getPermalink()
    {
        return "https://www.la-cave-a-nodo.fr/article/" . $this->slug;
    }

$this->slug is just :

use Gedmo\Mapping\Annotation as Gedmo;
[...]
    /**
     * @Gedmo\Slug(fields={"titre"},separator="-", updatable=true, unique=true)
     * @ORM\Column(length=128)
     */
    private $slug;

NodokaMurmevent avatar May 15 '16 07:05 NodokaMurmevent

I had exactly the same issue with EasyAdmin and FosComment. When removing @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT") the comments are saved. I'm a bit concern as I don't really understand this TrackingPolicy if it's here it should be a reason. @NodokaMurmevent have you noticed side effect by removing this ?

kaizokou avatar Jun 14 '16 17:06 kaizokou

yes a problem appared, test if when you update (NOT create a new) a post all modification work.

NodokaMurmevent avatar Jun 14 '16 20:06 NodokaMurmevent