Skip to content

Commit

Permalink
LC_Page::plugin_activate_flg を非推奨に
Browse files Browse the repository at this point in the history
- SC_Helper_Plugin::getSingletonInstance() の引数のデフォルト値を PLUGIN_ACTIVATE_FLAG とするよう修正
- 基本的に常に PLUGIN_ACTIVATE_FLAG の値を参照するよう修正
  • Loading branch information
nanasess committed Jun 26, 2019
1 parent 3ac54e0 commit 4d6793a
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 17 deletions.
3 changes: 1 addition & 2 deletions data/class/SC_FormParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ public function __construct()
$backtraces = debug_backtrace();
// 呼び出し元のクラスを取得
$class = $backtraces[1]['class'];
$objPage = $backtraces[1]['object'];
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($objPage->plugin_activate_flg);
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
if (is_object($objPlugin)) {
$objPlugin->doAction('SC_FormParam_construct', array($class, $this));
}
Expand Down
4 changes: 2 additions & 2 deletions data/class/SC_View.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function prefilter_transform($source, Smarty_Internal_Template $template)
{
if (!is_null($this->objPage)) {
// フックポイントを実行.
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->objPage->plugin_activate_flg);
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
if ($objPlugin) {
$objPlugin->doAction('prefilterTransform', array(&$source, $this->objPage, $template->smarty->_current_file));
}
Expand All @@ -164,7 +164,7 @@ public function outputfilter_transform($source, Smarty_Internal_Template $templa
{
if (!is_null($this->objPage)) {
// フックポイントを実行.
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->objPage->plugin_activate_flg);
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
if ($objPlugin) {
$objPlugin->doAction('outputfilterTransform', array(&$source, $this->objPage, $template->smarty->_current_file));
}
Expand Down
6 changes: 4 additions & 2 deletions data/class/helper/SC_Helper_Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SC_Helper_Plugin
* 有効なプラグインのロード. プラグインエンジンが有効になっていない場合は
* プラグインエンジン自身のインストール処理を起動する
*
* @param bool $plugin_activate_flg プラグインを有効化する場合 true
* @return void
*/
public function load($plugin_activate_flg = true)
Expand Down Expand Up @@ -86,9 +87,10 @@ public function load($plugin_activate_flg = true)
/**
* SC_Helper_Plugin オブジェクトを返す(Singletonパターン)
*
* @return object SC_Helper_Pluginオブジェクト
* @param bool $plugin_activate_flg プラグインを有効化する場合 true
* @return SC_Helper_Plugin SC_Helper_Pluginオブジェクト
*/
public static function getSingletonInstance($plugin_activate_flg = true)
public static function getSingletonInstance($plugin_activate_flg = PLUGIN_ACTIVATE_FLAG)
{
if (!isset($GLOBALS['_SC_Helper_Plugin_instance'])) {
// プラグインのローダーがDB接続を必要とするため、
Expand Down
9 changes: 6 additions & 3 deletions data/class/pages/LC_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ class LC_Page
/** 店舗基本情報 */
public $arrSiteInfo;

/** プラグインを実行フラグ */
/**
* プラグインを実行フラグ
* @deprecated 定数 PLUGIN_ACTIVATE_FLAG を使用してください
*/
public $plugin_activate_flg = PLUGIN_ACTIVATE_FLAG;

/** POST に限定する mode */
Expand Down Expand Up @@ -105,7 +108,7 @@ public function init()
}

// スーパーフックポイントを実行.
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
$objPlugin->doAction('LC_Page_preProcess', array($this));

// 店舗基本情報取得
Expand Down Expand Up @@ -137,7 +140,7 @@ public function process()
*/
public function sendResponse()
{
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
// ローカルフックポイントを実行.
$this->doLocalHookpointAfter($objPlugin);

Expand Down
4 changes: 2 additions & 2 deletions data/class/pages/admin/LC_Page_Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function init()
$this->objDisplay = new SC_Display_Ex();

// スーパーフックポイントを実行.
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
$objPlugin->doAction('LC_Page_preProcess', array($this));

// トランザクショントークンの検証と生成
Expand Down Expand Up @@ -99,7 +99,7 @@ public function process()
*/
public function sendResponse()
{
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
// ローカルフックポイントを実行
$parent_class_name = get_parent_class($this);
$objPlugin->doAction($parent_class_name . '_action_after', array($this));
Expand Down
2 changes: 1 addition & 1 deletion data/class/pages/error/LC_Page_Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function init()
// ディスプレイクラス生成
$this->objDisplay = new SC_Display_Ex();

$objHelperPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
$objHelperPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
if (is_object($objHelperPlugin)) {
// transformでフックしている場合に, 再度エラーが発生するため, コールバックを無効化.
$objHelperPlugin->arrRegistedPluginActions = array();
Expand Down
2 changes: 1 addition & 1 deletion data/class/pages/error/LC_Page_Error_DispError.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function init()
$this->objDisplay = new SC_Display_Ex();

// transformでフックしている場合に, 再度エラーが発生するため, コールバックを無効化.
$objHelperPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
$objHelperPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
$objHelperPlugin->arrRegistedPluginActions = array();

// キャッシュから店舗情報取得(DBへの接続は行わない)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function init()
$this->setTokenTo();

// ローカルフックポイントを実行.
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
$this->doLocalHookpointBefore($objPlugin);
}

Expand Down
2 changes: 1 addition & 1 deletion data/class/pages/mypage/LC_Page_Mypage_DownLoad.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function action()
public function sendResponse()
{
// TODO sendResponseをオーバーライドしている為、afterフックポイントが実行されない.直接実行する.(#1790)
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
$objPlugin->doAction('LC_Page_Mypage_DownLoad_action_after', array($this));

$this->objDisplay->noAction();
Expand Down
4 changes: 2 additions & 2 deletions data/class/pages/products/LC_Page_Products_Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ public function doAddFavorite(SC_Customer &$objCustomer)
if (!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) {
SC_Response_Ex::actionExit();
}
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
$objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite', array($this));
}
}
Expand All @@ -671,7 +671,7 @@ public function doAddFavoriteSphone(SC_Customer $objCustomer)
$this->arrErr = $this->lfCheckError($this->mode, $this->objFormParam);
if (count($this->arrErr) == 0) {
if ($this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'), $objCustomer->getValue('customer_id'))) {
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
$objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance();
$objPlugin->doAction('LC_Page_Products_Detail_action_add_favorite_sphone', array($this));
print 'true';
SC_Response_Ex::actionExit();
Expand Down

0 comments on commit 4d6793a

Please sign in to comment.