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

Revision 22857, 4.1 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 主に空白・空白行の調整。
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 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    final public function __destruct()
62    {}
63
64    abstract public function doAction($arrParam);
65
66    abstract public function getResponseGroupName();
67
68    abstract protected function lfInitParam(&$objFormParam);
69
70    public function getResponseArray()
71    {
72        return $this->arrResponse;
73    }
74
75    public function getErrorArray()
76    {
77        return $this->arrErr;
78    }
79
80    public function getDefaultConfig()
81    {
82        $arrApiConfig = array();
83        $arrApiConfig['operation_name'] = $this->operation_name;
84        $arrApiConfig['operation_description'] = $this->operation_description;
85        $arrApiConfig['auth_types'] = $this->default_auth_types;
86        $arrApiConfig['enable'] = $this->default_enable;
87        $arrApiConfig['is_log'] = $this->default_is_log;
88        $arrApiConfig['sub_data'] = $this->default_sub_data;
89
90        return $arrApiConfig;
91    }
92
93    protected function setResponse($key, $data)
94    {
95        $this->arrResponse[$key] = $data;
96    }
97
98    protected function addError($arrErr)
99    {
100        $this->arrErr = array_merge((array)$this->arrErr, (array)$arrErr);
101    }
102
103    protected function isParamError()
104    {
105        return !SC_Utils_Ex::isBlank($this->arrErr);
106    }
107
108    protected function checkErrorExtended($arrParam)
109    {
110    }
111
112    protected function doInitParam($arrParam = array())
113    {
114        $this->objFormParam = new SC_FormParam_Ex();
115        $this->lfInitParam($this->objFormParam);
116        $this->objFormParam->setParam($arrParam);
117        $this->objFormParam->convParam();
118        $this->arrErr = $this->objFormParam->checkError(false);
119        $this->arrErr = array_merge((array)$this->arrErr, (array)$this->checkErrorExtended($arrParam));
120
121        return $this->objFormParam->getHashArray();
122    }
123
124    public function getRequestValidate()
125    {
126        $arrParam = $this->objFormParam->getHashArray();
127        if (!SC_Utils_Ex::isBlank($arrParam)) {
128            return $arrParam;
129        }
130
131        return;
132    }
133}
Note: See TracBrowser for help on using the repository browser.