Authored by whb

修改配置

@@ -13,8 +13,7 @@ @@ -13,8 +13,7 @@
13 ], 13 ],
14 "autoload": { 14 "autoload": {
15 "psr-4": { 15 "psr-4": {
16 - "QSns\\": "src/QSns",  
17 - "QSnsApi\\":"src/QSnsApi" 16 + "QSns\\": "src/QSns"
18 } 17 }
19 }, 18 },
20 "require": { 19 "require": {
  1 +<?php
  2 +use Action\RootAction;
  3 +
  4 +class IndexController extends RootAction
  5 +{
  6 + public function indexAction()
  7 + {
  8 + $this->_viewScriptPush(
  9 + array('bootstrap', 'cookies', 'custom', 'jquery.dataTables', 'dataTables.responsive', 'dataTables.bootstrap')
  10 + );
  11 + $this->_viewLink()->offsetSetFile(103, $this->_css('dataTables', true));
  12 + $this->_assign('tab',array($this->getRequest()->getModuleName(),$this->getRequest()->getControllerName(),$this->getRequest()->getActionName()));
  13 + }
  14 +
  15 + public function addAction()
  16 + {
  17 + $this->_viewLink()
  18 + ->offsetSetFile(20, $this->_css('jquery.tagsinput', true))
  19 + ->offsetSetFile(21, $this->_css('toggles', true));
  20 +
  21 + $this->_viewScriptPush(array(
  22 + 'bootstrap', 'cookies', 'custom','retina', 'pace', 'modernizr', 'jquery-migrate',
  23 + 'jquery-ui', 'autogrow-textarea',
  24 + 'jquery.mousewheel', 'jquery.tagsinput', 'toggles',
  25 + 'select2'
  26 + ));
  27 + $this->_assign('tab',array($this->getRequest()->getModuleName(),$this->getRequest()->getControllerName(),$this->getRequest()->getActionName()));
  28 + }
  29 +}
  1 +;profile
  2 +product.index.type = "rewrite"
  3 +product.index.match = "/product/$"
  4 +product.index.route.module = Product
  5 +product.index.route.controller = Index
  6 +product.index.route.action = Index
1 -<?php  
2 -/**  
3 - * Created by PhpStorm.  
4 - * User: Zip  
5 - * Date: 15/4/6  
6 - * Time: 下午10:06  
7 - */  
8 -  
9 -namespace QSnsApi;  
10 -  
11 -  
12 -class ApiAbstract  
13 -{  
14 -  
15 - /**  
16 - * @param $serviceUri  
17 - * @return YarConcurrent  
18 - */  
19 - protected static function concurrent($className)  
20 - {  
21 - return new YarConcurrent(Config::getUri($className));  
22 - }  
23 -  
24 - /**  
25 - * @param $serviceUri  
26 - * @return \Yar_Client  
27 - */  
28 - protected static function client($className)  
29 - {  
30 - echo Config::getUri($className);  
31 - exit();  
32 - $yarClient = new \Yar_Client(Config::getUri($className));  
33 - $yarClient->setOpt(YAR_OPT_CONNECT_TIMEOUT, 1000);  
34 - return $yarClient;  
35 - }  
36 -}  
1 -<?php  
2 -namespace QSnsApi;  
3 -class Config  
4 -{  
5 - public static $production = "/service/";  
6 -  
7 - public static $testing = "/service/";  
8 -  
9 - public static $developer = "/service/";  
10 -  
11 - /**  
12 - * ClassNameUriList ,  
13 - * 可以定义不同的方法的地址,主要是本地开发使用  
14 - * 或者使用非本站点的Service  
15 - * @var array  
16 - */  
17 - public static $productionClassNameUri = array(  
18 - 'admin.profile' => 'http://www.qin.com/service/admin/profile'  
19 - );  
20 -  
21 - /**  
22 - * 测试配置列表  
23 - * @var array  
24 - */  
25 - public static $testingClassNameUri = array();  
26 -  
27 - /**  
28 - * 开发者配置列表  
29 - * @var array  
30 - */  
31 - public static $developerClassNameUri = array(  
32 - 'admin.profile' => 'http://www.yoho.com/service/admin/profile',  
33 - );  
34 -  
35 - /**  
36 - * 获取URI  
37 - * @param $className  
38 - * @return string  
39 - */  
40 - public static function getUri($className)  
41 - {  
42 - $environ = ini_get('yaf.environ');  
43 - $environClassName = $environ . 'ClassNameUri';  
44 - if (!property_exists('QApi\Config', $environClassName)) {  
45 - throw new \Exception('Environ Class Is Null.');  
46 - }  
47 - $environClassList = self::$$environClassName;  
48 - if (isset($environClassList[$className])) {  
49 - return $environClassList[$className];  
50 - }  
51 - if (!isset(self::$$environ) || !isset($_SERVER['HTTP_HOST'])) {  
52 - throw new \Exception('Service Url Is Null.');  
53 - }  
54 - $className = str_replace(array('.'), array('/'), $className);  
55 - return 'http://' . $_SERVER['HTTP_HOST'] . self::$$environ . $className;  
56 - }  
57 -}  
1 -<?php  
2 -namespace QSnsApi;  
3 -class YarClient  
4 -{  
5 - private $uri;  
6 -  
7 - public function __construct($uri)  
8 - {  
9 - $this->uri = $uri;  
10 - }  
11 -  
12 - /**  
13 - * @return \Yar_Client  
14 - */  
15 - public function call()  
16 - {  
17 - return new \Yar_Client($this->uri);  
18 - }  
19 -}  
1 -<?php  
2 -namespace QSnsApi;  
3 -class YarConcurrent  
4 -{  
5 - private $uri;  
6 -  
7 - public function __construct($uri)  
8 - {  
9 - $this->uri = $uri;  
10 - }  
11 -  
12 - public function call($method, $parameters, $callback)  
13 - {  
14 - \Yar_Concurrent_Client::call($this->uri, $method, $parameters, $callback);  
15 - return $this;  
16 - }  
17 -  
18 - public function loop($callback = 'QSnsApi\YarConcurrent::callback', $error_callback = 'QSnsApi\YarConcurrent::errorCallback')  
19 - {  
20 - \Yar_Concurrent_Client::loop($callback, $error_callback);  
21 - return $this;  
22 - }  
23 -  
24 - /**  
25 - * 错误回调  
26 - * @param $type  
27 - * @param $error  
28 - * @param $callinfo  
29 - */  
30 - static public function errorCallback($type, $error, $callinfo)  
31 - {  
32 - print_r($error);  
33 - }  
34 -  
35 - /**  
36 - * 发送所有注册的并行调用  
37 - * @param $retval  
38 - * @param $callinfo  
39 - */  
40 - static public function callback($retval, $callinfo)  
41 - {  
42 -  
43 - }  
44 -}