try { $zkServer = empty($zkServer) ? RpcConfig::getZooConfig() : $zkServer; PhpLibLog::info("ZookeeperComponent::getServer serverName:$serverName , zkServer:$zkServer"); $this->zk = new \Zookeeper($zkServer); $serverStr = $this->zk->getChildren("/" . $serverName); PhpLibLog::info("ZookeeperComponent::getServer getChildren success:".json_encode($serverStr)); } catch (Exception $e) { $msg = $e->getMessage(); PhpLibLog::emergency("ZookeeperComponent::getServer ZooException message:$msg"); Throw new ZooException('zookeeper exception:' .$msg); } if (empty($serverStr)) { PhpLibLog::emergency("ZookeeperComponent::getServer RPC service $serverName empty!"); Throw new RpcServiceNotFoundException("未发现RPC服务:" . $serverName . " !"); } //从服务列表中随机取一个 $randKey = array_rand($serverStr, 1);
*/ public function getServer($serverName, $zkServer = null) { $serverData = $this->getServerFromClient($serverName); if (empty($serverData)) { $serverData = $this->getServerFromPhpZk($serverName, $zkServer); } return $serverData; }
* 获取服务地址和端口号 * @return array * @throws \Exception */ protected function getServer() { return $this->zoo->getServer($this->zkServiceName); } /** * 获取连接对象 * @return TSocket */
* BasicService constructor. */ public function __construct() { PhpLibLog::info("zk服务名:" . $this->zkServiceName); $this->zoo = new ZookeeperService(); $this->server = $this->getServer(); $this->connectObj = $this->getConnectObj(); $this->transport = $this->getTransPort(); $this->protocol = $this->getProtocol(); $this->rpcClient = $this->setRpcClient(); $this->transport->open(); }
const LOGIN_STATUS_SUCCESS = 1; /** @var \vso\phplib\rpc\thrift\account\AccountServiceClient $accountRpcService */ private $accountRpcService; public function __construct() { $this->accountRpcService = new AccountService(); } public function loginStatus($username, $vso_token) { $params = [ 'appid' => Yii::$app->params['Api']['app_id'],
$dependencies = $this->resolveDependencies($dependencies, $reflection); if (!$reflection->isInstantiable()) { throw new NotInstantiableException($reflection->name); } if (empty($config)) { return $reflection->newInstanceArgs($dependencies); } $config = $this->resolveDependencies($config); if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten)
public function get($class, $params = [], $config = []) { if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
$config = array_merge($definition, $config); $params = $this->mergeParams($class, $params); if ($concrete === $class) { $object = $this->build($class, $params, $config); } else { $object = $this->get($concrete, $params, $config); } } elseif (is_object($definition)) { return $this->_singletons[$class] = $definition; } else { throw new InvalidConfigException('Unexpected object definition type: ' . gettype($definition)); }
private $userGrowthService;//用户成长值服务 public function __construct() { $this->nicknameService = Yii::$container->get('Nickname'); $this->backUserService = Yii::$container->get('BackUser'); $this->userService = Yii::$container->get('User'); $this->userGrowthService = Yii::$container->get('UserGrowth'); } /** * 批量获取用户名对应的昵称 * @param array $usernames 用户名数组
$dependencies = $this->resolveDependencies($dependencies, $reflection); if (!$reflection->isInstantiable()) { throw new NotInstantiableException($reflection->name); } if (empty($config)) { return $reflection->newInstanceArgs($dependencies); } $config = $this->resolveDependencies($config); if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten)
public function get($class, $params = [], $config = []) { if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
$config = array_merge($definition, $config); $params = $this->mergeParams($class, $params); if ($concrete === $class) { $object = $this->build($class, $params, $config); } else { $object = $this->get($concrete, $params, $config); } } elseif (is_object($definition)) { return $this->_singletons[$class] = $definition; } else { throw new InvalidConfigException('Unexpected object definition type: ' . gettype($definition)); }
$demandInfo = $this->demandData->getDemandData($taskBn, []); if (empty($demandInfo)) { return $newWork; } //user服务依赖 /** @var $demandUserDependency \frontend\modules\demand\services\dependency\DemandUserDependency */ $demandUserDependency = Yii::$container->get('DemandUserDependency'); $currentUserInfo = $demandUserDependency->userLoginStatus(); //获取当前登录者username $loginUsername = $currentUserInfo['username'] ?: ''; //是否已经选标了 $bid_selected = $this->isExistWonBid($taskBn); //是否选择了隐标
if (empty($where['task_bn'])) { return []; } //获取投稿列表 $workLists = $this->getUniqueWorksList($where, $page, $limit); //格式化输出数据格式 $workLists = $this->formatWorkList($where['task_bn'], $workLists); return $workLists; } /** * @param $workInfo array 投标数据
$demandDataService = Yii::$container->get('frontend\modules\demand\interfaces\DemandDataInterface'); /** @var $workService \frontend\modules\demand\services\foundation\Work */ $workService = Yii::$container->get('frontend\modules\demand\interfaces\WorkInterface', [], [ 'demandData' => $demandDataService ]); //投标列表 $req_work_list = $workService->getDemandWorkList(['task_bn' => $task_bn], 1, $work_page_num); //投标总数 $req_work_total = (new DemandsSummary())->find()->select('total_bids')->where(['task_bn' => $task_bn])->scalar(); //备选投标列表 $req_opt_list = $workService->getDemandWorkList(['task_bn' => $task_bn, 'status' => Work::STATUS_OPTIONAL], 1, $work_page_num); //备选投标总数 $req_opt_total = $req_work_mdl->_get_count(['task_bn' => $task_bn, 'status' => DemandsWorks::STATUS_OPTIONAL]);
$args = $this->controller->bindActionParams($this, $params); Yii::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
'views' => ['class' => 'task\libs\ViewsPanel'], ], ]; } $application = new yii\web\Application($config); $application->run();
$_GET = [ 'bn' => '6225301550235', ];