Important

You are browsing the upcoming documentation for version 5.1 of OroCommerce, OroCRM and OroPlatform, which is scheduled to be released on March 2023. Read version 5.0 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

OroCommentBundle

OroCommentBundle adds the Comments functionality which can be used with the application entities.

Enable Comments for an Entity

Usually, you do not need to provide a predefined set of associations between the comment entity and activity entities; rather, it is the administrator who chooses to do this. But it is possible to create this type of association using migrations if you need. The following example shows how you can do it:

namespace Acme\Bundle\DemoBundle\Migrations\Schema\v1_5;

use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\CommentBundle\Migration\Extension\CommentExtension;
use Oro\Bundle\CommentBundle\Migration\Extension\CommentExtensionAwareInterface;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

class AddCommentAssociation  implements Migration, CommentExtensionAwareInterface
{
    protected CommentExtension $commentExtension;

    /**
     * @inheritDoc
     */
    public function setCommentExtension(CommentExtension $commentExtension): void
    {
        $this->commentExtension = $commentExtension;
    }

    /**
     * @inheritDoc
     */
    public function up(Schema $schema, QueryBag $queries)
    {
        self::addComment($schema, $this->comment);
    }

    /**
     * @param Schema $schema
     * @param CommentExtension $commentExtension
     * @return void
     */
    public static function addComment(Schema $schema, CommentExtension $commentExtension): void
    {
        $commentExtension->addCommentAssociation($schema, 'acme_demo_entity');
    }
}

CommentExtension performs the association of the activity entity with comment. To get CommentExtension in migration, implement CommentExtensionAwareInterface.

Show Entity Comments in Activity List Widget

If you created the new activity entity and want to comment on it in the activity list widget, implement CommentProviderInterface. For example:

namespace Acme\Bundle\DemoBundle\Provider;

// ...
use Oro\Bundle\ActivityListBundle\Model\ActivityListProviderInterface;
use Oro\Bundle\CommentBundle\Model\CommentProviderInterface;

class SomeActivityListProvider implements ActivityListProviderInterface, CommentProviderInterface
{
    // ...

    /**
     * @inheritDoc
     */
    public function isCommentsEnabled($entityClass)
    {
        return $this->configManager->hasConfig($entityClass)
            && $this->configManager->getEntityConfig('comment', $entityClass)->is('enabled');
    }
}

The comment widget will be rendered into `div.message .comment` node of the js/activityItemTemplate.html.twig template.

Attachment Configuration

MIME types of comment attachments can be configured at System > Configuration > System Configuration > General Setup > Upload settings > File Mime Types.

Maximum file size will be taken from System > Entity Management > Comment > Attachment Field > File Size.