pantheon-systems/pantheon-edge-integrations

This package is abandoned and no longer maintained. No replacement package was suggested.

Helper class for content personalization.

v1.1.0 2022-06-21 20:54 UTC

This package is auto-updated.

Last update: 2024-09-02 18:20:03 UTC


README

Archived project

This project is archived as of August 2024 as it no longer receives active development. The architecture provided by the tools in this SDK and the related projects are still valid and will continue to work on Pantheon AGCDN. However, we will not be responding to issues or pull requests or building these tools out more than they are already.

Unsupported Packagist Release VersionBuild Status

Pantheon Edge Integrations is a PHP library which uses header data to provide a personalization object, to be used for personalizing content for each user.

Installation

Pantheon Edge Integrations can be installed via Composer from Packagist...

composer require pantheon-systems/pantheon-edge-integrations

Usage

To make use of the PHP library, ensure PHP can use the class. After which, it's possible to etiher call the library through instanced methods, or through the global methods.

use Pantheon\EI\HeaderData;

Instanced Methods

Once the class is available, headerData objects can be instantiated to make use of the API and methods can be called on it.

$headerData = new HeaderData();

getHeader($key)

Uses header key to return raw header data.

$headerData->getHeader('Audience');
// => "geo:US"

$headerData->getHeader('Interest');
// => "27"

$headerData->getHeader('Role');
// => "subscriber"

parseHeader($key)

Uses header key to return parsed header data array.

$headerData->getHeader('Audience');
// => [geo => US]

$headerData->getHeader('Interest');
// => [0 => 27]

$headerData->getHeader('Role');
// => "subscriber"

returnPersonalizationObject()

Returns an array with personalization data.

$headerData->returnPersonalizedObject();
// => [
//        Audience => [ geo => US ]
//        Interest => [ 0 => 27 ]
//        Role => subscriber
//    ]

returnVaryHeader($key)

Returns vary header array, based on header data.

Global Methods

There are also static methods defined within the class to help assist in retrieving data without having to instantiate the object yourself.

HeaderData::personalizationObject()

Gets the global personalizaition object.

Pantheon\EI\HeaderData::personalizationObject();
// => [
//        Audience => [ geo => US ]
//        Interest => [ 0 => 27 ]
//        Role => subscriber
//    ]

HeaderData::parse($key)

Parses a global header by key using a specified regex.

Pantheon\EI\HeaderData::parse('Audience');
// => [geo => US]

HeaderData::header($key)

Gets the global header data based on the given key.

Pantheon\EI\HeaderData::header('Audience');
// => geo:US

HeaderData::varyHeader()

Returns vary header array based on the global data.

Pantheon\EI\HeaderData::varyHeader('geo');

Development

PHPUnit is used to run the tests.

composer install
composer test