PHP code example of edumedia / comment-bundle

1. Go to this page and download the library: Download edumedia/comment-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

edumedia / comment-bundle example snippets



// src/Entity/Comment.php



namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use eduMedia\CommentBundle\Entity\CommentInterface;
use eduMedia\CommentBundle\Entity\CommentTrait;
use Symfony\Component\Security\Core\User\UserInterface;

#[ORM\Entity]
#[ORM\Table]
class Comment implements CommentInterface
{
    use CommentTrait;

    #[ORM\ManyToOne(targetEntity: User::class)]
    private ?UserInterface $author = null;
}


// src/Entity/User

namespace App\Entity;

use eduMedia\CommentBundle\Entity\CommentableInterface;
use eduMedia\CommentBundle\Entity\CommentableTrait;

class User implements /* (...) */ CommentableInterface
{

    use CommentableTrait;
    
    // (...)
}


// src/Controller/Admin/UserCrudController.php

namespace App\Controller\Admin;

use App\Entity\User;
// (...)

class UserCrudController extends AbstractCrudController
{
    public function configureCrud(Crud $crud): Crud
    {
        return $crud->overrideTemplate('crud/edit', 'admin/user/edit.html.twig');
    }
}