/** * Retrieves or creates an sfSympalContentSlot object with the given * name for this sfSympalContent object * * @return sfSympalContentSlot */ public function getOrCreateSlot($name, $options = array()) { if (!($hasSlot = $this->hasSlot($name))) { $isColumn = $this->hasField($name) ? true : false; // if type isn't specified, give it a type of Column or Text if (isset($options['type'])) { $type = $options['type']; } else { $type = $isColumn ? 'Column' : 'Text'; } if (!$isColumn && $type == 'Column') { throw new sfException('Cannot set a non-column slot to type "Column"'); } $slot = new sfSympalContentSlot(); $slot->setContentRenderedFor($this); $slot->is_column = $isColumn; $slot->name = $name; $slot->type = $type; if (isset($options['default_value'])) { $slot->value = $options['default_value']; } $slot->save(); $this->addSlot($slot); } else { $slot = $this->getSlot($name); } $slot->setContentRenderedFor($this); return $slot; }
public function getOrCreateSlot($name, $type = null, $renderFunction = null, $options = array()) { if (!($hasSlot = $this->hasSlot($name))) { $isColumn = $this->hasField($name) ? true : false; $type = $type ? $type : 'Text'; $slot = new sfSympalContentSlot(); $slot->is_column = $isColumn; if ($slot->is_column && is_null($renderFunction)) { $renderFunction = 'get_sympal_content_property'; } $slot->render_function = $renderFunction; $slot->name = $name; $slot->type = $type; if (isset($options['default_value'])) { $slot->value = $options['default_value']; } $slot->save(); $this->addSlot($slot); } else { $slot = $this->getSlot($name); } if ($type != null && $slot->type != $type) { $slot->type = $type; $slot->save(); } $slot->setContentRenderedFor($this); return $slot; }