smirik/propel-likeable-behavior

Add functionality to like objects.

dev-master 2012-09-09 17:05 UTC

This package is not auto-updated.

Last update: 2020-08-07 18:04:28 UTC


README

Installation

Download LikeableBehavior.php and put it somewhere.

propel.behavior.likeable.class = path.to.likeable.behavior

If you are using composer then just add:

{
    "require": {
        "smirik/propel-likeable-behavior": "*"
    }
}

Usage

Add to schema.xml:

<behavior name="likeable" />

Behavior will create table likes and add several methods to the Model:

public function addLike($user_id, $mark = 1, PropelPDO $con = null);
public function removeLike($user_id, PropelPDO $con = null)
public function hasLike($user_id, PropelPDO $con = null)
public function countLikes(PropelPDO $con = null)

user_id could be any integer.

Requirements

  • Model should have getId() method.
  • Type will be placed automatically based on class name (with namespace)

Credits