mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 21:43:18 +00:00

Conflicts: lib/Alchemy/Phrasea/Command/Developer/JavascriptBuilder.php lib/Alchemy/Phrasea/Controller/Prod/Basket.php lib/Alchemy/Phrasea/Core/Provider/TaskManagerServiceProvider.php lib/classes/Exception/Feed/ItemNotFound.php lib/classes/Exception/Feed/PublisherNotFound.php lib/classes/Feed/Abstract.php lib/classes/Feed/Adapter.php lib/classes/Feed/Aggregate.php lib/classes/Feed/Collection.php lib/classes/Feed/CollectionInterface.php lib/classes/Feed/Entry/Adapter.php lib/classes/Feed/Entry/Collection.php lib/classes/Feed/Entry/Interface.php lib/classes/Feed/Entry/Item.php lib/classes/Feed/Entry/ItemInterface.php lib/classes/Feed/Interface.php lib/classes/Feed/Link.php lib/classes/Feed/LinkInterface.php lib/classes/Feed/Publisher/Adapter.php lib/classes/Feed/Publisher/Interface.php lib/classes/Feed/Token.php lib/classes/Feed/TokenAggregate.php lib/classes/Feed/XML/Abstract.php lib/classes/Feed/XML/Atom.php lib/classes/Feed/XML/Cooliris.php lib/classes/Feed/XML/Interface.php lib/classes/Feed/XML/RSS.php lib/classes/Feed/XML/RSS/ImageInterface.php lib/classes/http/request.php lib/classes/module/console/schedulerStart.php lib/classes/module/console/schedulerState.php lib/classes/module/console/schedulerStop.php lib/classes/module/console/taskState.php lib/classes/module/console/tasklist.php lib/classes/module/console/taskrun.php lib/classes/registry.php lib/classes/registryInterface.php lib/classes/set/order.php lib/classes/system/url.php lib/classes/task/Scheduler.php lib/classes/task/appboxAbstract.php lib/classes/task/databoxAbstract.php lib/classes/task/manager.php lib/classes/task/period/RecordMover.php lib/classes/task/period/apibridge.php lib/classes/task/period/archive.php lib/classes/task/period/cindexer.php lib/classes/task/period/emptyColl.php lib/classes/task/period/ftp.php lib/classes/task/period/ftpPull.php lib/classes/task/period/subdef.php lib/classes/task/period/test.php lib/classes/task/period/writemeta.php lib/conf.d/PhraseaFixture/AbstractWZ.php lib/conf.d/PhraseaFixture/Basket/LoadFiveBaskets.php lib/conf.d/PhraseaFixture/Basket/LoadOneBasket.php lib/conf.d/PhraseaFixture/Basket/LoadOneBasketEnv.php lib/conf.d/PhraseaFixture/Lazaret/LoadOneFile.php lib/conf.d/PhraseaFixture/Story/LoadOneStory.php lib/conf.d/PhraseaFixture/UsrLists/ListAbstract.php lib/conf.d/PhraseaFixture/UsrLists/UsrList.php lib/conf.d/PhraseaFixture/UsrLists/UsrListEntry.php lib/conf.d/PhraseaFixture/UsrLists/UsrListOwner.php lib/conf.d/PhraseaFixture/ValidationParticipant/LoadOneParticipant.php lib/conf.d/PhraseaFixture/ValidationParticipant/LoadParticipantWithSession.php lib/conf.d/PhraseaFixture/ValidationSession/LoadOneValidationSession.php
198 lines
4.0 KiB
PHP
198 lines
4.0 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2014 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Alchemy\Phrasea\Authentication\Provider\Token;
|
|
|
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
|
|
|
class Identity
|
|
{
|
|
const PROPERTY_ID = 'id';
|
|
const PROPERTY_IMAGEURL = 'image_url';
|
|
const PROPERTY_EMAIL = 'email';
|
|
const PROPERTY_FIRSTNAME = 'first_name';
|
|
const PROPERTY_LASTNAME = 'last_name';
|
|
const PROPERTY_USERNAME = 'username';
|
|
const PROPERTY_COMPANY = 'company';
|
|
|
|
private $data = [
|
|
self::PROPERTY_ID => null,
|
|
self::PROPERTY_IMAGEURL => null,
|
|
self::PROPERTY_EMAIL => null,
|
|
self::PROPERTY_FIRSTNAME => null,
|
|
self::PROPERTY_LASTNAME => null,
|
|
self::PROPERTY_USERNAME => null,
|
|
self::PROPERTY_COMPANY => null,
|
|
];
|
|
|
|
public function __construct(array $data = [])
|
|
{
|
|
$this->data = array_merge($this->data, $data);
|
|
}
|
|
|
|
/**
|
|
* Returns an associated array of the current identity properies.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function all()
|
|
{
|
|
return array_filter($this->data);
|
|
}
|
|
|
|
/**
|
|
* Returns the display name (first and last name)
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getDisplayName()
|
|
{
|
|
$data = array_filter([
|
|
$this->get(self::PROPERTY_FIRSTNAME),
|
|
$this->get(self::PROPERTY_LASTNAME),
|
|
]);
|
|
|
|
return implode(' ', $data);
|
|
}
|
|
|
|
/**
|
|
* Returns the id
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getId()
|
|
{
|
|
return $this->get(self::PROPERTY_ID);
|
|
}
|
|
|
|
/**
|
|
* Returns the first name
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getFirstname()
|
|
{
|
|
return $this->get(self::PROPERTY_FIRSTNAME);
|
|
}
|
|
|
|
/**
|
|
* Returns the last name
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getLastname()
|
|
{
|
|
return $this->get(self::PROPERTY_LASTNAME);
|
|
}
|
|
|
|
/**
|
|
* Returns the image URI
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getImageURI()
|
|
{
|
|
return $this->get(self::PROPERTY_IMAGEURL);
|
|
}
|
|
|
|
/**
|
|
* Returns the email
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getEmail()
|
|
{
|
|
return $this->get(self::PROPERTY_EMAIL);
|
|
}
|
|
|
|
/**
|
|
* Returns the username
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getUsername()
|
|
{
|
|
return $this->get(self::PROPERTY_USERNAME);
|
|
}
|
|
|
|
/**
|
|
* Returns the company name
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getCompany()
|
|
{
|
|
return $this->get(self::PROPERTY_COMPANY);
|
|
}
|
|
|
|
/**
|
|
* Returns true if the property exists
|
|
*
|
|
* @param $property string
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function has($property)
|
|
{
|
|
return isset($this->data[$property]);
|
|
}
|
|
|
|
/**
|
|
* Get a property value
|
|
*
|
|
* @param $property string
|
|
*
|
|
* @return string
|
|
*
|
|
* @throws InvalidArgumentException In case the property does not exists
|
|
*/
|
|
public function get($property)
|
|
{
|
|
if (!array_key_exists($property, $this->data)) {
|
|
throw new InvalidArgumentException(sprintf('Property %s does not exist', $property));
|
|
}
|
|
|
|
return $this->data[$property];
|
|
}
|
|
|
|
/**
|
|
* Set a property
|
|
*
|
|
* @param $property string
|
|
* @param $value string
|
|
*
|
|
* @return Identity
|
|
*/
|
|
public function set($property, $value)
|
|
{
|
|
$this->data[$property] = $value;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Removes the property
|
|
*
|
|
* @return string The value that was stored for the given property
|
|
*/
|
|
public function remove($property)
|
|
{
|
|
if (!array_key_exists($property, $this->data)) {
|
|
throw new InvalidArgumentException(sprintf('Property %s does not exist', $property));
|
|
}
|
|
|
|
$value = $this->data[$property];
|
|
unset($this->data[$property]);
|
|
|
|
return $value;
|
|
}
|
|
}
|