protected function executeSave() { $redirect = $this->getRequestParameter('redirect'); $id = $this->getRequestParameter(); $m = $this->getRequestParameter('m', 'array', array()); try { $ex = ServiceManager::getInstance()->getByPk($id, true); $ex->addField('oldImage', 'string', $ex->image); $ex->updateFromRequest($m); if (!$ex->isValid()) { throw new EUserMessageError("Ошибка при сохранении", $ex); } if (!$ex->save()) { throw new EUserMessageError("Ошибка при сохранении", $ex); } $this->setFlash('Данные успешно сохранены', self::$FLASH_SUCCESS); $this->setHeader('redirect', fvSite::$fvConfig->get('dir_web_root') . $this->getRequest()->getRequestParameter('module') . ($redirect ? "" : "/edit/?id=" . $ex->getPk())); } catch (EUserMessageError $e) { $this->setFlash($e->getMessage(), self::$FLASH_ERROR); $this->setHeader('X-JSON', json_encode($e->getValidationResult())); } catch (EDatabaseError $db) { $this->setFlash($db->getMessage(), self::$FLASH_ERROR); } return $this->getRequest()->isXmlHttpRequest() ? self::$FV_AJAX_CALL : self::$FV_OK; }
function showEdit() { $id = $this->getRequestParameter(); $ex = ServiceManager::getInstance()->getByPk($id, true); $this->__assign("tmpDir", fvSite::$fvConfig->get("path.upload.web_temp_image")); $this->__assign("ex", $ex); $this->__assign("wt", range(-20, 20)); return $this->__display('edit.tpl'); }
public function getSvc($name, $id = null) { $svc = []; if (!is_null($id)) { $svc = ServiceManager::getInstance($id); } else { if (!is_null($name)) { $svc = ServiceManager::getInstanceByName($name); } } return $svc; }
function showIndex() { $infra = ServiceManager::getInstance()->getAll("is_show=1 and service_type=" . ServiceManager::ST_INFRA, "weight asc"); $compl = ServiceManager::getInstance()->getAll("is_show=1 and service_type=" . ServiceManager::ST_COMPL, "weight asc"); $deliv = ServiceManager::getInstance()->getAll("is_show=1 and service_type=" . ServiceManager::ST_DELIV, "weight asc"); $serv = ServiceManager::getInstance()->getAll("is_show=1 and service_type=" . ServiceManager::ST_SERV, "weight asc"); $this->__assign("infra", $infra); $this->__assign("compl", $compl); $this->__assign("serv", $serv); $this->__assign("deliv", $deliv); $this->__assign("manager", ServiceManager::getInstance()); return $this->__display("index.tpl"); }
public static function getInstanceByName($name) { $path = Yii::getPathOfAlias('root.assets.services.running.' . $name); $initPath = Yii::getPathOfAlias('root.assets.services.init'); if (is_dir($path)) { $instances = glob($path . DIRECTORY_SEPARATOR . "*"); foreach ($instances as $itc) { $id = str_replace($path, "", $itc); $svc = ServiceManager::getInstance($id); if (!is_null($svc)) { return $svc; } } } return null; }
public function actionView($name = null, $id = null, $l = 1) { $params = []; $options = []; if ($l == 0) { $options['layout'] = '//layouts/blank'; } if (!is_null($id)) { $params['svc'] = ServiceManager::getInstance($_GET['id']); } else { if (!is_null($name)) { $params['svc'] = ServiceManager::getInstanceByName($_GET['name']); } } if (!isset($params['svc'])) { throw new CHttpException(404); } $params['title'] = $params['svc']['name']; $params['id'] = $params['svc']['id']; $this->renderForm("SysServiceForm", null, $params, $options); }
function getServiceType() { return ServiceManager::getInstance()->getServiceTypeList($this->service_type); }
/** * Get multiple services by tag * * @param string $tag Tag to use for services filter * @param null $forceType (Optional) Return only services which are instances of $forceType * * @return array */ protected static function servicesByTag($tag, $forceType = null) { return ServiceManager::getInstance()->getServicesByTag($tag, $forceType); }