\BEAR_Main

メイン

ページに実装されたイベントハンドラをイベント毎にコールしページを実行します。
キャッシュオプションでページの初期化(onInit)をキャッシュするinitキャッシュ、
テンプレート生成までも含めたページキャッシュのキャッシュオプションを
指定することができます。

Example 1.キャッシュページの実行

class Page_Blog_RSS extends App_Page{ } $config = array('page_cache'=>'init', 'life'=>60); new BEAR_Main('Page_Blog_RSS', $config); //10分間のページキャッシュ

Summary

Methods
Properties
Constants
__construct()
onInject()
setConfig()
getConfig()
setService()
run()
end()
exitMain()
isCliErrorOutput()
includePage()
No public properties found
No constants found
_exception()
_run()
_runSubmit()
_runClick()
_runInit()
_runPreOnOutput()
_sessionStart()
$_config
$_log
$_agent
N/A
_runCache()
_writeCache()
_formValidationOk()
_ajaxValidationNG()
$_isRunnable
$_page
$_submit
$_isAjaxSubmit
N/A

Properties

$_config

$_config : array

Class config

Type

array

$_agent

$_agent : 

Type

$_isRunnable

$_isRunnable : boolean

runできる

Type

boolean

$_page

$_page : \BEAR_Page

ページインスタンス

Type

\BEAR_Page

$_submit

$_submit : mixed

サブミット値

$_POSTか$_GETの内容が入ります BEAR_Page::queryMethodプロパティの設定に依存します

Type

mixed

$_isAjaxSubmit

$_isAjaxSubmit : boolean

Ajaxサブミットか

Type

boolean

Methods

__construct()

__construct(array  $config) 

Constructor

設定を_configプロパティに代入します。

Parameters

array $config

ユーザー設定値

onInject()

onInject() : void

Inject

設定にしたがってサービスをインジェクトします。

setConfig()

setConfig(mixed  $config, mixed  $values = null) : self

Set config

Parameters

mixed $config

(string) 設定キー | (array) 設定配列

mixed $values

(string) $configの時の設定値

Returns

self

getConfig()

getConfig(string  $key = null) : mixed

Get config

Parameters

string $key

設定キー、指定なければ全ての設定を取得

Returns

mixed

setService()

setService(string  $name, mixed  $service) : void

Set service

Parameters

string $name

サービスキー

mixed $service

サービス

run()

run(string  $pageClass, array  $config = array(), array  $options = array()) : void

ページクラス実行

指定されたページクラスをインスタンス化し実行します。

Parameters

string $pageClass

ページクラス名

array $config

設定

array $options

オプション

Throws

\BEAR_Page_Exception

end()

end(null  $initCache = null) 

ページ終了処理

ヘッダーとコンテンツを出力して終了します。

Parameters

null $initCache

Throws

\BEAR_Exception

exitMain()

exitMain() : void

Main終了

exit()の実行をここに集約しています。

isCliErrorOutput()

isCliErrorOutput() : boolean

エラーの出力フォーマット(CLI or rich HTML)

Returns

boolean

includePage()

includePage(string  $pageFile) : void

ページファイルのインクルード

Parameters

string $pageFile

ページファイル

Throws

\BEAR_Main_Exception

_exception()

_exception(string  $msg, array  $config = array()) : \BEAR_Exception

例外の作成

Parameters

string $msg

例外メッセージ

array $config

例外config

Returns

\BEAR_Exception

_run()

_run(  $pageClass) 

ページ開始

ページを実行します。

Parameters

$pageClass

_runSubmit()

_runSubmit() : void

Submit処理

フォームがサブミットされた場合の処理を行います。
サブミットされたらバリデーションを自動で行いOKならPage::onAction(), NGならPage::onOutput()をコールします。

_runClick()

_runClick(array  $args) : void

onClickコール

ページのonClickメソッドをコールします。

Parameters

array $args

引数

_runInit()

_runInit(array  $args) : void

onInitコール

Parameters

array $args

ページ引数

Throws

\Panda_Exception

_runPreOnOutput()

_runPreOnOutput() : void

出力前のバッファの消去

debugモード時はdebug出力エリアとして出力します。

_sessionStart()

_sessionStart() : void

セッションスタート

_runCache()

_runCache() : mixed

init/ページキャッシュの読み込み

ページキャッシュが存在すれば表示して終了します。initキャッシュなら配列を返します。
キャッシュを書き込むときはtrueを返します。
ページキャッシュはヘッダーもキャッシュされます。

Returns

mixed —

array (bool) false no cache | (bool) true write cache | (array) initcache

_writeCache()

_writeCache(string  $cacheData) : void

ページキャッシュ書き込み

ヘッダーとコンテンツをキャッシュに保存

Parameters

string $cacheData

キャッシュ

_formValidationOk()

_formValidationOk(object  $form, object  $formName = null) : void

フォームバリデーションOK処理

トークンの検査を行い不正アクセスでなければonActionメソッドの引数に POSTされたデータを与えてコールする。

Parameters

object $form
object $formName

_ajaxValidationNG()

_ajaxValidationNG(object  $form) : void

AJAXフォームでバリデーションNG

エラーフォームエレメント名とエラーメッセージの連想配列をJSONで返す

Parameters

object $form

フォームオブジェクト