/** * Update an editable component * * @param sfRequest $request A request object */ public function executeUpdate(sfWebRequest $request) { $result = $error = ''; if (!$this->getUser()->hasCredential(sfConfig::get('app_sfDoctrineEditableComponentPlugin_admin_credential', 'editable_content_admin'))) { $this->getResponse()->setStatusCode(403); $error = 'Forbidden'; } else { if (!$request->hasParameter('id') || !$request->hasParameter('value')) { $error = 'Missing parameters'; } } // Dispatching of editable_component.filter_contents event $result = $this->dispatcher->filter(new sfEvent($this, 'editable_component.filter_contents', array('name' => $name = $request->getParameter('id'), 'type' => $type = $request->getParameter('type', PluginsfEditableComponentTable::DEFAULT_TYPE))), $request->getParameter('value'))->getReturnValue(); try { $component = sfEditableComponentTable::updateComponent($name, $result, $type); } catch (Doctrine_Exception $e) { $error = sprintf('Unable to update component "%s": %s', $name, $e->getMessage()); } // Dispatching of editable_component.updated event $this->dispatcher->notify(new sfEvent($component, 'editable_component.updated', array('view_cache' => $this->context->getViewCacheManager(), 'culture' => $this->getUser()->getCulture()))); return $this->renderResult($result, $error); }
/** * Shows a component * */ public function executeShow() { $this->componentCssClassName = sfConfig::get('app_sfDoctrineEditableComponentPlugin_component_css_class_name', 'sfEditableComponent'); $this->component = sfEditableComponentTable::getComponent($this->name, $this->type); }