Download the PHP package mothership-ec/cog-mothership-refer-a-friend without Composer

On this page you can find all versions of the php package mothership-ec/cog-mothership-refer-a-friend. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cog-mothership-refer-a-friend

Mothership Refer a Friend

The Message\Mothership\ReferAFriend cogule allows users to refer non-users to the site, and potentially receive a reward for doing so.

Referrals

The Referral object represents an instance where a user has referred someone to the site. The user can refer as many people as they like, but any email address may only be referred once. If a user attempts to refer someone who has already been referred, they will get an error message informing them. They can also only refer non-users.

The referral is made up of the following information:

Rewards

Reward types

Rewards can come in several types. Only one reward type is packaged with this module: no_reward. This type acts as a simple referral but the referrer does not get anything when the referral is marked as complete. It is marked as complete when the user registers with the site and logs in.

Reward configuration

Each reward type can be configured in its own way, using a set of Entities, which are stored against a Config class. There are three types of entity that can be stored against a configuration:

Each of these types have an associated collection which extends the Message\Cog\ValueObject\Collection class, and all entities are registered in the service container within an instance of their associated collection.

The Message\Mothership\ReferAFriend\Reward\Type\TypeInterface has three methods: validTriggers(); validConstraints(); and validRewardOptions(), to determine which entities apply to a specific reward type. These return one dimensional arrays of the names of these entities (returned by the entities' getName() methods).

Triggers

Triggers determine which event must be fired for a referral to be potentially marked as complete.

They must implement Message\Mothership\ReferAFriend\Reward\Config\Trigger\TriggerInterface.

The Referral object has a hasTriggered() method to quickly determine whether it has triggered. It takes the event name as its argument.

In order for a trigger to be effective, there must be an event listener listening out for the same event that loads the reward. This can then load the referral using a the email address, e.g.:

Note: The referral loader returns an array. All methods on the loader return an array of referrals, with the exception of getByID(). This is so that controllers know what to expect when calling the loader, and for future proofing if the module is ever changed to allow multiple referrals to be made to one address.

Triggers must be added by extending the refer.reward.config.triggers service in the service container, and adding them via the add() method on the collection:

Constraints

Constraints determine a rule that must be fulfilled for a referral to be marked as complete and a reward to be generated. This is stored in the database as a simple key/value pair.

They must implement Message\Mothership\ReferAFriend\Reward\Config\Constraint\ConstraintInterface. The constraint must be associated with a Symfony form type. This is returned using the getFormType() method on the constraint. Any options that should be put against this form field should be returned as an array by the getFormOptions() method on the constraint.

Constraints also have an isValid() method which take the referral as its first argument, and an instance of Message\Cog\Event\Event, which was fired to trigger the validation of the referral as its second parameter.

So to extend the example above, we can check the validity of the referral by looping through its constraints:

Note: While the ReferralInterface has a method of hasTriggered() to quickly access the triggers and check to see if it has been triggered, there is no isValid() method. The reason for this is that there may be circumstances where you may want to ignore a constraint under a certain circumstance.

Constraints must be added by extending the refer.reward.config.constraints service in the service container, and calling the add() method on the collection:

Reward options

Reward options are used to configure the reward, if any, that will be generated upon the successful completion of the referral. They must implement Message\Mothership\ReferAFriend\Reward\Config\RewardOption\RewardOptionInterface.

Like constraints, they are stored as a key/value pair, and they must be associated with a Symfony form type, and these are defined using the getFormType() and getFormOptions() methods.

Reward options must be added by extending the refer.reward.config.reward_options service in the service container, and calling the add() method on the collection:

Proxies

This module uses lazy loading on both the referrals and the reward configurations, and hence classes for Message\Mothership\ReferAFriend\Referral\ReferralProxy and Message\Mothership\ReferAFriend\Reward\Config\ConfigProxy exist. These classes hold the loaders for their entities, as well as any IDs that they may need for loading, rather than the entities themselves. They extend the getters to call the loaders to load them entities from the database and set them against themselves as and when they need them. Once they have been loaded once, they will retrieve them from memory instead of the database for the rest of the request. For example, in the ConfigProxy:


All versions of cog-mothership-refer-a-friend with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
mothership-ec/cog Version ~4.0
mothership-ec/cog-user Version ~2.0
mothership-ec/cog-mothership-cp Version ~3.0
mothership-ec/cog-mothership-cms Version ~4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mothership-ec/cog-mothership-refer-a-friend contains the following files

Loading the files please wait ....