bluebear/basebundle

This package is abandoned and no longer maintained. The author suggests using the lag/adminbundle package instead.

Base bundle for Symfony2

Installs: 2 477

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 7

Forks: 0

Open Issues: 0

Type:symfony-bundle

0.2.3 2016-01-30 18:30 UTC

This package is auto-updated.

Last update: 2022-02-01 12:45:17 UTC


README

BaseBundle for Symfony2 projects. This bundle contains some shortcuts and code snippets to ease Symfony2 projects developpment.

Installation

php composer.phar require bluebear/basebundle

Getting started

BaseBundle offers some features to help you :

ControllerTrait

<?php
...
use BlueBear\BaseBundle\Behavior\ControllerTrait;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class MyController extends Controller {
    use ControllerTrait;
    
    ...

Your controller should have following methods (those methods are native in Symfony Controller):

public function createNotFoundException($message = 'Not Found', Exception $previous = null)
public function generateUrl($route, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) 

ControllerTrait has following methods :

  • forward404Unless($condition, $message = '404 Not Found') : Forward current request to a 404 page if $condition is false
  • redirect($url, $status = 302) : Redirect to an url or a route (for route use "@my_route")
  • setMessage($message, $type = 'info', $parameters = []) : Add a flash message with a type and translations parameters
  • getConfig($key) : Return configuration key $key from container parameters
  • getRouting() : Return router service
  • getTranslator() : Return translator service
  • getSession() : Return session service
  • getEventDispatcher() : Return event dispatcher service
  • getEntityManager() : Return entity manager service
  • translate($string, $parameters = []) : Return entity manager service

ContainerTrait

ContainerTrait has following methods :

  • getContainer() : Return Container service
  • setContainer() : Set Container service

EntityManagerTrait

EntityManagerTrait has following methods :

  • getEntityManager() : Return EntityManager service
  • setEntityManager() : Set EntityManager service

ManagerTrait

...