This is a Symfony Bundle compatible with Symfony 2.6+ which provides several features which are commonly required in Symfony projects.
"sideclick/core-bundle": "dev-master"
Enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Sideclick\CoreBundle\SideclickCoreBundle(),
);
}
This Bundle requires that other bundles be installed and configured, these are:
- https://github.com/dustin10/VichUploaderBundle
- https://github.com/FriendsOfSymfony/FOSMessageBundle (Note that when installing this, you do not need to perform the steps named "Step 2 - Setting up your user class" and "Step 3 - Set up FOSMessageBundle's models", this has already been done in the ScCoreBundle
When configuring FOSMessageBundle, start with this:
fos_message:
db_driver: orm
thread_class: Sc\CoreBundle\Entity\Thread
message_class: Sc\CoreBundle\Entity\Message
You will need to install and configure these before being able to use this Bundle.
Entity helper classes should be defined in the /Entity/Helper directory, here is the basic structure of an Entity Helper class for an entity named 'User':
<?php
//Sideclick\CoreBundle\Entity\Helper\UserHelper.php
namespace Sideclick\CoreBundle\Entity\Helper;
use Sideclick\CoreBundle\Entity\Helper\HelperAbstract;
use Sideclick\CoreBundle\Entity\User;
class UserHelper extends HelperAbstract
{
protected $_user;
public function setUser(User $user)
{
$this->_user = $user;
}
}
There is a service named sc_core.entity_helper_factory which makes it easy to get an instance of an Entity Helper for an object, for example, in your controller you could do:
$userHelper = $this->get('sc_core.entity_helper_factory')->getEntityHelper($user);
Also, there is a twig function to get a helper in your templates:
get_entity_helper(user)
More documentation to come...