예제 #1
0
 public static function fromModel(ContextModel $model)
 {
     $context = new self();
     $context->registration = $model->getRegistration();
     $context->revision = $model->getRevision();
     $context->platform = $model->getPlatform();
     $context->language = $model->getLanguage();
     if (null !== ($instructor = $model->getInstructor())) {
         $context->instructor = Object::fromModel($instructor);
     }
     if (null !== ($team = $model->getTeam())) {
         $context->team = Object::fromModel($team);
     }
     if (null !== ($contextActivities = $model->getContextActivities())) {
         $context->hasContextActivities = true;
         if (null !== ($parentActivities = $contextActivities->getParentActivities())) {
             $context->parentActivities = array();
             foreach ($parentActivities as $parentActivity) {
                 $activity = Object::fromModel($parentActivity);
                 $activity->parentContext = $context;
                 $context->parentActivities[] = $activity;
             }
         }
         if (null !== ($groupingActivities = $contextActivities->getGroupingActivities())) {
             $context->groupingActivities = array();
             foreach ($groupingActivities as $groupingActivity) {
                 $activity = Object::fromModel($groupingActivity);
                 $activity->groupingContext = $context;
                 $context->groupingActivities[] = $activity;
             }
         }
         if (null !== ($categoryActivities = $contextActivities->getCategoryActivities())) {
             $context->categoryActivities = array();
             foreach ($categoryActivities as $categoryActivity) {
                 $activity = Object::fromModel($categoryActivity);
                 $activity->categoryContext = $context;
                 $context->categoryActivities[] = $activity;
             }
         }
         if (null !== ($otherActivities = $contextActivities->getOtherActivities())) {
             $context->otherActivities = array();
             foreach ($otherActivities as $otherActivity) {
                 $activity = Object::fromModel($otherActivity);
                 $activity->otherContext = $context;
                 $context->otherActivities[] = $activity;
             }
         }
     } else {
         $context->hasContextActivities = false;
     }
     if (null !== ($statementReference = $model->getStatement())) {
         $context->statement = $statementReference->getStatementId()->getValue();
     }
     if (null !== ($contextExtensions = $model->getExtensions())) {
         $context->extensions = Extensions::fromModel($contextExtensions);
     }
     return $context;
 }
예제 #2
0
 function it_is_not_equal_with_other_statement_if_contexts_differ()
 {
     $context = new Context();
     $revisionContext = $context->withRevision('test');
     $platformContext = $context->withPlatform('test');
     $statement = $this->withContext($revisionContext);
     $this->withContext($platformContext)->equals($statement)->shouldReturn(false);
 }
예제 #3
0
 public static function getContextActivitiesAllPropertiesOnlyContext()
 {
     $context = new Context();
     return $context->withContextActivities(ContextActivitiesFixtures::getAllPropertiesActivities());
 }