Development

Changeset 8372

You must first sign up to be able to contribute.

Changeset 8372

Show
Ignore:
Timestamp:
04/09/08 15:32:39 (5 months ago)
Author:
fabien
Message:

added an optional second argument to slot() for simple slots

The most obvious example is when you define a slot for the page title.
Before, you had to type something like this:

<?php slot('title') ?>The title<?php end_slot() ?>

Now, you can just type:

<?php slot('title', 'The title') ?>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/helper/PartialHelper.php

    r8343 r8372  
    187187 * 
    188188 * @param  string slot name 
     189 * @param  string The slot content 
    189190 * 
    190191 * @see    end_slot 
    191192 */ 
    192 function slot($name
     193function slot($name, $value = null
    193194{ 
    194195  $context = sfContext::getInstance(); 
     
    201202  } 
    202203 
     204  if (sfConfig::get('sf_logging_enabled')) 
     205  { 
     206    $context->getEventDispatcher()->notify(new sfEvent(null, 'application.log', array(sprintf('Set slot "%s"', $name)))); 
     207  } 
     208 
     209  if (!is_null($value)) 
     210  { 
     211    $response->setSlot($name, $value); 
     212 
     213    return; 
     214  } 
     215 
    203216  $slot_names[] = $name; 
    204217 
    205218  $response->setSlot($name, ''); 
    206219  sfConfig::set('symfony.view.slot_names', $slot_names); 
    207  
    208   if (sfConfig::get('sf_logging_enabled')) 
    209   { 
    210     $context->getEventDispatcher()->notify(new sfEvent(null, 'application.log', array(sprintf('Set slot "%s"', $name)))); 
    211   } 
    212220 
    213221  ob_start();