2017 © Pedro Peláez
 

symfony-bundle smartcode-bundle

This bundle provides a way to generate software licenses with Symfony2

image

intracto/smartcode-bundle

This bundle provides a way to generate software licenses with Symfony2

  • Friday, March 24, 2017
  • by tvlooy
  • Repository
  • 24 Watchers
  • 4 Stars
  • 1,413 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 7 % Grown

The README.md

Needs maintainer

If you use this bundle, contact @tvlooy about ownership., (*1)

SmartCodeBundle Run tests Scrutinizer

This bundle provides a way to generate software licenses for a given payload., (*2)

It has been inspired by the Promotion Bundle of Sylius., (*3)

How to install?

Install the bundle via composer, (*4)

composer require intracto/smartcode-bundle

Enable the bundle, (*5)

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    // ...

    public function registerBundles()
    {
        $bundles = array(
            // ...,
            new Intracto\SmartCodeBundle\SmartCodeBundle(),
        );

        // ...
    }
}

How to run tests?


php bin/phpunit

How to get started?

Smart codes have to be bound to a payload this can be done by implementing the PayloadInterface., (*6)

    use Intracto\SmartCodeBundle\Entity\PayloadInterface;
    use Intracto\SmartCodeBundle\Entity\SmartCodeInterface;

    class Payload implements PayloadInterface
    {

        ...

        /**
         * @ORM\OneToMany(targetEntity="Intracto\SmartCodeBundle\Entity\SmartCodeInterface", mappedBy="payload")
         *
         * @var SmartCodes[]|ArrayCollection
         */
        protected $smartCodes;

        ...
    }

Now you can get started with the generation. To generate Smart codes you can use the SmartCodeGenerator or create your own by implementing the SmartCodeGeneratorInterface., (*7)

This service will allow you to call the function:, (*8)

    public function generate(PayloadInterface $payload, SmartCodeOptions $options)

As you can see this has 2 parameters, the first is your payload that you created in step 1 and the 2nd is a model containing all your options., (*9)

    class SmartCodeOptions
    {
        protected $amount;
        protected $usageLimit;
        protected $expiresAt;
        protected $startsAt;
        protected $batch;

        ...
    }
  • Amount: The amount of smart codes you wish to generate for the given payload.
  • UsageLimit: The amount of times a smart code can be used.
  • ExpiresAt: The expiry date for a smart code.
  • StartsAt: The date a smart code can start being used.
  • Batch: A name or description you want to give the current generation.

The last thing you would probably want to do is to be able to use these smart codes you just generated. This is possible via the SmartCodeAction service, which you can also overwrite by implementing the SmartCodeActionInterface., (*10)

This class has 2 required functions:, (*11)

   public function register(SubjectInterface $subject, SmartCodeInterface $smartCode);

   public function unregister(SubjectInterface $subject, SmartCodeInterface $smartCode);

To register or unregister a certain smart code you would need a subject that is going to be using this code. To make such a subject you can implement the SubjectInterface., (*12)

    use Intracto\SmartCodeBundle\Entity\SmartCodeInterface;
    use Intracto\SmartCodeBundle\Entity\SubjectInterface;

    class User implements SubjectInterface
    {

        ...

        /**
         * @ORM\ManyToMany(targetEntity="Intracto\SmartCodeBundle\Entity\SmartCodeInterface", inversedBy="subjects")
         * @ORM\JoinTable(name="user_smartcode",
         *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
         *      inverseJoinColumns={@ORM\JoinColumn(name="smartcode_id", referencedColumnName="id")}
         *      )
         *
         * @var SmartCode[]|ArrayCollection
         */
        protected $smartCodes;

        ...

    }

The Versions

24/03 2017

dev-master

9999999-dev https://github.com/intracto

This bundle provides a way to generate software licenses with Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

generate software licenses

24/03 2017

v1.2.1

1.2.1.0 https://github.com/intracto

This bundle provides a way to generate software licenses with Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

generate software licenses

04/06 2015

1.2

1.2.0.0 https://github.com/intracto

This bundle provides a way to generate software licenses with Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

generate software licenses

12/05 2015

v1.1

1.1.0.0 https://github.com/intracto

This bundle provides a way to generate software licenses with Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

generate software licenses

12/05 2015

v1.0.1

1.0.1.0 https://github.com/intracto

This bundle provides a way to generate software licenses with Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

generate software licenses

05/05 2015

v1.0

1.0.0.0 https://github.com/intracto

This bundle provides a way to generate software licenses with Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

generate software licenses