maesbox / common-bundle
Bundle for common functions
1.1.0
2017-01-25 14:16 UTC
Requires
- php: >=5.3.9
- doctrine/doctrine-bundle: ~1.4
- doctrine/orm: >=2.4
- guzzlehttp/guzzle: >=5.0
- jms/security-extra-bundle: >=1.0
- jms/serializer-bundle: >=1.0
- knplabs/knp-paginator-bundle: ^2.0
- stof/doctrine-extensions-bundle: >=1.0
- symfony/symfony: >=2.8
This package is auto-updated.
Last update: 2024-12-17 10:21:16 UTC
README
installation
composer
composer require maesbox/commonbundle
kernel
add these lines to app/AppKernel.php
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
//...
new Sonata\SeoBundle\SonataSeoBundle(),
new Symfony\Cmf\Bundle\SeoBundle\CmfSeoBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
//...
new Maesbox\CommonBundle\MaesboxCommonBundle(),
//...
);
}
//...
}
configuration
MaesboxCommonBundle
doctrine:
orm:
entity_managers:
default:
dql:
datetime_functions:
#date: YourApp\YourBundle\DQL\Date
#hour: YourApp\YourBundle\DQL\Hour
month: Maesbox\CommonBundle\Model\DQL\Month
year: Maesbox\CommonBundle\Model\DQL\Year
StofDoctrineExtensionsBundle
doctrine:
orm:
entity_managers:
default:
mappings:
gedmo_translatable:
type: annotation
prefix: Gedmo\Translatable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
alias: GedmoTranslatable
is_bundle: false
gedmo_translator:
type: annotation
prefix: Gedmo\Translator\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
alias: GedmoTranslator
is_bundle: false
gedmo_loggable:
type: annotation
prefix: Gedmo\Loggable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
alias: GedmoLoggable
is_bundle: false
gedmo_tree:
type: annotation
prefix: Gedmo\Tree\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
alias: GedmoTree
is_bundle: false
for more advanced options, refer to bundle docs:
features
controller
<?php
use Maesbox\CommonBundle\Model\BaseClass\BaseController;
class AppController extends BaseController
{
}
provides several methods:
- getSession
- getSerializer
- getParameter
- getEventDispatcher
- getManager
- getBaseManager
- getRepository
- getSecurity
- getCurrentUser
- getTranslator
entity manager
- firstly your manager must extend
Maesbox\CommonBundle\Model\BaseClass\BaseManager
<?php
use Maesbox\CommonBundle\Model\BaseClass\BaseManager;
class AppManager extends BaseManager
{
}
- secondly you have to annotate the reposiotry methods you want to expose
<?php
use Doctrine\ORM\EntityRepository;
use Maesbox\CommonBundle\Model\Annotation\SingleResultQuery;
use Maesbox\CommonBundle\Model\Annotation\SingleScalarResultQuery;
use Maesbox\CommonBundle\Model\Annotation\ListResultQuery;
use Maesbox\CommonBundle\Model\Annotation\ListScalarResultQuery;
class AppRepository extends EntityRepository
{
/**
* @SingleResultQuery
*/
public function getSingleResultQuery($params){
return $this->createQueryBuilder("a");
}
/**
* @SingleScalarResultQuery
*/
public function getSingleScalarResultQuery($params){
return $this->createQueryBuilder("a");
}
/**
* @ListResultQuery
*/
public function getListResultQuery($params){
return $this->createQueryBuilder("a");
}
/**
* @ScalarListResultQuery
*/
public function getScalarListResultQuery($params){
return $this->createQueryBuilder("a");
}
}
listener
console listener
logs console errors :)