コード例 #1
0
ファイル: Node.php プロジェクト: BGCX261/zibo-svn-to-git
 /**
  * Delete a widget from a region
  * @param string $region name of the region
  * @param int $id id of the widget to delete
  * @return null
  * @throws zibo\ZiboException when the NodeSettings are not set to this node
  * @throws zibo\ZiboException when a widget could not be found
  */
 public function deleteWidget($region, $id)
 {
     $this->checkSettings();
     $widgetsKey = NodeSettingModel::SETTING_WIDGETS . '.' . $region;
     $widgetsValue = $this->settings->get($widgetsKey);
     $widgetIds = explode(',', $widgetsValue);
     $widgetsValue = '';
     $foundWidget = false;
     foreach ($widgetIds as $widgetId) {
         if ($id == $widgetId) {
             $foundWidget = true;
             continue;
         }
         $widgetsValue .= ($widgetsValue ? NodeSettingModel::WIDGETS_SEPARATOR : '') . $widgetId;
     }
     if (!$foundWidget) {
         throw new ZiboException('Could not find the widget with id ' . $id);
     }
     $this->settings = new WidgetSettings($id, $this->settings);
     $this->settings->clearWidgetProperties();
     $this->settings->set($widgetsKey, $widgetsValue);
 }