Skip to content

Instantly share code, notes, and snippets.

View wowo's full-sized avatar

Wojciech Sznapka wowo

View GitHub Profile
@wowo
wowo / gist:1331766
Created November 1, 2011 20:12
deps file for Symfony2 and Mockery
[Mockery]
git=https://github.com/padraic/mockery.git
target=mockery
<?php
namespace Wowo\Bundle\NewsletterBundle\Tests\Newsletter;
use lapistano\ProxyObject\ProxyObject;
class NewsletterManagerTest extends \PHPUnit_Framework_TestCase
{
public function testBuildBody()
{
$proxy = new ProxyObject();
$ ./bin/vendors update
[Proxy-Object]
git=https://github.com/lapistano/proxy-object.git
target=/proxy-object
<?php
// [...]
$loader->registerNamespaces(array(
// [...]
'lapistano' => __DIR__.'/../vendor/proxy-object/src/lapistano',
));
// [...]
// this one's important! you need it only with PHPUnit, so there's a condition
if (class_exists('PHPUnit_Runner_Version')) {
<?php
class MailingType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
//this is ain't documented but it works! :-)
$builder
->add('body', 'textarea',
array('attr' => array('class' => 'tinymce')));
}
{% form_theme form _self %}
{% block _wowo_bundle_newsletterbundle_newslettertype_mailing_body_widget %}
{{ form_widget(form, { 'attr': {'class': 'tinymce'}}) }}
{% endblock %}
<form action="" method="post" {{ form_enctype(form) }} >
{{ form_widget(form) }}
<input type="submit" value="{% trans %}Send mailing{% endtrans %}"/>
</form>
<?php
class MailingType extends AbstractType
{
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('body', 'textarea', array('class' => 'tinymce')); // it won't work!
}
}
@wowo
wowo / closureHandlling.php
Created September 26, 2011 22:29
Closure wrapper handling
<?php
class NewsletterManager implements NewsletterManagerInterface
{
public function getJobFromQueueAndSendMailing(\Closure $logger, $verbose)
{
// [...]
if ($verbose) {
$logger(sprintf("Sent message:\n%s", $message->toString()));
}
}
@wowo
wowo / OriginCall.php
Created September 26, 2011 22:25
Closure logger from Symfony2 command
<?php
class SendMailingCommand extends ContainerAwareCommand
{
protected function execute(InputInterface $input, OutputInterface $output)
{
$logger = function($message) use ($output)
{
$output->writeln($message);
};