/** * @param HookEvent $event */ public function onRoutingStart(HookEvent $event) { $routing = $event->getPayload(); if (!$routing instanceof RoutingManager) { return; } }
/** * @param \Kendo\Hook\HookEvent $event */ public function onBeforeBuildBundleJS(HookEvent $event) { $requirejs = $event->getPayload(); if (!$requirejs instanceof Requirejs) { return; } $requirejs->addDependency(['platform/layout/main']); }
/** * @param \Kendo\Hook\HookEvent $event */ public function onCompleteCreatePoster(HookEvent $event) { $item = $event->getPayload('poster'); $data = $event->getPayload('data', []); if (!$item instanceof CatalogInterface) { return; } app()->catalogService()->updateItemAttribute($item, $data); }
/** * @param HookEvent $event */ public function onAdminStatisticBlockRender(HookEvent $event) { $payload = $event->getPayload(); if (!$payload instanceof View) { return; } $stats = $payload->__get('stats'); $stats['page'] = ['label' => app()->text('page.pages'), 'value' => app()->pageService()->getActivePageCount()]; $payload->__set('stats', $stats); }
/** * @param HookEvent $event */ public function onRoutingStart(HookEvent $event) { $routing = $event->getPayload(); if (!$routing instanceof RoutingManager) { return; } $routing->add(['name' => 'messages', 'uri' => 'messages', 'defaults' => ['controller' => 'Platform\\Message\\Controller\\HomeController', 'action' => 'inbox-message']]); $routing->add(['name' => 'message_inbox', 'uri' => 'messages', 'defaults' => ['controller' => 'Platform\\Message\\Controller\\HomeController', 'action' => 'inbox-message']]); $routing->add(['name' => 'message_unread', 'uri' => 'unread-messages', 'defaults' => ['controller' => 'Platform\\Message\\Controller\\HomeController', 'action' => 'unread-message']]); $routing->add(['name' => 'message_sent', 'uri' => 'sent-message', 'defaults' => ['controller' => 'Platform\\Message\\Controller\\HomeController', 'action' => 'sent-message']]); $routing->add(['name' => 'message_compose', 'uri' => 'compose-message(/<recipientType>)(/<recipientId>)', 'defaults' => ['controller' => 'Platform\\Message\\Controller\\HomeController', 'action' => 'compose-message']]); }
/** * @param HookEvent $event */ public function onRequirejsRender(HookEvent $event) { $requirejs = $event->getPayload(); if (!$requirejs instanceof Requirejs) { return; } $staticUrl = app()->staticBaseUrl(); $requirejs->baseUrl($staticUrl . 'static/jscript'); // you have shim to bundles, do not shim here! $requirejs->addPaths(['jquery' => 'kendo/jquery/jquery', 'bootstrap' => 'kendo/bootstrap/bootstrap', 'jqueryui' => 'kendo/jquery-ui/jqueryui', 'underscore' => 'kendo/underscore/underscore.min', 'jquery-ext' => 'kendo/jquery-ext/jquery-ext', 'kd' => 'kendo/core/main'])->addDependency(['jquery', 'underscore', 'bootstrap', 'kd', 'jquery-ext'])->addPrimaryBundle(['jquery', 'underscore', 'bootstrap', 'kd', 'jquery-ext']); $options = ['baseUrl' => KENDO_BASE_URL, 'staticUrl' => $staticUrl, 'logged' => app()->auth()->logged(), 'isUser' => app()->auth()->isUser()]; $script = '$kd.setOptions(' . json_encode($options, JSON_PRETTY_PRINT) . ')'; $requirejs->prependScript('options', $script); }
/** * @param \Kendo\Hook\HookEvent $event */ public function onAfterDeleteShare(HookEvent $event) { $share = $event->getPayload(); if (!$share instanceof Share) { return; } $about = $share->getAbout(); if ($about instanceof AtomInterface) { $about->modify('share_count', 'share_count-1'); } }
/** * Check poster is user * * @param HookEvent $event */ public function onUserCreated(HookEvent $event) { $config = app()->setting('register'); $user = $event->getPayload(); if (!$user instanceof User) { return; } if (!$user->isVerified()) { // start process verify this member } else { // if active member } if ($config['email_verify'] = 1) { } if ($config['approval'] == '2') { } if ($config['notify_admin']) { } // process add after to handler all of this case. $user->setApproved(1); $user->setActive(1); $user->save(); }
/** * @param \Kendo\Hook\HookEvent $event */ public function onClearMembership(HookEvent $event) { $parent = $event->getPayload('parent'); $poster = $event->getPayload('poster'); if (!$poster instanceof PosterInterface or !$parent instanceof PosterInterface) { return; } app()->relation()->clearRelationItem($parent, $poster); /** * 2 ways membership need to required to clear */ if ($poster instanceof User && $parent instanceof User) { app()->relation()->clearRelationItem($poster, $parent); } }
/** * @param \Kendo\Hook\HookEvent $event */ public function onAfterDeleteComment(HookEvent $event) { $cmt = $event->getPayload(); if (!$cmt instanceof Comment) { return; } $about = $cmt->getAbout(); if ($about instanceof AtomInterface) { $about->modify('comment_count', 'comment_count-1'); } }
/** * @param \Kendo\Hook\HookEvent $event */ public function onCompleteCreatePoster(HookEvent $event) { $poster = $event->getPayload('poster'); $data = $event->getPayload('data', []); if (!empty($data['avatar'])) { app()->photoService()->setPosterAvatar($poster, $data['avatar']); } }
/** * @param \Kendo\Hook\HookEvent $event */ public function onAfterDeletePoster(HookEvent $event) { $poster = $event->getPayload(); if (!$poster instanceof PosterInterface) { return; } }
/** * @param \Kendo\Hook\HookEvent $event */ public function onAcceptMembershipRequest(HookEvent $event) { $parent = $event->getPayload('parent'); $poster = $event->getPayload('poster'); if (!$parent instanceof PosterInterface or !$poster instanceof PosterInterface) { return; } app()->notificationService()->addAcceptMembershipNotification($parent, $poster); }
/** * @param \Kendo\Hook\HookEvent $event */ public function onAfterDeleteLike(HookEvent $event) { $like = $event->getPayload(); if (!$like instanceof Like) { return; } $about = $like->getAbout(); if ($about instanceof AtomInterface) { $about->modify('like_count', 'like_count-1'); } }
/** * @param \Kendo\Hook\HookEvent $event */ public function onAcceptMembershipRequest(HookEvent $event) { $parent = $event->getPayload('parent'); $poster = $event->getPayload('poster'); if (!$parent instanceof PosterInterface or !$poster instanceof PosterInterface) { return; } app()->followService()->add($poster, $parent); /** * 2 ways friends for required. */ if ($parent instanceof User && $poster instanceof User) { app()->followService()->add($parent, $poster); } }
/** * @param \Kendo\Hook\HookEvent $event */ public function onAfterInsertMembershipRequest(HookEvent $event) { $payload = $event->getPayload(); if (!$payload instanceof MembershipRequest) { return; } $poster = $payload->getPoster(); $parent = $payload->getParent(); if (!$poster instanceof PosterInterface or !$parent instanceof PosterInterface) { return; } app()->invitationService()->addMembershipRequest($poster, $parent); }