/** * Add request from poster to parent * * @param string $type * @param PosterInterface $poster * @param PosterInterface $parent * @param ContentInterface $object * * @return \Platform\Invitation\Model\Invitation */ public function addRequest($type, PosterInterface $poster, PosterInterface $parent, ContentInterface $object = null) { $data = ['type_id' => $type, 'poster_id' => $poster->getId(), 'user_id' => $poster->getUserId(), 'parent_id' => $parent->getId(), 'parent_user_id' => $parent->getUserId(), 'poster_type' => $poster->getType(), 'parent_type' => $parent->getType(), 'created_at' => KENDO_DATE_TIME]; if (null != $object) { $data = array_merge($data, ['object_id' => $object->getId(), 'object_type' => $object->getType()]); } $request = new Invitation($data); $request->save(); return $request; }
/** * @param array $context * * @return string */ public function toHtml($context = []) { $attrs = ['id' => $this->invitation->getId(), 'type' => $this->invitation->getType()]; return app()->viewHelper()->partial('platform/user/invitation/request-membership', ['headline' => $this->getHeadline(), 'poster' => $this->invitation->getPoster(), 'parent' => $this->invitation->getParent(), 'request' => $this->invitation, 'attrs' => $attrs]); }
/** * @param Invitation $invitation */ public function onAcceptRequestMembershipUser(Invitation $invitation) { /** * current viewer called to accept data */ $poster = $invitation->getPoster(); $parent = $invitation->getParent(); app()->relation()->acceptMembershipRequest($poster, $parent, false); }
/** * @param array $params * * @return string */ public function toHref($params = []) { return $this->invitation->getPoster()->toHref($params); }