Message-ID: <1038403852.3538.1485853532372.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3537_125717062.1485853532372" ------=_Part_3537_125717062.1485853532372 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html How to customize UserHash generation

How to customize UserHash generation

Version compatibility

Compatible with eZ Publish 5.25.3 and 2= 013.07 (up to 2014.11)

Deprecated

This recipe is deprecated as of 5.4 / 2014.11.
Use user context providers from FOSHttpCacheBundle instead.

 

=20 =20

Be sure to have read C= ontext aware HTTP cache documentation before reading this recipe.

Description

When user hash generation is requested, eZ Publish will create a hashable User Identity object.

One can add information to the Identity object making the resulted hash = vary. This can be done by registering Identity definers.

 

For this, all you need to do is to declare a service with = ezpublish.identity_definer tag. Class for this s= ervice must implement <= strong>eZ\Publish\SPI\User\IdentityAware i= nterface.

Example

services.yml (inside a bundle)
=20
parameters:
    my_identity_definer.class: Acme\TestBundle\Identity\MyDefiner
 
services:
    my_identity_definer:
        class: %my_identity_definer.class%
        tags:
            - { name: ezpublish.identity_definer }
=20
=20
<?php

namespace Acme\TestBundle\Identity;

use eZ\Publish\SPI\User\IdentityAware;
use eZ\Publish\SPI\User\Identity;

class MyDefiner implements IdentityAware
{
    public function setIdentity( Identity $identity )
    {
        // Here I can add information to $identity.
        // value MUST be scalar.
        $identity->setInformation( 'my_key', 'my_value' );
    }
}
=20

S= ecuring hash generation request

By default, hash generation requests are granted for localhost (12= 7.0.0.1::1fe80::1).

If you want to enlarge the scope (e.g. if your Varnish server is not run= ning on the same machine), you can override canGenerateUserHash(= ) protected method in your main kernel class (mostly EzPublishKernel).

------=_Part_3537_125717062.1485853532372--