/**
  * @param Request $request
  * @param Created $payload
  */
 public function created(Request $request, Created $payload)
 {
     $serializer = Activity::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 201, ['Location' => $resource->getLinks()['self']]);
 }
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = ActivityObject::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['activities']));
     $resource = $resource->fields($params->getFields(['activity-object' => ActivityObject::getSerializer()->getFields(), 'activity' => Activity::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
示例#3
0
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = User::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['sessions', 'groups', 'activities']));
     $resource = $resource->fields($params->getFields(['user' => User::getSerializer()->getFields(), 'session' => Session::getSerializer()->getFields(), 'group' => Group::getSerializer()->getFields(), 'activity' => Activity::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
示例#4
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $data = $payload->getModel();
     $serializer = User::getSerializer();
     $resource = new Collection($data, $serializer);
     $resource = $resource->with($params->getInclude(['sessions', 'groups', 'activities']));
     $resource = $resource->fields($params->getFields(['user' => User::getSerializer()->getFields(), 'session' => Session::getSerializer()->getFields(), 'group' => Group::getSerializer()->getFields(), 'activity' => Activity::getSerializer()->getFields()]));
     $document = new Document($resource);
     // meta
     if ($params->getPage('size') != -1) {
         $document->setMeta(['total' => $data->getNbResults(), 'first' => '%apiurl%/' . $serializer->getType(null) . '?' . $params->toQueryString(['page' => ['number' => $data->getFirstPage()]]), 'next' => '%apiurl%/' . $serializer->getType(null) . '?' . $params->toQueryString(['page' => ['number' => $data->getNextPage()]]), 'previous' => '%apiurl%/' . $serializer->getType(null) . '?' . $params->toQueryString(['page' => ['number' => $data->getPreviousPage()]]), 'last' => '%apiurl%/' . $serializer->getType(null) . '?' . $params->toQueryString(['page' => ['number' => $data->getLastPage()]])]);
     }
     // return response
     return new JsonResponse($document->toArray());
 }
示例#5
0
文件: User.php 项目: keeko/core
 /**
  * @param array $activity
  */
 public function newActivity(array $activity)
 {
     $resolver = new OptionsResolver();
     $resolver->setRequired(array('verb', 'object'));
     $resolver->setDefined(array('target'));
     $resolver->setAllowedTypes('target', array('keeko\\framework\\model\\ActivityObjectInterface', 'keeko\\core\\model\\ActivityObject'));
     $resolver->setAllowedTypes('object', array('keeko\\framework\\model\\ActivityObjectInterface', 'keeko\\core\\model\\ActivityObject'));
     $options = $resolver->resolve($activity);
     $obj = new Activity();
     $obj->setActor($this);
     $obj->setVerb($options['verb']);
     $obj->setObject($this->getActivityObject($options['object'], true));
     if (isset($options['target'])) {
         $obj->setTarget($this->getActivityObject($options['target']));
     }
     $obj->save();
 }
示例#6
0
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function read(Request $request, Found $payload)
 {
     $serializer = Activity::getSerializer();
     $relationship = $serializer->actor($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }
示例#7
0
 /**
  * Filter the query by a related \keeko\core\model\Activity object
  *
  * @param \keeko\core\model\Activity|ObjectCollection $activity the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildActivityObjectQuery The current query, for fluid interface
  */
 public function filterByActivityRelatedByTargetId($activity, $comparison = null)
 {
     if ($activity instanceof \keeko\core\model\Activity) {
         return $this->addUsingAlias(ActivityObjectTableMap::COL_ID, $activity->getTargetId(), $comparison);
     } elseif ($activity instanceof ObjectCollection) {
         return $this->useActivityRelatedByTargetIdQuery()->filterByPrimaryKeys($activity->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByActivityRelatedByTargetId() only accepts arguments of type \\keeko\\core\\model\\Activity or Collection');
     }
 }
示例#8
0
 /**
  */
 public function getRelationships()
 {
     return ['sessions' => Session::getSerializer()->getType(null), 'groups' => Group::getSerializer()->getType(null), 'activities' => Activity::getSerializer()->getType(null)];
 }
 /**
  */
 public function getRelationships()
 {
     return ['activities' => Activity::getSerializer()->getType(null)];
 }
示例#10
0
 /**
  * @param ChildActivity $activityRelatedByTargetId The ChildActivity object to add.
  */
 protected function doAddActivityRelatedByTargetId(ChildActivity $activityRelatedByTargetId)
 {
     $this->collActivitiesRelatedByTargetId[] = $activityRelatedByTargetId;
     $activityRelatedByTargetId->setTarget($this);
 }
示例#11
0
文件: User.php 项目: keeko/core
 /**
  * @param ChildActivity $activity The ChildActivity object to add.
  */
 protected function doAddActivity(ChildActivity $activity)
 {
     $this->collActivities[] = $activity;
     $activity->setActor($this);
 }
示例#12
0
 /**
  * Internal mechanism to set the Target id
  * 
  * @param Activity $model
  * @param mixed $relatedId
  */
 protected function doSetTargetId(Activity $model, $relatedId)
 {
     if ($model->getTargetId() !== $relatedId) {
         $model->setTargetId($relatedId);
         return true;
     }
     return false;
 }
示例#13
0
 /**
  * Exclude object from result
  *
  * @param   ChildActivity $activity Object to remove from the list of results
  *
  * @return $this|ChildActivityQuery The current query, for fluid interface
  */
 public function prune($activity = null)
 {
     if ($activity) {
         $this->addUsingAlias(ActivityTableMap::COL_ID, $activity->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }