2017 © Pedro Peláez
 

library silex-timeline

image

shineunited/silex-timeline

  • Thursday, September 28, 2017
  • by shineunited
  • Repository
  • 3 Watchers
  • 0 Stars
  • 345 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 2 % Grown

The README.md

Silex Timeline

A Silex package for managing time-dependent content in templates and routes., (*1)

Latest Stable Version Minimum PHP Version Build Status, (*2)

Installation

The recommend way to install is through composer:, (*3)

$ composer require shineunited/silex-timeline

Configuration

<?php

require_once(__DIR__ . '/../vendor/autoload.php');

use Silex\Application;
use ShineUnited\Silex\Timeline\TimelineServiceProvider;

$app = new Application();

$app->register(new TimelineServiceProvider(), [
    'timeline.timezone' => 'UTC',
    'timeline.epochs'   => [
        'epoch1' => 'Monday, 15-Aug-2005 15:52:01',
        'epoch2' => '2005-08-15T15:52:01',
        'epoch3' => new \DateTimeImmutable('15-Aug-05 15:52:01')
    ]
]);

Usage

Adding Epochs

<?php

// add epochs directly
$app['timeline']['epoch4'] = 'Monday, 15-Aug-2005 15:52:01';
$app['timeline']['epoch5'] = '15 Aug 2005 15:52:01';
$app['timeline']['epoch6'] = new \DateTimeImmutable('15-Aug-05 15:52:01');

Fetching Epochs

By Array Reference
<?php

$app['timeline']['now'];
$app['timeline']['epoch1'];
$app['timeline']['epoch2'];
$app['timeline']['epoch3'];
By Param Reference
<?php

$app['timeline']->now;
$app['timeline']->epoch1;
$app['timeline']->epoch2;
$app['timeline']->epoch3;

Comparing Epochs

Timeline Functions
<?php

// isBefore
if($app['timeline']->isBefore('epoch1')) {
    // before 'epoch1'
}

// isAfter
if($app['timeline']->isAfter('epoch1')) {
    // before 'epoch1'
}

// isUpcoming
if($app['timeline']->isUpcoming('epoch1')) {
    // before 'epoch1'
}

// isComplete
if($app['timeline']->isComplete('epoch1')) {
    // before 'epoch1'
}
Epoch Functions
<?php
// isBefore
if($epoch->isBefore('epoch1')) {
    // $epoch is before 'epoch1'
}

// isAfter
if($epoch->isAfter('epoch1')) {
    // $epoch is after 'epoch1'
}
Direct Comparison
<?php

// by array reference
if($app['timeline']['now'] < $app['timeline']['epoch1']) {
    // before 'epoch1'
}

if($app['timeline']['now'] >= $app['timeline']['epoch1']) {
    // after 'epoch1'
}

// by param reference
if($app['timeline']->now < $app['timeline']->epoch1) {
    // before 'epoch1'
}

if($app['timeline']->now >= $app['timeline']->epoch1) {
    // before 'epoch1'
}

Twig Templates

Twig Operators
{# before operator #}
{% if before "epoch" %}
    BEFORE
{% else %}
    AFTER
{% endif %}
{# after operator #}
{% if after "epoch" %}
    AFTER
{% else %}
    BEFORE
{% endif %}
Twig Functions
{# isBefore function #}
{% if isBefore("epoch") %}
    BEFORE
{% else %}
    AFTER
{% endif %}
{# isAfter function #}
{% if isAfter("epoch") %}
    AFTER
{% else %}
    BEFORE
{% endif %}
{# isUpcoming function #}
{% if isUpcoming("epoch") %}
    UPCOMING
{% else %}
    COMPLETE
{% endif %}
{# isComplete function #}
{% if isComplete("epoch") %}
    COMPLETE
{% else %}
    UPCOMING
{% endif %}
Twig Tests
{# upcoming test #}
{% if "epoch" is upcoming %}
    UPCOMING
{% else %}
    COMPLETE
{% endif %}
{# complete test #}
{% if "epoch" is complete %}
    COMPLETE
{% else %}
    UPCOMING
{% endif %}

The Versions

28/09 2017

2.0.x-dev

2.0.9999999.9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

twig silex timeline

28/09 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

twig silex timeline

28/09 2017

2.0.1

2.0.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

twig silex timeline

28/09 2017

1.0.x-dev

1.0.9999999.9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

twig silex timeline

28/09 2017

1.0.1

1.0.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

twig silex timeline

15/09 2017

2.0.0

2.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

twig silex timeline

15/09 2017

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

twig silex timeline