Skip to content

Instantly share code, notes, and snippets.

View services.yml
services:
organization_bundle.listener.logos:
class: Gedmo\Uploadable\UploadableListener
arguments: [@stof_doctrine_extensions.uploadable.mime_type_guesser]
calls:
- [setAnnotationReader, ['@annotation_reader']]
- [setDefaultFileInfoClass, ['%stof_doctrine_extensions.uploadable.default_file_info.class%']]
- [setDefaultPath, ['%logo_directory%']]
View ChoiceFiller.php
<?php
/**
* Extract lookup table information from a database to be used in a select field.
* For example, a page can be published, rejected, or pending...
*
*/
namespace ICS\CoreBundle\Library;
View QuickExample.php
<?php
//Entity file
* @UniqueEntity(fields="email", message="Sorry, this email address is already in use.", groups={"registration"})
//Form file
public function configureOptions(OptionsResolver $resolver)
{
@Raistlfiren
Raistlfiren / Overview.php
Last active Jan 28, 2016
Doctrine Entity Listener
View Overview.php
services:
job_bundle.listener.job_listener:
class: JobBundle\Listener\JobListener
tags:
- { name: doctrine.orm.entity_listener }
orm:
default_entity_manager: ~
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
View AbstractControllerTest.php
<?php
namespace CoreBundle\Library;
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\Loader;
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\ORM\Tools\SchemaTool;
View JobType.php
<?php
namespace Test\Job\JobBundle\Form\Type;
use Test\Job\CompanyBundle\Form\Type\CompanyType;
use Test\CoreBundle\Form\Type\AddressType;
use Doctrine\Common\Persistence\ObjectManager;
use Test\Job\JobBundle\Form\Transformer\CompanyToIdTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
View Test.php
<?php
namespace Wolfe\Tests;
use PHPUnit_Framework_TestCase;
use Slim\App;
use Slim\Http\Environment;
use Slim\Http\Headers;
use Slim\Http\Request;
use Slim\Http\RequestBody;
View index.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Slim\Container;
use Slim\App;
use Slim\Views\Twig;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Wolfe\Loader\Kernel;
View functionalTest.php
<?php
$app = new App();
$app->post('/', function(ServerRequestInterface $request, ResponseInterface $response) {
//ERROR on functional test - Cannot modify header information - headers already sent by
$filename = filter_var($filename, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
header("Content-Disposition: attachment; filename=\"$filename\"");
View example.php
<?php
class Contact {
protected $maskEmail;
protected $email;
public function checkEmail()
{
if ($this->maskEmail){