cunningsoft / message-bundle
A user-to-user message bundle for Symfony2
Installs: 70
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 2
Type:symfony-bundle
pkg:composer/cunningsoft/message-bundle
Requires
- doctrine/orm: >=2.2.0
- knplabs/knp-time-bundle: ~1.1
- symfony/symfony: ~2.3
This package is auto-updated.
Last update: 2025-10-12 11:52:27 UTC
README
- 
Add the following to your composer.jsonfile:// composer.json { // ... require: { // ... "cunningsoft/message-bundle": "0.1.*" } } 
- 
Run composer update cunningsoft/message-bundleto install the new dependencies.
- 
Register the new bundle in your AppKernel.php:<?php // in AppKernel::registerBundles() $bundles = array( // ... new Cunningsoft\MessageBundle\CunningsoftMessageBundle(), // ... ); 
- 
Let your user entity implement the Cunningsoft\MessageBundle\Entity\UserInterface:// Acme\ProjectBundle\Entity\User.php <?php namespace Acme\ProjectBundle\Entity; use Cunningsoft\MessageBundle\Entity\UserInterface as MessageUserInterface; class User implements MessageUserInterface { /** * @var int */ protected $id; /** * @var string */ protected $username; /** * @return int */ public function getId() { return $this->id; } /** * @return string */ public function getUsername() { return $this->username; } // ... 
- 
Map the interface to your user entity in your config.yml:// app/config/config.yml // ... doctrine: orm: resolve_target_entities: Cunningsoft\MessageBundle\Entity\UserInterface: Acme\ProjectBundle\Entity\User 
- 
Update your database schema: $ app/console doctrine:schema:update 
- 
Import routes: // app/config/routing.yml // ... cunningsoft_message_bundle: resource: "@CunningsoftMessageBundle/Controller" type: annotation 
- 
Link to the messages list: // src/Acme/ProjectBundle/Resources/views/Default/index.html.twig // ... <a href="{{ path('cunningsoft_message_list') }}">messages</a> // ... 
- 
Create a child bundle to fetch users mkdir src/Acme/MessageBundle// src/Acme/MessageBundle/AcmeMessageBundle.php <?php namespace Acme\MessageBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class AcmeMessageBundle extends Bundle { public function getParent() { return 'CunningsoftMessageBundle'; } } // src/Acme/MessageBundle/Controller/MessageController.php <?php namespace Acme\MessageBundle\Controller; use Cunningsoft\MessageBundle\Controller\MessageController as BaseController; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; /** * @Route("/message") */ class MessageController extends BaseController { public function findUser($id) { return $this->get('doctrine.orm.entity_manager')->getRepository('AcmeProjectBundle:User')->find($id); } public function findAllUsers() { return $this->get('doctrine.orm.entity_manager')->getRepository('AcmeProjectBundle:User')->findAll(); } } 
Changelog
- 0.1 (master) First working version.