Skip to content

Instantly share code, notes, and snippets.

@webdevilopers
webdevilopers / ContractController.php
Last active May 25, 2023 08:39
Inject Entity and Repository into Service with Symfony2
<?php
use Plusquam\Bundle\ContractBundle\Service\Invoice;
class ContractAdminController extends Controller
{
/**
* Invoice action
*
* @return Response
@webdevilopers
webdevilopers / empty_hours.sql
Last active October 9, 2015 08:18
Select night shift hours only of rows in a given range with SQL
/*
* date: 2015-07-10
* workStart: 22:00:00
* date_end: 2015-07-11
* workEnd: 07:00:00
*/
SELECT(
TIMEDIFF(
TIMESTAMP(
@webdevilopers
webdevilopers / app_dev.symfony.conf
Last active June 28, 2019 21:03
Symfony2 virtual host conf with SYMFONY_ENV for development on Ubuntu14
<VirtualHost *:80>
ServerName dev.symfony.com
DocumentRoot /var/www/symfony/web
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/symfony/web">
DirectoryIndex app_dev.php
AllowOverride None
<IfModule mod_rewrite.c>
@webdevilopers
webdevilopers / key_does_not_exist.php
Last active August 29, 2015 14:23
Sonata Admin Form Event PRE_SET_DATA creates loop in configureFormFields only valid on 3rd run
<?php
namespace Plusquam\Bundle\ContractBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
@webdevilopers
webdevilopers / RecentContractsBlockService.php
Last active June 3, 2021 08:34
Sonata Admin - Include custom block / list view in edit template
<?php
namespace Plusquam\Bundle\ContractBundle\Block;
use Sonata\BlockBundle\Block\BlockContextInterface;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\HttpFoundation\Response;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
@webdevilopers
webdevilopers / PersonAdmin.php
Last active August 5, 2018 03:28
(NOT) NULL doctrine_orm_callback filter with Sonata Admin
<?php
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\CoreBundle\Form\Type\BooleanType;
class PersonAdmin extends Admin
{
protected function configureDatagridFilters(DatagridMapper $filterMapper)
{
@webdevilopers
webdevilopers / Configurator.php
Last active August 29, 2015 14:23
Symfony2 Custom Form Field Type Label with Error rendered only first time
<?php
class Configuration
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
@webdevilopers
webdevilopers / Payroll.php
Created June 10, 2015 10:26
Doctrine Extensions MongoDB ODM ReferencesListener not calling preUpdate
<?php
namespace Plusquam\Bundle\TimekeepingBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Gedmo\Mapping\Annotation as Gedmo;
use Plusquam\Bundle\ContractBundle\Entity\Branch;
use Application\Sonata\UserBundle\Entity\User;
/**
@webdevilopers
webdevilopers / Configuration.php
Created June 4, 2015 21:09
Symfony Assert Callback violation not added to property
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use AppBundle\Value\Scope as ScopeValue;
/**
@webdevilopers
webdevilopers / Api.php
Last active March 22, 2016 09:48
Circular reference detected for service "doctrine.dbal.default_connection", path: "doctrine.dbal.default_connection".
<?php
namespace Acme\AppBundle\Service;
use Doctrine\ORM\EntityManager;
use GuzzleHttp\Exception\RequestException;
/**
* @todo Inject mailer
*/