. */ use Nethgui\System\PlatformInterface as Validate; /** * Manages profile * * Fires events * - profile-clean * - profile-gui-clean * - profile-lo-clean */ class Clean extends \Nethgui\Controller\Table\AbstractAction { public function __construct($identifier = NULL) { if ($identifier !== 'all' && $identifier !== 'gui' && $identifier !== 'libreoffice') { throw new \InvalidArgumentException(sprintf('%s: module identifier must be one of "all", "gui" or "libreoffice".', get_class($this)), 1325579395); } parent::__construct($identifier); } public function bind(\Nethgui\Controller\RequestInterface $request) { $this->declareParameter('username', Validate::USERNAME); parent::bind($request); $username = \Nethgui\array_end($request->getPath()); if ( ! $username) { throw new \Nethgui\Exception\HttpException('Not found', 404, 1322148400); } $this->parameters['username'] = $username; } public function process() { if ( ! $this->getRequest()->isMutation()) { return; } $event = "libreoffice"; // it is the less impacting. switch ($this->getIdentifier()) { case "all": $event = "profile-clean"; break; case "gui": $event = "profile-gui-clean"; break; case "libreoffice": $event = "profile-lo-clean"; break; } $this->getPlatform()->signalEvent(sprintf("%s@post", $event), array($this->parameters['username'])); } }