Skip to content

Commit

Permalink
v1 & v2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
tmilos committed Feb 3, 2017
1 parent 512be77 commit cf2cc1c
Show file tree
Hide file tree
Showing 38 changed files with 4,803 additions and 1,368 deletions.
10 changes: 4 additions & 6 deletions src/Builder/AttributeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
namespace Tmilos\ScimSchema\Builder;

use Tmilos\ScimSchema\Model\Schema\Attribute;
use Tmilos\ScimSchema\Model\Schema\MutabilityValue;
use Tmilos\ScimSchema\Model\Schema\ReturnedValue;
use Tmilos\ScimSchema\Model\Schema\UniquenessValue;
use Tmilos\ScimSchema\ScimConstants;

class AttributeBuilder
{
Expand Down Expand Up @@ -73,9 +71,9 @@ public static function create($name, $type, $description = null)

protected function __construct()
{
$this->mutability = MutabilityValue::READ_WRITE;
$this->returned = ReturnedValue::BY_DEFAULT;
$this->uniqueness = UniquenessValue::NONE;
$this->mutability = ScimConstants::MUTABILITY_READ_WRITE;
$this->returned = ScimConstants::RETURNED_DEFAULT;
$this->uniqueness = ScimConstants::UNIQUENESS_NONE;
}

/**
Expand Down
37 changes: 19 additions & 18 deletions src/Builder/ResourceTypeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@

namespace Tmilos\ScimSchema\Builder;

use Tmilos\ScimSchema\Model\ResourceType;
use Tmilos\ScimSchema\Model\Schema;
use Tmilos\ScimSchema\Model\v2\ResourceType;
use Tmilos\ScimSchema\ScimConstants;
use Tmilos\ScimSchema\ScimConstantsV2;

class ResourceTypeBuilder
{
private static $builderMap = [
ResourceType::RESOURCE_TYPE => 'buildResourceType',
ResourceType::SCHEMA => 'buildSchema',
ResourceType::SERVICE_PROVIDER_CONFIG => 'buildServiceProviderConfig',
ResourceType::USER => 'buildUser',
ResourceType::GROUP => 'buildGroup',
ScimConstants::RESOURCE_TYPE_RESOURCE_TYPE => 'buildResourceType',
ScimConstants::RESOURCE_TYPE_SCHEMA => 'buildSchema',
ScimConstants::RESOURCE_TYPE_SERVICE_PROVIDER_CONFIG => 'buildServiceProviderConfig',
ScimConstants::RESOURCE_TYPE_USER => 'buildUser',
ScimConstants::RESOURCE_TYPE_GROUP => 'buildGroup',
];

private $locationBase = 'http://localhost';
Expand Down Expand Up @@ -57,11 +58,11 @@ public function build($resourceTypeId)
*/
public function buildResourceType()
{
$result = new ResourceType(ResourceType::RESOURCE_TYPE);
$result = new ResourceType(ScimConstants::RESOURCE_TYPE_RESOURCE_TYPE);
$result->setName('ResourceType');
$result->setDescription('Resource Type');
$result->setEndpoint('/ResourceTypes');
$result->setSchema(Schema::RESOURCE_TYPE);
$result->setSchema(ScimConstantsV2::SCHEMA_RESOURCE_TYPE);
$result->getMeta()->setLocation($this->locationBase.'/ResourceTypes/'.$result->getId());

return $result;
Expand All @@ -72,11 +73,11 @@ public function buildResourceType()
*/
public function buildSchema()
{
$result = new ResourceType(ResourceType::SCHEMA);
$result = new ResourceType(ScimConstants::RESOURCE_TYPE_SCHEMA);
$result->setName('Schema');
$result->setDescription('Schema');
$result->setEndpoint('/Schemas');
$result->setSchema(Schema::SCHEMA);
$result->setSchema(ScimConstantsV2::SCHEMA_SCHEMA);
$result->getMeta()->setLocation($this->locationBase.'/ResourceTypes/'.$result->getId());

return $result;
Expand All @@ -87,11 +88,11 @@ public function buildSchema()
*/
public function buildServiceProviderConfig()
{
$result = new ResourceType(ResourceType::SERVICE_PROVIDER_CONFIG);
$result = new ResourceType(ScimConstants::RESOURCE_TYPE_SERVICE_PROVIDER_CONFIG);
$result->setName('Service Provider Configuration');
$result->setDescription('Service Provider Configuration');
$result->setEndpoint('/ServiceProviderConfigs');
$result->setSchema(Schema::SERVICE_PROVIDER_CONFIG);
$result->setSchema(ScimConstantsV2::SCHEMA_SERVICE_PROVIDER_CONFIG);
$result->getMeta()->setLocation($this->locationBase.'/ResourceTypes/'.$result->getId());

return $result;
Expand All @@ -102,12 +103,12 @@ public function buildServiceProviderConfig()
*/
public function buildUser()
{
$result = new ResourceType(ResourceType::USER);
$result = new ResourceType(ScimConstants::RESOURCE_TYPE_USER);
$result->setName('User');
$result->setDescription('User Account');
$result->setEndpoint('/Users');
$result->setSchema(Schema::USER);
$result->addSchemaExtension(Schema::ENTERPRISE_USER, false);
$result->setSchema(ScimConstantsV2::SCHEMA_USER);
$result->addSchemaExtension(ScimConstantsV2::SCHEMA_ENTERPRISE_USER, false);
$result->getMeta()->setLocation($this->locationBase.'/ResourceTypes/'.$result->getId());

return $result;
Expand All @@ -118,11 +119,11 @@ public function buildUser()
*/
public function buildGroup()
{
$result = new ResourceType(ResourceType::GROUP);
$result = new ResourceType(ScimConstants::RESOURCE_TYPE_GROUP);
$result->setName('Group');
$result->setDescription('Group');
$result->setEndpoint('/Groups');
$result->setSchema(Schema::GROUP);
$result->setSchema(ScimConstantsV2::SCHEMA_GROUP);
$result->getMeta()->setLocation($this->locationBase.'/ResourceTypes/'.$result->getId());

return $result;
Expand Down
Loading

0 comments on commit cf2cc1c

Please sign in to comment.