This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // tested on http://sandbox.onlinephpfunctions.com/ | |
| class Section { | |
| public $id; | |
| } | |
| $a = new Section(); | |
| $a->id = 10; | |
| $aa = new Section(); | |
| $aa->id = 20; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| /** | |
| * Usage: FIELD(str,str1,str2,str3,...) | |
| * | |
| * FIELD returns the index (position) of str in the str1, str2, str3, ... list. | |
| * Returns 0 if str is not found. If all arguments to FIELD() are strings, all | |
| * arguments are compared as strings. If all arguments are numbers, they are | |
| * compared as numbers. Otherwise, the arguments are compared as double. | |
| * If str is NULL, the return value is 0 because NULL fails equality comparison | |
| * with any value. FIELD() is the complement of ELT(). (Taken from MySQL | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Create method "publicCriteria" that returns active criteria | |
| Create method "findAllActive" for listing | |
| Create method "findOneBySlugForDetail" for detail | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Let Symfony guess (translation must be defined in messages.[locale].yml | |
| $duree = $this->get('translator')->transChoice('There is one apple|There are %count% apples',$circuit->getDuree(),array('%count%'=>$circuit->getDuree())); | |
| // Specify intervals (']' '[' : include/exclude) | |
| $duree = $this->get('translator')->transChoice('{1} 1 jour|]1,Inf] %count% jours',$circuit->getDuree(),array('%count%'=>$circuit->getDuree())); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // UI Tooltips | |
| // Article.translation.introduction title attribute set inside FormType. | |
| // Parameters same as UnifikSystemBundle | |
| $('#cke_article_translation_introduction iframe').attr('title',$('#article_translation_introduction').attr('title')).tooltip({ | |
| position: { 'my': 'left+8 center', 'at': 'right center' }, | |
| show: { duration: 200 } | |
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | $source->manipulateRow(function ($row) { | |
| // ArticlesTranslation's Comments count | |
| $row->setField('comments_count', $row->getEntity()->getComments()->count()); | |
| return $row; | |
| }); | |
| $grid->addColumn(new NumberColumn(['id' => 'comments_count', 'field' => 'comments_count', 'title' => 'Comments', 'source' => false, 'filterable'=>false, 'sortable'=>false]), 3); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public function addQueryTranslationSupport(QueryBuilder $query, $source, $locale, $resetJoin = false) | |
| { | |
| if ($resetJoin) { | |
| $query->resetDQLPart('join'); | |
| } | |
| $query->andWhere('_translations.locale is null or _translations.locale = :locale'); | |
| $query->setParameter('locale', $locale); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Bind sfWidgetFormDate year change | |
| // A partir de la valeur year de date_debut, changer la valeur year de date_fin | |
| // @author SGL | |
| function bindSfWidgetFormDateDebutYearChange(input_id) { | |
| $(input_id).change(function() { | |
| // Avec sfWidgetFormDate, la meme classe est applique au tous les widgets (year/month/day) | |
| // Si widget est year | |
| if (input_id.match(/_year$/)) { | |
| var output_id = input_id.replace('_date_debut_','_date_fin_'); | |
| // Ne pas changer la date si elle a deja ete selectionee | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Verifier si date_fin est superieur a date_debut | |
| // date_fin est optionnel | |
| $this->validatorSchema->setPostValidator(new sfValidatorOr(array( | |
| new sfValidatorAnd( array ( | |
| new sfValidatorSchemaCompare ('date_debut', sfValidatorSchemaCompare::NOT_EQUAL, null), | |
| new sfValidatorSchemaCompare ('date_fin', sfValidatorSchemaCompare::EQUAL, null) | |
| )), | |
| new sfValidatorSchemaCompare('date_fin', sfValidatorSchemaCompare::GREATER_THAN_EQUAL, 'date_debut',array('throw_global_error' => false), array('invalid' => 'La date de fin "%left_field%" doit être supérieure à la date de début "%right_field%".' )) | |
| ))); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | $this->setValidators(array( | |
| 'no_candidate' => new sfValidatorAnd(array( | |
| new sfValidatorString(array('required' => true, 'trim'=>true),array('required'=>"Veuillez entrer votre numéro de candidat ou votre code permanent.")), | |
| new sfValidatorOr(array( | |
| new sfValidatorRegex(array('pattern' => '/^[0-9]+$/', 'trim'=>true),array()), | |
| new sfValidatorRegex(array('pattern' => '/^[a-zA-Z]{4}[0-9]{8}+$/', 'trim'=>true),array()) | |
| ),array(),array('invalid'=>'Numéro de candidat ou code permanent invalide.')) | |
| ),array('halt_on_error'=>true),array('required'=>"Veuillez entrer votre numéro de candidat ou votre code permanent.")), | |
| // ... |