本文整理汇总了PHP中Jam::behavior方法的典型用法代码示例。如果您正苦于以下问题:PHP Jam::behavior方法的具体用法?PHP Jam::behavior怎么用?PHP Jam::behavior使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jam
的用法示例。
在下文中一共展示了Jam::behavior方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
public static function initialize(Jam_Meta $meta)
{
$meta->table('vocabularies')->name_key('name');
$meta->behaviors(array('paranoid' => Jam::behavior('paranoid', array())));
$meta->associations(array('terms' => Jam::association('hasmany', array('inverse_of' => 'vocabulary'))));
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'is_hidden' => Jam::field('boolean', array()), 'created_at' => Jam::field('timestamp', array('auto_now_create' => TRUE, 'format' => 'Y-m-d H:i:s')), 'updated_at' => Jam::field('timestamp', array('auto_now_update' => TRUE, 'format' => 'Y-m-d H:i:s', 'label' => "Last edited"))));
}
示例2: initialize
public static function initialize(Jam_Meta $meta)
{
$meta->db(Kohana::TESTING);
parent::initialize($meta);
$meta->behaviors(['username' => Jam::behavior('username')]);
$meta->associations(array('user_tokens' => Jam::association('hasmany', array('foreign_model' => 'test_user_token', 'foreign_key' => 'test_user_id')), 'roles' => Jam::association('manytomany', array('foreign_model' => 'test_role', 'join_table' => 'test_roles_users', 'foreign_key' => 'test_role_id', 'association_foreign_key' => 'test_user_id'))));
}
示例3: initialize
public static function initialize(Jam_Meta $meta)
{
$meta->table('terms')->name_key('name');
$meta->behaviors(array('nested' => Jam::behavior('Nested'), 'sluggable' => Jam::behavior('Sluggable', array('uses_primary_key' => FALSE, 'auto_save' => FALSE, 'unique' => TRUE))));
$meta->associations(array('vocabulary' => Jam::association('belongsto', array('inverse_of' => 'terms'))));
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'is_hidden' => Jam::field('boolean', array()), 'created_at' => Jam::field('timestamp', array('auto_now_create' => TRUE, 'format' => 'Y-m-d H:i:s')), 'updated_at' => Jam::field('timestamp', array('auto_now_update' => TRUE, 'format' => 'Y-m-d H:i:s'))));
$meta->validator('name', array('present' => TRUE));
}
示例4: test_available_promotions
/**
* @covers Jam_Behavior_Promotable_Brand_Purchase::available_promotions
*/
public function test_available_promotions()
{
$behavior = Jam::behavior('promotable_brand_purchase');
$promotions = $behavior->available_promotions();
$this->assertEquals(array(1, 2), $promotions->ids());
Jam::find('promotion', 1)->update_fields(array('expires_at' => strtotime('-2days')));
$promotions = $behavior->available_promotions();
$this->assertEquals(array(2), $promotions->ids());
}
示例5: initialize
public static function initialize(Jam_Meta $meta)
{
// Set database to connect to
$meta->db(Kohana::TESTING);
$meta->associations(array('test_post' => Jam::association('belongsto', array('conditions' => array('where' => array('test_post._approved_by', 'IS', NULL)), 'counter_cache' => TRUE, 'touch' => 'updated')), 'test_blogs' => Jam::association('manytomany', array('join_table' => 'test_blogs_test_tags'))));
$meta->behaviors(array('sluggable' => Jam::behavior('sluggable', array('uses_primary_key' => FALSE, 'unique' => TRUE, 'slug' => 'Model_Test_Tag::_slug'))));
// Set fields
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string')));
}
示例6: initialize
public static function initialize(Jam_Meta $meta)
{
// Set database to connect to
$meta->db(Kohana::TESTING);
$meta->behaviors(array('nested' => Jam::behavior('nested')));
$meta->associations(array('test_blog' => Jam::association('belongsto', array('inverse_of' => 'test_categories')), 'test_posts' => Jam::association('manytomany'), 'test_author' => Jam::association('belongsto')));
// Define fields
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'is_featured' => Jam::field('boolean')));
}
示例7: initialize
public static function initialize(Jam_Meta $meta)
{
// Set database to connect to
$meta->db(Kohana::TESTING);
$meta->name_key('file');
$meta->behaviors(array('paranoid' => Jam::behavior('paranoid', array('field' => 'deleted')), 'sortable' => Jam::behavior('sortable', array('field' => 'position', 'scope' => 'group')), 'sluggable' => Jam::behavior('sluggable', array('auto_save' => TRUE)), 'tokenable' => Jam::behavior('tokenable', array('uppercase' => TRUE))));
$meta->associations(array('test_holder' => Jam::association('belongsto', array('polymorphic' => 'test_holder_type'))));
// Set fields
$meta->fields(array('id' => Jam::field('primary'), 'file' => Jam::field('string'), 'group' => Jam::field('string')));
$meta->validator('file', array('length' => array('minimum' => 4)));
}
示例8: initialize
public static function initialize(Jam_Meta $meta)
{
$meta->behaviors(array('freezable' => Jam::behavior('freezable', array('parent' => 'test', 'fields' => 'value'))))->associations(array('parent' => Jam::association('belongsto')))->fields(array('value' => Jam::field('string')));
}
示例9: initialize
/**
* @codeCoverageIgnore
*/
public static function initialize(Jam_Meta $meta)
{
$meta->behaviors(array('paranoid' => Jam::behavior('paranoid')))->associations(array('brand_refund' => Jam::association('belongsto', array('inverse_of' => 'items')), 'purchase_item' => Jam::association('belongsto', array('inverse_of' => 'refund_items'))))->fields(array('id' => Jam::field('primary'), 'amount' => Jam::field('price')))->validator('brand_refund', 'purchase_item', array('present' => TRUE));
}
示例10: initialize
public static function initialize(Jam_Meta $meta)
{
$meta->behaviors(array('shippable_brand' => Jam::behavior('shippable_brand')))->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string')));
}
示例11: initialize
/**
* @codeCoverageIgnore
*/
public static function initialize(Jam_Meta $meta)
{
$meta->behaviors(array('paranoid' => Jam::behavior('paranoid')))->associations(array('groups' => Jam::association('hasmany', array('foreign_model' => 'shipping_group', 'foreign_key' => 'shipping_id', 'inverse_of' => 'shipping', 'delete_on_remove' => Jam_Association::DELETE)), 'methods' => Jam::association('manytomany', array('foreign_model' => 'shipping_method', 'association_foreign_key' => 'method_id', 'join_table' => 'shipping_groups', 'readonly' => TRUE, 'join_table_paranoid' => TRUE)), 'locations' => Jam::association('manytomany', array('join_table' => 'shipping_groups', 'join_table_paranoid' => TRUE, 'readonly' => TRUE)), 'ships_from' => Jam::association('belongsto', array('foreign_model' => 'location')), 'brand' => Jam::association('belongsto', array('inverse_of' => 'shippings'))))->fields(array('id' => Jam::field('primary'), 'model' => Jam::field('polymorphic'), 'name' => Jam::field('string'), 'currency' => Jam::field('string')))->validator('name', 'currency', array('present' => TRUE))->validator('currency', array('currency' => TRUE));
}
示例12: initialize
/**
* @codeCoverageIgnore
*/
public static function initialize(Jam_Meta $meta)
{
$meta->behaviors(array('visitor_defaults' => Jam::behavior('visitor_defaults')))->associations(array('user' => Jam::association('belongsto', array('inverse_of' => 'visitor')), 'country' => Jam::association('belongsto', array('foreign_key' => 'country_id', 'foreign_model' => 'location'))))->fields(array('id' => Jam::field('primary'), 'ip' => Jam::field('ip'), 'token' => Jam::field('string'), 'currency' => Jam::field('string')))->validator('currency', array('choice' => array('in' => array('EUR', 'GBP'))));
}
示例13: initialize
public static function initialize(Jam_Meta $meta)
{
$meta->behaviors(array('freezable' => Jam::behavior('freezable', array('associations' => 'child'))))->associations(array('child' => Jam::association('hasone')));
}
示例14: initialize
public static function initialize(Jam_Meta $meta)
{
$meta->behaviors(array('paranoid' => Jam::behavior('paranoid')))->associations(array('variations' => Jam::association('hasmany')))->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'currency' => Jam::field('string'), 'price' => Jam::field('price')))->validator('name', 'price', 'currency', array('present' => TRUE))->validator('price', array('price' => TRUE));
}
示例15: initialize
public static function initialize(Jam_Meta $meta)
{
$meta->name_key('token')->behaviors(array('auth_user_token' => Jam::behavior('auth_user_token')))->fields(array('id' => Jam::field('primary'), 'user_agent' => Jam::field('string'), 'token' => Jam::field('string'), 'type' => Jam::field('string'), 'created' => Jam::field('timestamp', array('auto_now_create' => TRUE)), 'expires' => Jam::field('timestamp', array('filters' => array('Model_Auth_User_Token::convert_expires')))))->associations(array('user' => Jam::association('belongsto')))->validator('token', array("unique" => TRUE));
}