baserCMS クラスリファレンス

ToolsTable extends AppTable
in package

Class Tool

ツールモデル

Table of Contents

$publishBeginField  : string
公開開始日のフィールド AppTable::getConditionAllowPublish() で利用
$publishEndField  : string
公開終了日のフィールド AppTable::getConditionAllowPublish() で利用
$publishStatusField  : string
公開状態のフィールド AppTable::getConditionAllowPublish() で利用
$tmpEvents  : array<string|int, mixed>
一時イベント イベントを一時にオフにする場合に対象のコールバック処理を一時的に格納する
$useTable  : string
テーブル
addField()  : bool
テーブルにフィールドを追加する
addPrefix()  : string
テーブル名にプレフィックスを追加する
alphaNumeric()  : bool
英数チェック
beforeSave()  : bool
Before Save
belongsToMany()  : BelongsToMany
Belongs To Many
between()  : mixed
範囲を指定しての長さチェック
cakeError()  : mixed
Used to report user friendly errors.
changeSort()  : bool
並び順を変更する
convertEncodingByArray()  : array<string|int, mixed>
配列の文字コードを変換する
deconstruct()  : mixed
Deconstructs a complex data type (array or object) into a single field value.
delete()  : bool
{@inheritDoc}
deleteAll()  : int
delField()  : bool
フィールドを削除する
editField()  : bool
フィールド構造を変更する
exists()  : bool
find()  : Query
Creates a new Query for this repository and applies some defaults based on the type of search that was selected.
getChildIdsList()  : array<string|int, mixed>
子カテゴリのIDリストを取得する
getConditionAllowPublish()  : array<string|int, mixed>
公開状態となっているデータを取得するための conditions 値を取得
getControlSource()  : array<string|int, mixed>
コントロールソースを取得する
getListModels()  : array<string|int, mixed>
データソースを指定してモデルリストを取得する
getMax()  : int
指定フィールドのMAX値を取得する
getTable()  : string
テーブルを取得
getUrlPattern()  : array<string|int, mixed>
コンテンツのURLにマッチする候補を取得する
initialize()  : void
Initialize
isPublish()  : bool
データが公開済みかどうかチェックする
loadCsv()  : bool
CSVを読み込む
loadSchema()  : bool
スキーマファイルを利用してデータベース構造を変更する
loadSchemaFile()  : bool
スキーマファイルを読み込む
offEvent()  : mixed
イベントを一時的にオフにする
onEvent()  : mixed
一時的にオフにしたイベントをオンにする BcModelEventDispatcherは対象外とする
reduceAssociations()  : void
指定したモデル以外のアソシエーションを除外する
renameField()  : bool
フィールド名を変更する
replaceText()  : string
機種依存文字の変換処理
saveDbLog()  : bool
データベースログを記録する
setTable()  : AppTable
テーブルをセット
sortdown()  : bool
一つ位置を下げる
sortup()  : bool
一つ位置を上げる
tableExists()  : bool
テーブルの存在チェックを行う
updateAll()  : int
writeSchema()  : bool
スキーマを書き出す
_writeSchema()  : bool
スキーマを書き出す

Properties

$publishBeginField

公開開始日のフィールド AppTable::getConditionAllowPublish() で利用

public string $publishBeginField = 'publish_begin'

$publishEndField

公開終了日のフィールド AppTable::getConditionAllowPublish() で利用

public string $publishEndField = 'publish_end'

$publishStatusField

公開状態のフィールド AppTable::getConditionAllowPublish() で利用

public string $publishStatusField = 'status'

$tmpEvents

一時イベント イベントを一時にオフにする場合に対象のコールバック処理を一時的に格納する

public array<string|int, mixed> $tmpEvents = []

$useTable

テーブル

public string $useTable = false

Methods

addField()

テーブルにフィールドを追加する

public addField(array<string|int, mixed> $options) : bool
Parameters
$options : array<string|int, mixed>

