本文整理匯總了PHP中yii\behaviors\AttributeBehavior::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP AttributeBehavior::init方法的具體用法?PHP AttributeBehavior::init怎麽用?PHP AttributeBehavior::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yii\behaviors\AttributeBehavior
的用法示例。
在下文中一共展示了AttributeBehavior::init方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_BEFORE_INSERT => [$this->createdByAttribute, $this->updatedByAttribute], BaseActiveRecord::EVENT_BEFORE_UPDATE => $this->updatedByAttribute];
}
}
示例2: init
public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_BEFORE_VALIDATE => $this->phoneAttribute, BaseActiveRecord::EVENT_AFTER_FIND => $this->phoneAttribute];
}
}
示例3: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_AFTER_VALIDATE => [$this->attribute], BaseActiveRecord::EVENT_AFTER_FIND => [$this->attribute]];
}
}
示例4: init
/**
* @inheritdoc
*/
public function init()
{
if ($this->attribute !== null) {
$this->attributes[BaseActiveRecord::EVENT_BEFORE_INSERT][] = $this->attribute;
}
parent::init();
}
示例5: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_BEFORE_INSERT => $this->compiledAttribute, BaseActiveRecord::EVENT_BEFORE_UPDATE => $this->compiledAttribute];
}
}
示例6: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_BEFORE_INSERT => 'date', BaseActiveRecord::EVENT_BEFORE_UPDATE => 'date', BaseActiveRecord::EVENT_AFTER_FIND => 'date'];
}
}
示例7: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_BEFORE_DELETE => $this->trashAttribute];
}
}
示例8: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_BEFORE_INSERT => [$this->authorAttribute]];
}
}
示例9: init
public function init()
{
parent::init();
if ($this->hashFunction == null) {
$this->hashFunction = [$this, 'defaultHashFunction'];
}
$this->attributes = [BaseActiveRecord::EVENT_BEFORE_INSERT => $this->passwordAttribute, BaseActiveRecord::EVENT_BEFORE_UPDATE => $this->passwordAttribute];
$this->value = $this->hashFunction;
}
示例10: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_BEFORE_VALIDATE => $this->attribute];
}
if ($this->attribute === null) {
throw new InvalidConfigException('Either "attribute" or "value" property must be specified.');
}
}
示例11: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [$this->trigger => $this->uniqueAttribute];
}
if (!empty($this->paramAttributes) && $this->paramOrder === null) {
throw new InvalidConfigException('$paramOrder wajib diisi jika $paramAttributes diisi');
}
if ($this->length === null) {
throw new InvalidConfigException('$length wajib diisi');
}
}
示例12: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_AFTER_INSERT => $this->imageAttributes, BaseActiveRecord::EVENT_AFTER_UPDATE => $this->imageAttributes];
foreach ($this->imageAttributes as $attribute => $params) {
if (is_numeric($attribute)) {
$attribute = $params;
$params = [];
}
$this->descriptors[$attribute] = Yii::createObject($params + ['class' => '\\vr\\image\\ImageAttributeDescriptor', 'attribute' => $attribute]);
}
}
}
示例13: init
public function init()
{
parent::init();
if (empty($this->attributes)) {
foreach ($this->convertAttr as $key => $value) {
$attrName = is_scalar($key) ? $key : $value;
$convertType = is_scalar($key) ? $value : self::DEFAULT_CONVERT_TYPE;
if (!in_array($convertType, $this->allowConvertType)) {
throw new \Exception(strtr('Disallow type convert "{type}"', ['{type}' => $convertType]));
}
$this->attributes[BaseActiveRecord::EVENT_BEFORE_INSERT][] = $attrName;
$this->attributes[BaseActiveRecord::EVENT_BEFORE_UPDATE][] = $attrName;
$this->attributes[BaseActiveRecord::EVENT_AFTER_FIND][] = $attrName;
$this->attributes[BaseActiveRecord::EVENT_AFTER_INSERT][] = $attrName;
$this->attributes[BaseActiveRecord::EVENT_AFTER_UPDATE][] = $attrName;
}
}
}
示例14: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->className == null) {
throw new \yii\base\InvalidConfigException("'className' must be set");
}
if (!is_array($this->map)) {
throw new \yii\base\InvalidConfigException("'map' must be an array; e.g.: ['gid' => 'group_id']");
} else {
if (!count($this->map) > 0) {
throw new \yii\base\InvalidConfigException("'map' must contain the mapping group => local; e.g.: ['gid' => 'group_id']");
}
}
if (!Yii::$app instanceof \yii\console\Application) {
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_BEFORE_INSERT => array_values($this->map)[0]];
}
}
}
示例15: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$this->category = str_replace(['{', '%', '}'], '', $this->category);
}