Skip to content

Instantly share code, notes, and snippets.

View rande's full-sized avatar
🖖
hello!

Thomas rande

🖖
hello!
View GitHub Profile
static protected $zendLoaded = false;
public function registerZend()
{
if (!self::$zendLoaded)
{
return;
}
@rande
rande / gist:443693
Created June 18, 2010 14:26
automatically redirect a user when a csrf token is detected
$this->dispatcher->connect('form.validation_error', function(sfEvent $event) {
$form = $event->getSubject();
$error = $event['error'];
if(!$form->isCSRFProtected())
{
return;
}
$field_name = sfForm::getCSRFFieldName();
@rande
rande / gist:509720
Created August 5, 2010 13:19
Create cache from a files containing url (multi-threaded python script)
import threading, time, urllib
import fileinput, io
class UrlDownloadThread ( threading.Thread ):
def __init__(self, url):
self.url = url
threading.Thread.__init__(self)
def run(self):
<?php
class myModelForm extends BaseModelForm
{
public function saveEmbeddedForms($con = null, $forms = null)
{
// nop, don't trust this
}
public function processUploadedFile($field, $filename = null, $values = null)
$connection = Doctrine::getTable('sfGuardUser')->getConnection();
$sqls = array(
"INSERT INTO `application_item` (`object_id`,`object_class`,`application_id`) VALUES ('1','MappableObject','4');",
"INSERT INTO `application_item` (`object_id`,`object_class`,`application_id`) VALUES ('2','MappableObject','4');",
"INSERT INTO `application_item` (`object_id`,`object_class`,`application_id`) VALUES ('3','MappableObject','4');",
"INSERT INTO `application_item` (`object_id`,`object_class`,`application_id`) VALUES ('4','MappableObject','4');",
);
array_map(function($sql) use ($connection) {
@rande
rande / custom targetEntity
Created November 3, 2010 22:24
custom targetEntity
<?php
namespace Sonata\Bundle\BlogBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Doctrine\Common\EventSubscriber;
class BlogBundle extends Bundle implements EventSubscriber
{
news_application:
type: xml
dir: %kernel.root_dir%/../src/Application/NewsBundle/Resources/config/doctrine/metadata/orm
prefix: Application\NewsBundle\Entity
alias: DExt
news_bundle:
type: xml
dir: %kernel.root_dir%/../src/Bundle/NewsBundle/Resources/config/doctrine/metadata/orm
prefix: Bundle\NewsBundle\Entity
<?php
/*
* This file is part of the Sonata package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
if($description['edit'] == 'inline') {
$target_object = $description['reflection']->getValue($object);
if(!$target_object) {
$target_object = $description['configuration']->getNewInstance();
}
$target_fields = $description['configuration']->getFormFields();
$target_form = $description['configuration']->getForm($target_object, $target_fields);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/FileLocator.php b/src/Symfony/Bundle/FrameworkBundle/Routing/FileLocator
index 49b69f2..698e17d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Routing/FileLocator.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Routing/FileLocator.php
@@ -42,7 +42,8 @@ class FileLocator extends BaseFileLocator
public function locate($file)
{
if ('@' === $file[0]) {
- return $this->kernel->locateResource($file);
+ $ressources = $this->kernel->locateResource($file, null, false);