[ field / column / table ]

Return values
bool

addPrefix()

テーブル名にプレフィックスを追加する

public addPrefix( $table) : string

$this->getConnection()->config() を利用するとユニットテストで問題が発生するため、BcUtil::getCurrentDbConfig()を利用する

$this->getConnection()->config()を利用すると、 そのテーブルに connection が設定されてしまう。

ユニットテストの dataProvider で、テーブルを初期化する場合、 タイミング的に、接続についてテスト用のエイリアスが設定されていないので、 テスト用の接続ではなく、 default がセットされてしまう。

Parameters
$table :
Tags
checked
noTodo
Return values
string

alphaNumeric()

英数チェック

public static alphaNumeric(string $value) : bool
Parameters
$value : string

チェック対象文字列

Return values
bool

beforeSave()

Before Save

public beforeSave(EventInterface $event, EntityInterface $entity, ArrayObject $options) : bool
Parameters
$event : EventInterface
$entity : EntityInterface
$options : ArrayObject
Return values
bool

belongsToMany()

Belongs To Many

public belongsToMany(string $associated[, array<string|int, mixed> $options = [] ]) : BelongsToMany

joinTable にプレフィックスを追加

Parameters
$associated : string
$options : array<string|int, mixed> = []
Tags
checked
noTodo
Return values
BelongsToMany

between()

範囲を指定しての長さチェック

public between(mixed $check, int $min, int $max) : mixed
Parameters
$check : mixed

対象となる値

$min : int

値の最短値

$max : int

値の最長値

Return values
mixed

cakeError()

Used to report user friendly errors.

public cakeError(string $method[, array<string|int, mixed> $messages = [] ]) : mixed

If there is a file app/error.php or app/app_error.php this file will be loaded error.php is the AppError class it should extend ErrorHandler class.

Parameters
$method : string

Method to be called in the error class (AppError or ErrorHandler classes)

$messages : array<string|int, mixed> = []

Message that is to be displayed by the error class

Return values
mixed

changeSort()

並び順を変更する

public changeSort(string $id, int $offset[, array<string|int, mixed> $options = [] ]) : bool
Parameters
$id : string
$offset : int
$options : array<string|int, mixed> = []
  • conditions: データ取得条件
  • sortFieldName: ソートフィールドのカラム名 (初期値: sort)
Return values
bool

convertEncodingByArray()

配列の文字コードを変換する

public convertEncodingByArray(array<string|int, mixed> $data, string $outenc, string $inenc) : array<string|int, mixed>

TODO GLOBAL グローバルな関数として再配置する必要あり

Parameters
$data : array<string|int, mixed>

変換前のデータ

$outenc : string

変換後の文字コード

$inenc : string

変換元の文字コード

Return values
array<string|int, mixed>

変換後のデータ

deconstruct()

Deconstructs a complex data type (array or object) into a single field value.

public deconstruct(string $field, mixed $data) : mixed
Parameters
$field : string

The name of the field to be deconstructed

$data : mixed

An array or object to be deconstructed into a field

Return values
mixed

The resulting data that should be assigned to a field

delete()

{@inheritDoc}

public delete(EntityInterface $entity[, array<string|int, mixed>|ArrayAccess $options = [] ]) : bool

For HasMany and HasOne associations records will be removed based on the dependent option. Join table records in BelongsToMany associations will always be removed. You can use the cascadeCallbacks option when defining associations to change how associated data is deleted.

Options

  • atomic Defaults to true. When true the deletion happens within a transaction.
  • checkRules Defaults to true. Check deletion rules before deleting the record.

Events

  • Model.beforeDelete Fired before the delete occurs. If stopped the delete will be aborted. Receives the event, entity, and options.
  • Model.afterDelete Fired after the delete has been successful. Receives the event, entity, and options.
  • Model.afterDeleteCommit Fired after the transaction is committed for an atomic delete. Receives the event, entity, and options.

