Skip to content

Instantly share code, notes, and snippets.

Avatar
🐼
Yay

Ludovic Fleury ludofleury

🐼
Yay
View GitHub Profile
View UnitOfWork.php
<?php
/*
* $Id: UnitOfWork.php 7684 2010-08-24 16:34:16Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
@ludofleury
ludofleury / FileRelation.class.php
Created Dec 18, 2010
lib/model/doctrine/FileRelation.class.php Relational model between object model and file model Implement LooseCoupling doctrine behavior concept from Christian Schaefer.
View FileRelation.class.php
<?php
/**
* FileRelation
*
*
* @package shop
* @subpackage model
* @author Christian Schaefer <caefer@ical.ly>
* @author Ludovic Fleury <ludovic.fleury@w3brothers.com>
@ludofleury
ludofleury / _ajax_list.php
Created Dec 18, 2010
The routing rules for the backend module file_relation
View _ajax_list.php
<?php
# Partial called by other admin-gen module like :
# include_partial('file_relation/ajax_list',array('object_type'=> 'product', 'object_id' => $product->getId(), 'file_type'=>'image'))
?>
<fieldset id="sf_fieldset_file_relation_<?php echo $file_type ?>">
<h2><?php echo ucfirst($file_type) ?></h2>
<div id="file_relation_<?php echo $file_type ?>" class="file_relation"></div>
</fieldset>
@ludofleury
ludofleury / Fixtures.yml
Created Dec 21, 2010
Symfony Doctrine : How to have multiple hierarchical data in 1 table but with the logic splitted into X models.
View Fixtures.yml
Category:
collection_0:
name: Collection
root_id: 1
children:
collection_1:
name: Spring 2010
summary:
collection_2:
name: Summer 2010
@ludofleury
ludofleury / Admin gen on multiple primary keys Model.
Created Jan 30, 2011
Ever dream to use admin-gen (symfony 1.4 + Doctrine 1.2) with a Model using composite primary keys ? Fast & furious tips for the routing :
View Admin gen on multiple primary keys Model.
app/routing.yml
In this example, my Model is identified by A string + an id.
That's why I specified requirements.
attached_file:
class: sfDoctrineRouteCollection
options:
model: AttachedFile
module: attachment
prefix_path: /attachment
View gist:828193
// Ouvre le premier lien enfant de l'élément cible
// Reproduit le comportement des navigateurs (ctrl ou cmd ou middleclick = nouvel onglet)
$('.line-click').live('click', function(e){
e.stopPropagation();
href = $(this).children('a:first').attr('href');
if (e.ctrlKey || e.metaKey || e.which == 2) {
window.open(href);
} else {
window.location = href;
}
@ludofleury
ludofleury / sdzDoctrineGenerateMigrationsDiffTask.php
Created Mar 22, 2011
Custom migrations using schema.yml revision.
View sdzDoctrineGenerateMigrationsDiffTask.php
<?php
class sdzDoctrineGenerateMigrationsDiffTask extends sfDoctrineBaseTask
{
/**
* @see sfTask
*/
protected function configure()
{
$this->addOptions(array(
@ludofleury
ludofleury / routing.yml
Created Jun 6, 2011
Use multiple routing files.
View routing.yml
## Default rules ===============================================================
homepage:
url: /
param:
module: home
action: index
sf_format: html
<?php foreach(glob(dirname(__FILE__).DIRECTORY_SEPARATOR.'routing'.DIRECTORY_SEPARATOR.'*.yml') as $yml){ require($yml); echo "\n"; } ?>
View gist:1291222
When I add this gem into my app Gemfile : gem 'mongoid', '~> 2.3.2.
I'm unable to run any "rails g" command, it cause this stack trace :
/MY_PATH/vendor/bundle/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `values' for nil:NilClass (NoMethodError)
from /server/poker/vendor/bundle/ruby/1.9.1/gems/mongoid-2.3.2/lib/mongoid/railtie.rb:64:in `block in <class:Railtie>'
from /server/poker/vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
from /server/poker/vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
from /server/poker/vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
from /server/poker/vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
from /server/poker/vendor/bundle/ruby/1.9.1/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
View gist:1316502
// Exercice Tableaux
//
// Ajouter une variable de type Tableau (tabInventaire) qui contient ces valeurs dans l'ordre que vous voulez :
"epee";
"dague";
"fronde";
"arc";
"bombe";
"fleche";
"potion";
You can’t perform that action at this time.