Skip to content

Instantly share code, notes, and snippets.

View kriswallsmith's full-sized avatar

Kris Wallsmith kriswallsmith

  • Portland, Oregon USA
  • 18:59 (UTC -07:00)
View GitHub Profile
@kriswallsmith
kriswallsmith / UniversalFilter.php
Created August 20, 2011 15:05
A universal constructor for Assetic filters
<?php
use Assetic\Asset\AssetInterface;
use Assetic\Filter\FilterInterface;
class UniversalFilter implements FilterInterface
{
static private $factories = array();
@kriswallsmith
kriswallsmith / gist:1155296
Created August 18, 2011 21:34
CmsBlockNodeVisitor getBlockName
private function getBlockName(\Twig_NodeInterface $node, \Twig_Environment $env)
{
if ($node instanceof \Twig_Node_Expression_Function) {
if ('cms_block' == $node->getNode('name')->getAttribute('name')) {
}
}
}
@kriswallsmith
kriswallsmith / config.yml
Created May 7, 2011 23:51
Assetic - Less config
assetic:
filters:
less:
node: /usr/local/bin/node
node_paths: [ /usr/local/lib/node ]
@kriswallsmith
kriswallsmith / gist:940473
Created April 25, 2011 12:56
Should I map Assetic filters to Twig functions or filters?

Simple function call:

{{ pngout("images/logo.png") }}

Simple filter call:

{{ "images/logo.png"|pngout }}
<?php
/*
* This file is part of the Assetic package.
*
* (c) Kris Wallsmith <kris.wallsmith@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
<?php
/**
* @annot:ns("Doctrine\ODM\MongoDB\Mapping", {
* "validation"="Symfony\Component\Validator\Constraints"
* })
*
* @Document
*/
class Product
<?php
interface Configurable
{
static function getOptionsBag();
}
class Form implements Configurable
{
public function __construct($options = array())
<?php
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Factory\StaticFactory;
use Symfony\Component\DependencyInjection\Scope\ContainerScope;
use Symfony\Component\DependencyInjection\Scope\NestingContainerScope;
use Symfony\Component\DependencyInjection\Scope\Scope;
use Symfony\Component\DependencyInjection\ScopedContainer;
class Connection
<service id="swiftmailer.message" class="Swift_Message" factory-method="newInstance" shared="false">
<file>%swiftmailer.init_file%</file>
<argument>null</argument>
<argument>null</argument>
<argument>null</argument>
<argument>%kernel.charset%</argument>
<call method="setFrom">
<argument>noreply@example.com</argument>
</call>
</service>
<?php
class Tag
{
public function normalizeName($name)
{
$normal = trim($name);
$normal = strtolower($normal);
return $normal;