Example #1
0
 public function __construct(ProfileObjectBuilder $builder)
 {
     parent::__construct($builder->getObjectID());
     $this->setGlobalID($builder->getGlobalID());
     $this->setDisplayName($builder->getDisplayName());
     $this->setParamArray($builder->getParamArray());
 }
Example #2
0
 public static function buildFromJSON($json)
 {
     // TODO parse and verify json
     $jsonObject = json_decode($json);
     $builder = new ProfileObjectBuilder();
     $builder->objectID($jsonObject->objectID)->globalID($jsonObject->globalID)->displayName($jsonObject->displayName);
     foreach (json_decode($json, true) as $key => $value) {
         if ($key != 'objectID' && $key != 'globalID' && $key != 'displayName' && $key != '@context' && $key != '@type') {
             $builder->param($key, $value);
         }
     }
     return $builder->build();
 }
Example #3
0
 public function testProfile()
 {
     $profile = (new ProfileObjectBuilder())->globalID(Sonic::getContextGlobalID())->displayName($this->aliceSocialRecord->getDisplayName())->param('x', 'y')->build();
     $this->assertTrue($profile->validate());
     $this->assertEquals($profile, ProfileObjectBuilder::buildFromJSON($profile->getJSONString()));
 }