1. Go to this page and download the library: Download gremo/subscription-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
public function registerBundles()
{
$bundles = array(
// ...
new Gremo\SubscriptionBundle\GremoSubscriptionBundle(),
// ...
);
// ...
}
use Gremo\SubscriptionBundle\Provider\ActivationDateProviderInterface;
use JMS\DiExtraBundle\Annotation as DI;
use Symfony\Component\Security\Core\SecurityContext;
/**
* @DI\Service("my_activation_provider")
*/
class MyActivationProvider implements ActivationDateProviderInterface
{
/**
* @var \Symfony\Component\Security\Core\SecurityContext
*/
private $context;
/**
* @DI\InjectParams({"context" = @DI\Inject("security.context")})
*/
public function __construct(SecurityContext $context)
{
$this->context = $context;
}
/**
* @return \DateTime
*/
public function getActivationDate()
{
$user = $this->context->getToken()->getUser();
return $user->getCreatedAt();
}
}
$subscription = $this->get('gremo_subscription'):
$currentPeriod = $subscription->getCurrentPeriod(); // Period from 2012-11-30 to 2012-12-29
$firstDate = $currentPeriod->getFirstDate(); // DateTime object (2012-11-30)
$lastDate = $currentPeriod->getLastDate(); // DateTime object (2012-12-29)
// Get periods count
$numPeriods = count($subscription); // 4
// Get the previous period
$previusPeriod = $subscription[$numPeriods - 1]; // Period from 2012-10-31 to 2012-11-29
// Loop over each day of the previous period
foreach($previusPeriod as date)
{
// ...
}
// Loop over each period
foreach($subscription as $period)
{
// ...
}
// Find out a period for the given date (may return null)
$period = $subscription->getPeriod(new \DateTime('2012-11-25')); // Period form 2012-10-01 to 2012-10-30
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.