/** * Update page color. * * <b>Request Type: </b>PUT<br/> * <b>Request Endpoint: </b>http://{server-domain}/api/microsite/page/color/{id} * <b>Summary: </b>This api is for update page color * * <b>Request Params</b>:<br/> * color: string<br/> * <br/><br/> * * <b>Response Example: </b> * <pre> * { * "message" : "OK" * } * </pre> */ public function actionColor($id) { $pageId = new \MongoId($id); $page = Page::findByPk($pageId); $color = $this->getParams('color'); if (empty($color)) { throw new BadRequestHttpException('Missing color'); } $page->color = $color; if ($page->save(true, ['color'])) { PageComponent::updateAll(['$set' => ['color' => $color]], ['pageId' => $pageId]); } else { throw new ServerErrorHttpException('update fail'); } return ['message' => 'ok']; }
private function _updateOrder($condition, $inc, $pageId, $tabId = null, $tabIndex = null) { if (empty($tabId)) { PageComponent::updateAll(['$inc' => ['order' => $inc]], array_merge($condition, ['parentId' => $pageId])); } else { PageComponent::updateAll(['$inc' => ['order' => $inc]], array_merge($condition, ['parentId' => new \MongoId($tabId), 'tabIndex' => $tabIndex])); } }