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

Revision 23546, 4.1 KB checked in by shutta, 10 years ago (diff)

#2580 Copyrightを更新
Copyrightを2014に更新

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
58    final public function __construct()
59    {
60    }
61
62    final public function __destruct()
63    {
64    }
65
66    abstract public function doAction($arrParam);
67
68    abstract public function getResponseGroupName();
69
70    abstract protected function lfInitParam(&$objFormParam);
71
72    public function getResponseArray()
73    {
74        return $this->arrResponse;
75    }
76
77    public function getErrorArray()
78    {
79        return $this->arrErr;
80    }
81
82    public function getDefaultConfig()
83    {
84        $arrApiConfig = array();
85        $arrApiConfig['operation_name'] = $this->operation_name;
86        $arrApiConfig['operation_description'] = $this->operation_description;
87        $arrApiConfig['auth_types'] = $this->default_auth_types;
88        $arrApiConfig['enable'] = $this->default_enable;
89        $arrApiConfig['is_log'] = $this->default_is_log;
90        $arrApiConfig['sub_data'] = $this->default_sub_data;
91
92        return $arrApiConfig;
93    }
94
95    protected function setResponse($key, $data)
96    {
97        $this->arrResponse[$key] = $data;
98    }
99
100    protected function addError($arrErr)
101    {
102        $this->arrErr = array_merge((array) $this->arrErr, (array) $arrErr);
103    }
104
105    protected function isParamError()
106    {
107        return !SC_Utils_Ex::isBlank($this->arrErr);
108    }
109
110    protected function checkErrorExtended($arrParam)
111    {
112    }
113
114    protected function doInitParam($arrParam = array())
115    {
116        $this->objFormParam = new SC_FormParam_Ex();
117        $this->lfInitParam($this->objFormParam);
118        $this->objFormParam->setParam($arrParam);
119        $this->objFormParam->convParam();
120        $this->arrErr = $this->objFormParam->checkError(false);
121        $this->arrErr = array_merge((array) $this->arrErr, (array) $this->checkErrorExtended($arrParam));
122
123        return $this->objFormParam->getHashArray();
124    }
125
126    public function getRequestValidate()
127    {
128        $arrParam = $this->objFormParam->getHashArray();
129        if (!SC_Utils_Ex::isBlank($arrParam)) {
130            return $arrParam;
131        }
132
133        return;
134    }
135}
Note: See TracBrowser for help on using the repository browser.