source: branches/version-2_13-dev/data/class/api/SC_Api_Abstract.php @ 23603

Revision 23603, 4.2 KB checked in by kimoto, 10 years ago (diff)

#2448 typo修正・ソース整形・ソースコメントの改善 for 2.13.3
The property arrResponse does not exist. Did you maybe forget to
declare it?

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2014 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24/**
25 * APIの抽象クラス
26 *
27 * @package Api
28 * @author LOCKON CO.,LTD.
29 * @version $Id$
30 */
31
32abstract class SC_Api_Abstract
33{
34    /** 認証タイプ */
35    const API_AUTH_TYPE_REFERER = '1';          // リファラー
36    const API_AUTH_TYPE_SESSION_TOKEN = '2';    // CSRF TOKEN
37    const API_AUTH_TYPE_API_SIGNATURE = '3';    // API 署名認証 推奨
38    const API_AUTH_TYPE_CUSTOMER = '4';         // 会員認証
39    const API_AUTH_TYPE_MEMBER = '5';           // 管理者認証
40    const API_AUTH_TYPE_CUSTOMER_LOGIN_SESSION = '6';   // 顧客ログインセッションが有効
41    const API_AUTH_TYPE_MEMBER_LOGIN_SESSION = '7';     // 管理者ログインセッションが有効
42    const API_AUTH_TYPE_IP = '8';               // IP認証
43    const API_AUTH_TYPE_HOST = '9';             // ホスト認証
44    const API_AUTH_TYPE_SSL = '10';             // SSL強制
45    const API_AUTH_TYPE_OPEN = '99';            // 完全オープン
46
47    /** API Operation default */
48    protected $operation_name = 'operation_name';
49    protected $operation_description = 'operation description';
50    protected $default_auth_types = '0'; // |区切り
51    protected $default_enable = '0';
52    protected $default_is_log = '0';
53    protected $default_sub_data = '';
54
55    protected $status = true;
56    protected $arrErr = array();
57    protected $arrResponse = array();
58
59    final public function __construct()
60    {
61    }
62
63    final public function __destruct()
64    {
65    }
66
67    abstract public function doAction($arrParam);
68
69    abstract public function getResponseGroupName();
70
71    abstract protected function lfInitParam(&$objFormParam);
72
73    public function getResponseArray()
74    {
75        return $this->arrResponse;
76    }
77
78    public function getErrorArray()
79    {
80        return $this->arrErr;
81    }
82
83    public function getDefaultConfig()
84    {
85        $arrApiConfig = array();
86        $arrApiConfig['operation_name'] = $this->operation_name;
87        $arrApiConfig['operation_description'] = $this->operation_description;
88        $arrApiConfig['auth_types'] = $this->default_auth_types;
89        $arrApiConfig['enable'] = $this->default_enable;
90        $arrApiConfig['is_log'] = $this->default_is_log;
91        $arrApiConfig['sub_data'] = $this->default_sub_data;
92
93        return $arrApiConfig;
94    }
95
96    protected function setResponse($key, $data)
97    {
98        $this->arrResponse[$key] = $data;
99    }
100
101    protected function addError($arrErr)
102    {
103        $this->arrErr = array_merge((array) $this->arrErr, (array) $arrErr);
104    }
105
106    protected function isParamError()
107    {
108        return !SC_Utils_Ex::isBlank($this->arrErr);
109    }
110
111    protected function checkErrorExtended($arrParam)
112    {
113    }
114
115    protected function doInitParam($arrParam = array())
116    {
117        $this->objFormParam = new SC_FormParam_Ex();
118        $this->lfInitParam($this->objFormParam);
119        $this->objFormParam->setParam($arrParam);
120        $this->objFormParam->convParam();
121        $this->arrErr = $this->objFormParam->checkError(false);
122        $this->arrErr = array_merge((array) $this->arrErr, (array) $this->checkErrorExtended($arrParam));
123
124        return $this->objFormParam->getHashArray();
125    }
126
127    public function getRequestValidate()
128    {
129        $arrParam = $this->objFormParam->getHashArray();
130        if (!SC_Utils_Ex::isBlank($arrParam)) {
131            return $arrParam;
132        }
133
134        return;
135    }
136}
Note: See TracBrowser for help on using the repository browser.