定制 ansas/propel-helper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ansas/propel-helper

最新稳定版本:1.4.0

Composer 安装命令:

composer require ansas/propel-helper

包简介

Propel helper - helper classes (traits) for Propel2 ORM

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

Helper classes (traits) for Propel2 ORM.

Ansas\Propel\Helper\ReadOnly

This trait is a workaround for the Propel bug that you cannot use joinWith() methods anymore when setting tables to readOnly="true" in Propel's schema.xml file. So instead of making tables "readonly" in the scheme just add this trait to every child model you want to make readonly.

For details see propelorm/Propel2#629

Example usage:

<?php

use Base\User as BaseUser;
use Ansas\Propel\Helper\ReadOnly;

class User extends BaseUser
{
    use ReadOnly;
}

Ansas\Propel\Helper\SimpleVersionableBehavior

The default behavior "versionable" does not seem to work well with relations and in combination with other behaviors. Therefore I wrote a "simple trait" that does NOT consider versions of related tables. All methods can be used as before.

Three things have to be implemented to use this trait:

  1. Use the trait in the desired class
  2. Add the following constant with the name of the versionable behavior active records class (e. g. for an 'Account')
  3. Optionally add the constant for column names (in default PhpName notation) to skip when populating object

Example usage:

<?php

use Base\User as BaseUser;
use Ansas\Propel\Helper\SimpleVersionableBehavior;

class User extends BaseUser
{
    use SimpleVersionableBehavior;

    /**
     * Class name for versionable behavior active records
     */
    const VERSIONABLE_CLASS = 'UserVersion';

    /**
     * Column names (in default PhpName notation) to skip when populating this with version entry
     */
    const VERSIONABLE_POPULATE_SKIP_COLUMNS = ['UpdatedAt', 'Version'];
}

Ansas\Propel\Helper\Validation

This trait makes validation of an object quite easy.

Methods:

protected function addValidationError($key, $value, $overwrite = true)
protected function resetValidation()
public function getValidationErrors()
public function hasValidationErrors()
abstract protected function doValidate();

TODO

  • Write tests

Contribute

Everybody can contribute to this package. Just:

  1. fork it,
  2. make your changes and
  3. send a pull request.

Please make sure to follow PSR-1 and PSR-2 coding conventions.

License

MIT license (see the LICENSE file for more information).

统计信息

  • 总下载量: 775
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-29