\BEAR_Img_Adapter

BEARクラスの抽象クラス

BEARフレームワークで使われる基底クラスです。

BEARのクラスはBEAR::factoryやBEAR::dependency()によって以下の順でインスタンス化されます。

1) コンストラクタで設定を行う 2) 設定に基づいてインジェクタで必要なサービスをプロパティに用意

Summary

Methods
Properties
Constants
__construct()
onInject()
setConfig()
getConfig()
setService()
deleteFile()
getTmpFileName()
resizeMobile()
loadRemoteFile()
getExtention()
$image
$deleteFiles
$adapter
No constants found
_exception()
getImageInfo()
header()
_error()
$_config
$file
$_srcWidth
$_srcHeight
$_srcAttr
$_result
$_log
N/A
No private methods found
$_srcType
N/A

Properties

$image

$image : resource

イメージリソース

Type

resource

$deleteFiles

$deleteFiles : array

デストラクタで消去するファイルリスト

Type

array

$adapter

$adapter : \GD

画像ライブラリオブジェクト

Type

\GD — | iMagick | Cariro

$_config

$_config : array

Class config

Type

array

$file

$file : string

Type

string

$_srcWidth

$_srcWidth : integer

元画像の幅

Type

integer

$_srcHeight

$_srcHeight : integer

元画像の高さ

Type

integer

$_srcAttr

$_srcAttr : string

元画像の属性

Type

string

$_result

$_result : boolean

出力結果

Type

boolean

$_srcType

$_srcType : string

画像のタイプ

IMAGETYPE_GIF | IMAGETYPE_JPEG | IMAGETYPE_PNG

Type

string

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

サービス

deleteFile()

deleteFile(string  $file) : void

ファイルの消去

作業用のファイルを消去リストに追加します。

Parameters

string $file

ファイル

getTmpFileName()

getTmpFileName(mixed  $file = false, mixed  $delete = true) : string

一時ファイル名を取得

一時画像ファイル名を生成します。 $deleteオプションがtrueの場合、デストラクタでテンポラリーファイルは消去されます

Parameters

mixed $file

ファイル名

mixed $delete

消去

Returns

string

resizeMobile()

resizeMobile() : void

モバイル端末に合わせた画像の最大リサイズ

loadRemoteFile()

loadRemoteFile(string  $file) : string

ファイルの読み込み

ローカル・リモートファイルにかかわらずファイルを読み込みます。
リモートファイルの場合はローカルにテンポラリーファイルが
作成されその名前が返されます。作られたテンポラリーファイルは
デストラクタで消去されます。キャッシュはされません。

Parameters

string $file

ファイル名

Returns

string

getExtention()

getExtention(string  $imageType) : string

image typeから拡張子を求める

Parameters

string $imageType

Returns

string

_exception()

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

例外の作成

Parameters

string $msg

例外メッセージ

array $config

例外config

Returns

\BEAR_Exception

getImageInfo()

getImageInfo() : void

画像情報の取得

getimagesizeで得られる画像情報を以下のプロパティに格納します。

_srcWidth int
srcHeight int
srcType   int
srcAttr   string

header()

header(mixed  $format = false, integer  $expire) : void

ヘッダー出力

Parameters

mixed $format

フォーマット

integer $expire

expire

_error()

_error(string  $errorFunc) : void

エラー終了

Parameters

string $errorFunc

ファンクション名