Timeline/EventSubscriber/PostTimelineSubscriber.php
public function createPostTimelineEntry(EntityPublishedEvent $event): void
    {
        // Only act on post objects.
        $post = $event->getObject();
        if (!$post instanceof Post) {
            return;
        }

        // Get the author for the post.
        $author = $this->user_provider->loadUserByUsername($post->getAuthor());

        // Create components for this action.
        $post_component = $this->action_manager->findOrCreateComponent($post);
        $author_component = $this->action_manager->findOrCreateComponent($author);

        // Add timeline entries for each group.
        foreach ($post->getGroups() as $group) {
            // Create the group component.
            $group_component = $this->action_manager->findOrCreateComponent($group);

            // Either a new post was created or a reply was created.
            if (null === $post->getParent()) {
                $verb = 'post';
            } else {
                $verb = 'reply';
            }

            // Create the action and link it.
            $action = $this->action_manager->create($author_component, $verb, [
                'directComplement' => $post_component,
                'indirectComplement' => $group_component,
            ]);

            // Update the action.
            $this->action_manager->updateAction($action);
        }
    }
public function createPostTimelineEntry(EntityPublishedEvent $event): void
    {
        // Only act on post objects.
        $post = $event->getObject();
        if (!$post instanceof Post) {
            return;
        }

        // Get the author for the post.
        $author = $this->user_provider->loadUserByUsername($post->getAuthor());

        // Create components for this action.
        $post_component = $this->action_manager->findOrCreateComponent($post);
        $author_component = $this->action_manager->findOrCreateComponent($author);

        // Add timeline entries for each group.
        foreach ($post->getGroups() as $group) {
            // Create the group component.
            $group_component = $this->action_manager->findOrCreateComponent($group);

            // Either a new post was created or a reply was created.
            if (null === $post->getParent()) {
                $verb = 'post';
            } else {
                $verb = 'reply';
            }

            // Create the action and link it.
            $action = $this->action_manager->create($author_component, $verb, [
                'directComplement' => $post_component,
                'indirectComplement' => $group_component,
            ]);

            // Update the action.
            $this->action_manager->updateAction($action);
        }
    }
Create the timeline entry for the new post.

@param EntityPublishedEvent $event The entity published event.

@return void