/**
  * Return array of assigments to available deliveries.
  * Takes into account repeated delivery {@see RepeatedDeliveryService::CLASS_URI}
  * 
  * @see \oat\taoDeliveryRdf\model\GroupAssignment::getAssignments()
  */
 public function getAssignments(User $user)
 {
     $repeatedDeliveryService = $this->getServiceManager()->get(RepeatedDeliveryService::CONFIG_ID);
     $assignments = array();
     foreach (parent::getAssignmentFactories($user) as $factory) {
         $delivery = new \core_kernel_classes_Resource($factory->getDeliveryId());
         if ($repeatedDeliveryService->isRepeated($delivery)) {
             $assignments[] = $this->transform($delivery, $user);
         } else {
             $assignments[] = $factory;
             foreach ($this->getRepeatedAssignments($delivery, $user) as $repeat) {
                 $assignments[] = $repeat;
             }
         }
     }
     // will all be repeat assignments
     usort($assignments, function ($a, $b) {
         return $a->getStartTime() - $b->getStartTime();
     });
     $assignments = \tao_helpers_Array::array_unique($assignments);
     //$assignments = array_unique($assignments);
     $final = array();
     foreach ($assignments as $factory) {
         $final[] = $factory->toAssignment();
     }
     return $final;
 }
Beispiel #2
0
 /**
  * shall be used beyond high level http connections unit tests (default parameters)
  *
  * @param string $url url to call
  * @param string $method
  * @param string $returnType CURLINFO_HTTP_CODE, etc... (default returns rhe http response data
  * @param array $curlOptions (numeric arrays get interpreted as headers)
  * @return mixed
  */
 protected function curl($url, $method = CURLOPT_HTTPGET, $returnType = "data", $curlOptions = array())
 {
     $options = $this->getDefaultCurlOptions();
     if (!\tao_helpers_Array::isAssoc($curlOptions)) {
         $curlOptions = array(CURLOPT_HTTPHEADER => $curlOptions);
     }
     foreach ($curlOptions as $key => $value) {
         if (isset($options[$key]) && is_array($options[$key]) && is_array($value)) {
             $options[$key] = array_merge($options[$key], $value);
         } else {
             $options[$key] = $value;
         }
     }
     $process = curl_init($url);
     if ($method != "DELETE") {
         curl_setopt($process, $method, 1);
     } else {
         curl_setopt($process, CURLOPT_CUSTOMREQUEST, "DELETE");
     }
     curl_setopt_array($process, $options);
     $data = curl_exec($process);
     if ($returnType != "data") {
         $data = curl_getinfo($process, $returnType);
     }
     curl_close($process);
     return $data;
 }
Beispiel #3
0
 /**
  * @dataProvider arrayProvider
  */
 public function testArrayUnique($testArray, $expectedArray)
 {
     $result = \tao_helpers_Array::array_unique($testArray);
     $this->assertEquals($expectedArray, $result);
 }