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

Revision 23605, 4.3 KB checked in by kimoto, 12 years ago (diff)

#2448 typo修正・ソース整形・ソースコメントの改善 for 2.13.3

Scrutinizer Auto-Fixes

This patch was automatically generated as part of the following inspection:
 https://scrutinizer-ci.com/g/nobuhiko/EC-CUBE/inspections/d8722894-69a6-4b1b-898d-43618035c60d

Enabled analysis tools:

  • PHP Analyzer
  • PHP PDepend
  • PHP Similarity Analyzer
  • PHP Change Tracking Analyzer
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    /**
72     * @param SC_FormParam_Ex $objFormParam
73     */
74    abstract protected function lfInitParam(&$objFormParam);
75
76    public function getResponseArray()
77    {
78        return $this->arrResponse;
79    }
80
81    public function getErrorArray()
82    {
83        return $this->arrErr;
84    }
85
86    public function getDefaultConfig()
87    {
88        $arrApiConfig = array();
89        $arrApiConfig['operation_name'] = $this->operation_name;
90        $arrApiConfig['operation_description'] = $this->operation_description;
91        $arrApiConfig['auth_types'] = $this->default_auth_types;
92        $arrApiConfig['enable'] = $this->default_enable;
93        $arrApiConfig['is_log'] = $this->default_is_log;
94        $arrApiConfig['sub_data'] = $this->default_sub_data;
95
96        return $arrApiConfig;
97    }
98
99    /**
100     * @param string $key
101     */
102    protected function setResponse($key, $data)
103    {
104        $this->arrResponse[$key] = $data;
105    }
106
107    protected function addError($arrErr)
108    {
109        $this->arrErr = array_merge((array) $this->arrErr, (array) $arrErr);
110    }
111
112    protected function isParamError()
113    {
114        return !SC_Utils_Ex::isBlank($this->arrErr);
115    }
116
117    protected function checkErrorExtended($arrParam)
118    {
119    }
120
121    protected function doInitParam($arrParam = array())
122    {
123        $this->objFormParam = new SC_FormParam_Ex();
124        $this->lfInitParam($this->objFormParam);
125        $this->objFormParam->setParam($arrParam);
126        $this->objFormParam->convParam();
127        $this->arrErr = $this->objFormParam->checkError(false);
128        $this->arrErr = array_merge((array) $this->arrErr, (array) $this->checkErrorExtended($arrParam));
129
130        return $this->objFormParam->getHashArray();
131    }
132
133    public function getRequestValidate()
134    {
135        $arrParam = $this->objFormParam->getHashArray();
136        if (!SC_Utils_Ex::isBlank($arrParam)) {
137            return $arrParam;
138        }
139
140        return;
141    }
142}
Note: See TracBrowser for help on using the repository browser.