PHP code example of netliva / symfony-commenter

1. Go to this page and download the library: Download netliva/symfony-commenter 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/ */

    

netliva / symfony-commenter example snippets


return [
    // ...
    Netliva\CommentBundle\NetlivaCommentBundle::class => ['all' => true],
];


namespace App\Entity;

// ...
use Netliva\CommentBundle\Entity\AuthorInterface;

/**
 * Staff
 */
class Users implements UserInterface, \Serializable, AuthorInterface
{
    // ...
	public function __toString ()
	{
		return $this->getName();
	}
    // ...
}

 

namespace App\EventListener;

use Doctrine\ORM\EntityManagerInterface;
use Netliva\CommentBundle\Event\NetlivaCommenterEvents;
use Netliva\CommentBundle\Event\UserImageEvent;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;

class CommentBoxUserImageSubscriber implements EventSubscriberInterface
{
    public function __construct () { }

    public static function getSubscribedEvents ()
    {
        return [
            NetlivaCommenterEvents::USER_IMAGE => 'getUserImage'
        ];
    }

    public function getUserImage (UserImageEvent $event)
    {
        // Kullanıcı mülküne ulaşın
        $user = $event->getAuthor();

        // kullanıcının profil fotoğrafının resmine ulaşın
        $imgPath = $user->getPhoto();

        if (!$imgPath || !file_exists($imgPath))
            return null;

        // fotoğrafın yolunu set edin, böylece gerekli yerlerde kullanıcı fotoğrafları gösterilir
        $event->setImage($imgPath);
    }

}

javascript
$(document).on("netliva:commenter:init", function(event, $comment_area, commenter){
    // $comment_area : Yorum alanı jQuery öğesi
    // commenter : Yorum aksiyonlarının yer aldığı javascript nesnesi 
});