The options argument will be converted into an \ArrayObject instance for the duration of the callbacks, this allows listeners to modify the options used in the delete operation.

Parameters
$entity : EntityInterface

The entity to remove.

$options : array<string|int, mixed>|ArrayAccess = []

The options for the delete.

Return values
bool

success

deleteAll()

public deleteAll(mixed $conditions) : int
Parameters
$conditions : mixed
Tags
inheritDoc
Return values
int

delField()

フィールドを削除する

public delField(array<string|int, mixed> $options) : bool
Parameters
$options : array<string|int, mixed>

[ field / table ]

Return values
bool

editField()

フィールド構造を変更する

public editField(array<string|int, mixed> $options) : bool
Parameters
$options : array<string|int, mixed>

[ field / column / table ]

Return values
bool

exists()

public exists(mixed $conditions) : bool
Parameters
$conditions : mixed
Tags
inheritDoc
Return values
bool

find()

Creates a new Query for this repository and applies some defaults based on the type of search that was selected.

public find([string $type = 'all' ][, array<string|int, mixed> $options = [] ]) : Query

Model.beforeFind event

Each find() will trigger a Model.beforeFind event for all attached listeners. Any listener can set a valid result set using $query

By default, $options will recognize the following keys:

  • fields
  • conditions
  • order
  • limit
  • offset
  • page
  • group
  • having
  • contain
  • join

Usage

Using the options array:

$query = $articles->find('all', [
  'conditions' => ['published' => 1],
  'limit' => 10,
  'contain' => ['Users', 'Comments']
]);

Using the builder interface:

$query = $articles->find()
  ->where(['published' => 1])
  ->limit(10)
  ->contain(['Users', 'Comments']);

Calling finders

The find() method is the entry point for custom finder methods. You can invoke a finder by specifying the type:

$query = $articles->find('published');

Would invoke the findPublished method.

Parameters
$type : string = 'all'

the type of query to perform

$options : array<string|int, mixed> = []

An array that will be passed to Query::applyOptions()

Return values
Query

The query builder

getChildIdsList()

子カテゴリのIDリストを取得する

public getChildIdsList(mixed $id) : array<string|int, mixed>

treeビヘイビア要

Parameters
$id : mixed

ページカテゴリーID

Return values
array<string|int, mixed>

getConditionAllowPublish()

公開状態となっているデータを取得するための conditions 値を取得

public getConditionAllowPublish() : array<string|int, mixed>

公開状態(初期値:status)、公開開始日(初期値:publish_begin)、公開終了日(初期値:publish_end) の組み合わせてによって配列を生成する。

公開状態が true であったとしても、公開期間が設定されている場合はそちらを優先する。

Tags
checked
noTodo
unitTest
Return values
array<string|int, mixed>

getControlSource()

コントロールソースを取得する

public getControlSource(mixed $field) : array<string|int, mixed>
Parameters
$field : mixed
Return values
array<string|int, mixed>

コントロールソース

getListModels()

データソースを指定してモデルリストを取得する

public getListModels([mixed $type = 'core' ]) : array<string|int, mixed>
Parameters
$type : mixed = 'core'
Return values
array<string|int, mixed>

getMax()

指定フィールドのMAX値を取得する

public getMax(string $field[, array<string|int, mixed> $conditions = [] ]) : int

現在数値フィールドのみ対応

Parameters
$field : string
$conditions : array<string|int, mixed> = []
Tags
checked
unitTest
noTodo
Return values
int

getTable()

テーブルを取得

public getTable() : string

プレフィックスを追加する

Tags
checked
noTodo
Return values
string

getUrlPattern()

コンテンツのURLにマッチする候補を取得する

public getUrlPattern(string $url) : array<string|int, mixed>
Parameters
$url : string
Tags
checked
noTodo
unitTest
Return values
array<string|int, mixed>

initialize()

Initialize

public initialize(array<string|int, mixed> $config) : void
Parameters
$config : array<string|int, mixed>

