/** * @return string * @throws NotFoundException */ protected function getMethodName() { $methodName = 'action' . str_replace(' ', '', ucwords(str_replace(['_', '-', '.'], [' ', ' ', ' '], $this->request->getActionName()))); if (!method_exists($this, $methodName)) { throw new NotFoundException("{$methodName} does not support in " . get_class($this)); } return $methodName; }
/** * @return string * @throws NotFoundException */ protected function getMethodName() { $methodName = 'action' . str_replace(' ', '', ucwords(str_replace(['_', '-', '.'], [' ', ' ', ' '], $this->request->getActionName()))); if (!method_exists($this, $methodName)) { $msg = strtr(":controller:::method does not support", [':controller' => $this->request->getControllerName(), ':method' => $methodName]); throw new NotFoundException($msg); } return $methodName; }
public function dump() { $exception = $this->request->getException(); if ($exception) { $message = $exception->getMessage(); if (!empty($message)) { echo sprintf('"%s"', $message); } else { echo var_export($exception, 1); } } }
/** * @param HttpRequest $request * @param PosterInterface $poster * @param PosterInterface $parent * * @return \Platform\Feed\Model\Feed */ public function addFromCommentComposer(HttpRequest $request, PosterInterface $poster, PosterInterface $parent) { $privacy = $request->getArray('privacy'); $privacyType = 1; $privacyValue = 1; if (!empty($privacy)) { $privacyType = $privacy['type']; $privacyValue = $privacy['value']; } $data = $request->getArray('video'); $video = $this->addVideo($poster, $parent, $data, $privacyType, $privacyValue); return $video; }
/** * Add photo from activity composer * * @see FeedController::actionPost() * * @param HttpRequest $request * @param PosterInterface $poster * @param PosterInterface $parent * * @return \Platform\Feed\Model\Feed */ public function addFromActivityComposer(HttpRequest $request, PosterInterface $poster, PosterInterface $parent) { // process upload photo to handler set. $photoTemp = $request->getArray('photoTemp'); $fileIdList = $this->processPhotoUploadFromTemporary($photoTemp, null); $object = null; $feed = null; $album = $this->getSingletonAlbum($parent); if (!$album instanceof PhotoAlbum) { throw new \InvalidArgumentException(); } list($totalPhoto, $photoList, $album, $collection) = $this->addPhotos($fileIdList, $poster, $parent, $album, [], false); if ($totalPhoto == 1) { $object = $photoList[0]; } if ($totalPhoto > 1) { $object = $collection; } // process to add feed $activityService = app()->feedService(); if ($object instanceof PhotoCollection) { $feed = $activityService->addItemFeed('update_status', $object); } else { if ($object instanceof Photo) { $feed = $activityService->addItemFeed('update_status', $object); } } $statusTxt = $request->getString('statusTxt'); $place = $request->getArray('place'); if (!empty($place)) { foreach ($photoList as $photo) { if (!$photo instanceof Photo) { } $photo->setPlace($place); $photo->save(); } } $shouldUpdate = false; if ($statusTxt) { $object->setStory($statusTxt); $shouldUpdate = true; } if (!empty($place)) { $object->setPlace($place); $shouldUpdate = true; } $people = $request->getArray('people'); if (!empty($people)) { $peopleCount = app()->tagService()->tagPeople($object, $people); $object->setPeopleCount($peopleCount); $shouldUpdate = true; } if ($shouldUpdate) { $object->save(); } return $feed; }
/** * @param HttpRequest $request * @param PosterInterface $poster * @param PosterInterface $parent * * @return Feed */ public function addFromActivityComposer(HttpRequest $request, PosterInterface $poster, PosterInterface $parent) { $privacy = $request->getArray('privacy'); $privacyType = 1; $privacyValue = 1; if (!empty($privacy)) { $privacyType = $privacy['type']; $privacyValue = $privacy['value']; } $statusTxt = $request->getString('statusTxt'); $status = $this->addStatus($statusTxt, $poster, $parent, $privacyType, $privacyValue); $needUpdate = false; $place = $request->getArray('place'); if (!empty($place)) { $status->setPlace($place); $needUpdate = true; } $people = $request->getArray('people'); if (!empty($people)) { $status->setPeople($people); $needUpdate = true; } if ($needUpdate) { $status->save(); } $feed = $this->addItemFeed('update_status', $status); return $feed; }
/** * @param HttpRequest $request * @param PosterInterface $poster * @param PosterInterface $parent * * @return Feed */ public function addFromActivityComposer(HttpRequest $request, PosterInterface $poster, PosterInterface $parent) { $privacy = $request->getArray('privacy'); $privacyType = 1; $privacyValue = 1; if (!empty($privacy)) { $privacyType = $privacy['type']; $privacyValue = $privacy['value']; } $story = $request->getString('statusTxt'); $data = $request->getArray('link'); $data['story'] = $story; $link = $this->addLink($data, $poster, $parent, $privacyType, $privacyValue); $needUpdate = false; $place = $request->getArray('place'); if (!empty($place)) { $link->setPlace($place); $needUpdate = true; } $people = $request->getArray('people'); if (!empty($people)) { $link->setPeople($people); $needUpdate = true; } if ($needUpdate) { $link->save(); } $feed = app()->feedService()->addItemFeed('update_status', $link); return $feed; }
/** * @param HttpRequest $request * * @return bool */ public function resolve(HttpRequest $request) { /** * pre-filter to match request */ if (KENDO_PROFILER) { $profilerKey = app()->profiler()->start('request', 'routing.resolve', $request->getPath()); } $path = $request->getPath(); $host = null; $result = new RoutingResult([]); $matched = false; // ensure it's not children foreach ($this->masters as $name => $route) { if (!$route->resolve($path, $host, $result)) { continue; } $vars = $result->getVars(); $request->setControllerName($vars[HttpRequest::CONTROLLER_KEY]); $request->setActionName($vars[HttpRequest::ACTION_KEY]); unset($vars[HttpRequest::CONTROLLER_KEY], $vars[HttpRequest::ACTION_KEY]); $request->setParams($vars); $matched = true; break; } if (!$matched) { $request->setControllerName('Platform\\Core\\Controller\\ErrorController'); $request->setActionName('404'); } if (KENDO_PROFILER and !empty($profilerKey)) { app()->profiler()->stop($profilerKey); } return true; }