テーブル設定

Tags
checked
noTodo
unitTest
Return values
void

isPublish()

データが公開済みかどうかチェックする

public isPublish(bool $status, string $publishBegin, string $publishEnd) : bool
Parameters
$status : bool

公開ステータス

$publishBegin : string

公開開始日時

$publishEnd : string

公開終了日時

Return values
bool

loadCsv()

CSVを読み込む

public loadCsv(mixed $dbConfigName, mixed $path[, mixed $options = [] ]) : bool
Parameters
$dbConfigName : mixed
$path : mixed
$options : mixed = []
Return values
bool

loadSchema()

スキーマファイルを利用してデータベース構造を変更する

public loadSchema(mixed $dbConfigName, mixed $path[, mixed $filterTable = '' ][, mixed $filterType = '' ][, mixed $excludePath = [] ][, mixed $dropField = true ]) : bool
Parameters
$dbConfigName : mixed
$path : mixed
$filterTable : mixed = ''
$filterType : mixed = ''
$excludePath : mixed = []
$dropField : mixed = true
Return values
bool

loadSchemaFile()

スキーマファイルを読み込む

public loadSchemaFile(array<string|int, mixed> $data, string $tmpPath) : bool
Parameters
$data : array<string|int, mixed>
$tmpPath : string
Return values
bool

offEvent()

イベントを一時的にオフにする

public offEvent(string $eventKey) : mixed
Parameters
$eventKey : string
Return values
mixed

onEvent()

一時的にオフにしたイベントをオンにする BcModelEventDispatcherは対象外とする

public onEvent(string $eventKey) : mixed
Parameters
$eventKey : string
Tags
checked
noTodo
unitTest
Return values
mixed

reduceAssociations()

指定したモデル以外のアソシエーションを除外する

public reduceAssociations(mixed $arguments[, bool $reset = true ]) : void
Parameters
$arguments : mixed
$reset : bool = true

バインド時に1回の find でリセットするかどうか

Return values
void

renameField()

フィールド名を変更する

public renameField(array<string|int, mixed> $options) : bool
Parameters
$options : array<string|int, mixed>

[ new / old / table ]

Return values
bool

replaceText()

機種依存文字の変換処理

public replaceText(mixed $str) : string

内部文字コードがUTF-8である必要がある。 多次元配列には対応していない。

Parameters
$str : mixed
Return values
string

変換後文字列 TODO AppExModeに移行すべきかも

saveDbLog()

データベースログを記録する

public saveDbLog(string $message) : bool
Parameters
$message : string
Return values
bool

setTable()

テーブルをセット

public setTable(string $table) : AppTable

プレフィックスを追加する

Parameters
$table : string
Tags
checked
noTodo
Return values
AppTable

sortdown()

一つ位置を下げる

public sortdown(string $id, array<string|int, mixed> $conditions) : bool
Parameters
$id : string
$conditions : array<string|int, mixed>
Return values
bool

sortup()

一つ位置を上げる

public sortup(string $id, array<string|int, mixed> $conditions) : bool
Parameters
$id : string
$conditions : array<string|int, mixed>
Return values
bool

tableExists()

テーブルの存在チェックを行う

public tableExists(string $tableName) : bool
Parameters
$tableName : string
Return values
bool

updateAll()

public updateAll(mixed $fields, mixed $conditions) : int
Parameters
$fields : mixed
$conditions : mixed
Tags
inheritDoc
Return values
int

writeSchema()

スキーマを書き出す

public writeSchema(array<string|int, mixed> $data, string $path) : bool
Parameters
$data : array<string|int, mixed>
$path : string

スキーマファイルの生成場所

Return values
bool

_writeSchema()

スキーマを書き出す

protected _writeSchema(string $field, array<string|int, mixed> $values, string $path) : bool
Parameters
$field : string
$values : array<string|int, mixed>
$path : string

スキーマファイルの生成場所

Return values
bool

Search results