コード例 #1
0
 public function preSet(FormEvent $event)
 {
     $form = $event->getForm();
     $rootName = $form->getRoot()->getName();
     if (!$form->isRoot() && ($parent = $form->getParent())) {
         $name = $this->getDottedName($form);
         $fullName = $this->getFullName($rootName, $name);
         // Add input from the previous submit
         if ($form->getName() !== '_token' && $this->session->hasOldInput($fullName)) {
             // Get old value
             $value = $this->session->getOldInput($fullName);
             // Transform back to good data
             $value = $this->transformValue($event, $value);
             // Store on the form
             $event->setData($value);
         }
         if ($this->session->has('errors')) {
             /** @var \Illuminate\Support\ViewErrorBag $errors */
             $errors = $this->session->get('errors');
             if ($errors->has($name)) {
                 $form->addError(new FormError(implode(' ', $errors->get($name))));
             }
         }
     }
 }
コード例 #2
0
 /**
  * @param Organization   $organization
  * @param User           $user
  * @param SessionManager $sessionManager
  */
 function __construct(Organization $organization, User $user, SessionManager $sessionManager)
 {
     $this->organization = $organization;
     $this->user = $user;
     $this->sessionManager = $sessionManager;
     $this->orgId = $this->sessionManager->get('org_id');
 }
コード例 #3
0
 public function install(Request $request, PluginHandler $handler, PluginProvider $provider, ComposerFileWriter $writer, SessionManager $session)
 {
     $id = $request->get('pluginId');
     $handler->getAllPlugins(true);
     if ($handler->getPlugin($id) !== null) {
         throw new HttpException(422, 'Plugin already installed.');
     }
     // 자료실에서 플러그인 정보 조회
     $pluginData = $provider->find($id);
     if ($pluginData === null) {
         throw new HttpException(422, "Can not find the plugin(" . $id . ") that should be installed from the Market-place.");
     }
     $title = $pluginData->title;
     $name = $pluginData->name;
     $version = $pluginData->latest_release->version;
     $operation = $handler->getOperation($writer);
     if ($operation['status'] === ComposerFileWriter::STATUS_RUNNING) {
         throw new HttpException(422, "이미 진행중인 요청이 있습니다.");
     }
     $timeLimit = config('xe.plugin.operation.time_limit');
     $writer->reset()->cleanOperation();
     $writer->install($name, $version, Carbon::now()->addSeconds($timeLimit)->toDateTimeString())->write();
     $this->reserveOperation($writer, $timeLimit);
     $session->flash('alert', ['type' => 'success', 'message' => '새로운 플러그인을 설치중입니다.']);
     return XePresenter::makeApi(['type' => 'success', 'message' => '새로운 플러그인을 설치중입니다.']);
 }
コード例 #4
0
 public function __construct()
 {
     $this->sessionManager = app(SessionManager::class);
     if ($this->sessionManager->has('flash_messages')) {
         $this->messages = $this->sessionManager->get('flash_messages');
     }
 }
コード例 #5
0
 public function __construct(SessionManager $session, $messages = array())
 {
     $this->session = $session;
     if ($session->has($this->session_key)) {
         $messages = array_merge_recursive($session->get($this->session_key), $messages);
     }
     parent::__construct($messages);
 }
コード例 #6
0
 public function handle($request, \Closure $next)
 {
     $response = $next($request);
     if (!empty($flashMessages = $this->messageManager->getFlash())) {
         $this->sessionManager->flash('flash_messages', $flashMessages);
     }
     return $response;
 }
コード例 #7
0
ファイル: Session.php プロジェクト: mesour/laravel-bridges
 public function getValueForSection($section, $key = null, $default = null)
 {
     $values = $this->sessionManager->get($section);
     if (!$key) {
         return $values;
     }
     return isset($values[$key]) ? $values[$key] : $default;
 }
コード例 #8
0
ファイル: myhelpers.php プロジェクト: thaigialai1987/qlcv
 function getuserfolder()
 {
     $session = new Session('demo');
     if ($session->has('userfolder')) {
         $value = $session->get('userfolder');
     }
     return $value;
 }
コード例 #9
0
 public function handleProviderCallback(Guard $auth, Socialite $socialite, UsersService $userService, SessionManager $manager)
 {
     $user = $socialite->driver('facebook')->user();
     $authUser = $userService->findOrCreateByFacebook($user);
     $auth->login($authUser);
     $manager->driver()->save();
     return redirect('/');
 }
コード例 #10
0
ファイル: Toastr.php プロジェクト: whossun/laravel-toastr
 /**
  *
  * Add a flash message to session.
  *
  * @param string $type Must be one of info, success, warning, error.
  * @param string $message The flash message content.
  * @param string $title The flash message title.
  * @param array  $options The custom options.
  *
  * @return void
  */
 public function add($type, $message, $title = null, $options = [])
 {
     $types = ['error', 'info', 'success', 'warning'];
     if (!in_array($type, $types)) {
         throw new Exception("The {$type} remind message is not valid.");
     }
     $this->messages[] = ['type' => $type, 'title' => $title, 'message' => $message, 'options' => $options];
     $this->session->flash('toastr::messages', $this->messages);
 }
コード例 #11
0
 /**
  * Adds a CSRF field to the root form view.
  *
  * @param FormView      $view    The form view
  * @param FormInterface $form    The form
  * @param array         $options The options
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     if (!$view->parent && $options['compound']) {
         $token = $this->session->token();
         $factory = $form->getConfig()->getFormFactory();
         $csrfForm = $factory->createNamed('_token', 'hidden', $token, array('mapped' => false));
         $view->children['_token'] = $csrfForm->createView(null);
     }
 }
コード例 #12
0
 /**
  * Add notification.
  *
  * @param $type
  * @param $message
  * @param null  $title
  * @param array $options
  *
  * @return bool
  */
 public function add($type, $message, $title = null, $options = [])
 {
     $types = ['info', 'warning', 'success', 'error'];
     if (!in_array($type, $types)) {
         return false;
     }
     $this->notifications[] = ['type' => $type, 'title' => $title, 'message' => $message, 'options' => $options];
     $this->session->flash('toastr:notifications', $this->notifications);
 }
コード例 #13
0
ファイル: laravelManager.php プロジェクト: GBPcoder/tpanel
 public function startSession()
 {
     $encrypter = $this->createEncrypter();
     $manager = new SessionManager($this->laravel);
     $session = $manager->driver();
     $this->updateSessionId($encrypter, $session);
     $session->start();
     $this->bindNewSession($session);
 }
コード例 #14
0
ファイル: RequestTrait.php プロジェクト: Hiroto-K/HkApps
 /**
  * Get session.
  *
  * @param string|null $key
  * @param mixed       $default
  *
  * @return \Illuminate\Session\SessionManager|mixed
  */
 public function session($key = null, $default = null)
 {
     if (!isset($this->session)) {
         $this->session = app('session');
     }
     if (is_null($key)) {
         return $this->session;
     }
     return $this->session->get($key, $default);
 }
コード例 #15
0
 /**
  * Allows you retrieve the most recent social provider
  * authorized with.
  *
  * @return mixed
  */
 public function getRecentAuthData()
 {
     $providers = $this->session->get('__sp_auth.p');
     if (!$providers) {
         return null;
     }
     return array_first($providers, function ($provider) {
         return $provider === $this->session->get('__sp_auth.r');
     });
 }
コード例 #16
0
 /**
  * @param OrganizationManager   $organizationManager
  * @param SessionManager        $sessionManager
  * @param ActivityManager       $activityManager
  * @param UploadActivityManager $uploadActivityManager
  * @param UploadActivity        $uploadActivity
  * @param SettingsManager       $settingsManager
  */
 function __construct(OrganizationManager $organizationManager, SessionManager $sessionManager, ActivityManager $activityManager, UploadActivityManager $uploadActivityManager, UploadActivity $uploadActivity, SettingsManager $settingsManager)
 {
     $this->middleware('auth');
     $this->activityManager = $activityManager;
     $this->uploadActivity = $uploadActivity;
     $this->uploadActivityManager = $uploadActivityManager;
     $this->sessionManager = $sessionManager;
     $this->organizationId = $this->sessionManager->get('org_id');
     $this->organizationManager = $organizationManager;
     $this->settingsManager = $settingsManager;
 }
コード例 #17
0
 /**
  * @param Activity              $activity
  * @param IatiIdentifierManager $iatiIdentifierManager
  * @param Identifier            $identifier
  * @param OrganizationManager   $organizationManager
  * @param SessionManager        $sessionManager
  * @param ActivityManager       $activityManager
  */
 function __construct(Activity $activity, IatiIdentifierManager $iatiIdentifierManager, Identifier $identifier, OrganizationManager $organizationManager, SessionManager $sessionManager, ActivityManager $activityManager)
 {
     $this->middleware('auth');
     $this->activity = $activity;
     $this->iatiIdentifierManager = $iatiIdentifierManager;
     $this->identifier = $identifier;
     $this->organizationManager = $organizationManager;
     $this->sessionManager = $sessionManager;
     $this->organization_id = $this->sessionManager->get('org_id');
     $this->activityManager = $activityManager;
 }
コード例 #18
0
 public function store(Request $request, WidgetBoxHandler $handler, SessionManager $session)
 {
     if (!$request->user()->isAdmin()) {
         throw new AccessDeniedHttpException();
     }
     $this->validate($request, ['id' => 'required', 'title' => 'required']);
     $inputs = $request->only(['id', 'title']);
     $widgetbox = $handler->find($inputs['id']);
     if ($widgetbox) {
         throw new IDAlreadyExistsException();
     }
     $widgetbox = $handler->create($inputs);
     $session->flash('alert', ['type' => 'success', 'message' => '위젯박스가 생성되었습니다.']);
     return XePresenter::makeApi(['type' => 'success', 'message' => '생성했습니다.']);
 }
コード例 #19
0
 /**
  * Determine if the session is using cookie sessions.
  *
  * @return bool
  */
 protected function usingCookieSessions()
 {
     if (!$this->sessionConfigured()) {
         return false;
     }
     return $this->manager->driver()->getHandler() instanceof CookieSessionHandler;
 }
コード例 #20
0
ファイル: AdminController.php プロジェクト: hifone/dashboard
 /**
  * POST method for handling custom actions on the settings page.
  *
  * @param string $settingsName
  *
  * @return JSON
  */
 public function settingsCustomAction($settingsName)
 {
     $config = app('itemconfig');
     $actionFactory = app('admin_action_factory');
     $actionName = $this->request->input('action_name', false);
     //get the action and perform the custom action
     $action = $actionFactory->getByName($actionName);
     $data = $config->getDataModel();
     $result = $action->perform($data);
     //override the config options so that we can get the latest
     app('admin_config_factory')->updateConfigOptions();
     //if the result is a string, return that as an error.
     if (is_string($result)) {
         return response()->json(array('success' => false, 'error' => $result));
     } elseif (!$result) {
         $messages = $action->getOption('messages');
         return response()->json(array('success' => false, 'error' => $messages['error']));
     } else {
         $response = array('success' => true, 'actions' => $actionFactory->getActionsOptions(true));
         //if it's a download response, flash the response to the session and return the download link
         if (is_a($result, 'Symfony\\Component\\HttpFoundation\\BinaryFileResponse')) {
             $file = $result->getFile()->getRealPath();
             $headers = $result->headers->all();
             $this->session->put('administrator_download_response', array('file' => $file, 'headers' => $headers));
             $response['download'] = route('admin_file_download');
         } elseif (is_a($result, '\\Illuminate\\Http\\RedirectResponse')) {
             $response['redirect'] = $result->getTargetUrl();
         }
         return response()->json($response);
     }
 }
コード例 #21
0
 /**
  * POST method for switching a user's locale
  *
  * @param string	$locale
  *
  * @return JSON
  */
 public function switchLocale($locale)
 {
     if (in_array($locale, config('administrator.locales'))) {
         $this->session->put('administrator_locale', $locale);
     }
     return redirect()->back();
 }
コード例 #22
0
ファイル: Location.php プロジェクト: muhamadsyahril/location
 /**
  * Sets the location property to the drivers returned location object.
  *
  * @param string $ip
  */
 private function setLocation($ip = '')
 {
     // The location session key.
     $key = 'location';
     // Removes location from the session if config option is set
     if ($this->localHostForgetLocation()) {
         $this->session->forget($key);
     }
     // Check if the location has already been set in the current session
     if ($this->session->has($key)) {
         // Set the current driver to the current session location
         $this->location = $this->session->get($key);
     } else {
         $this->setIp($ip);
         $this->location = $this->driver->get($this->ip);
         // The locations object property 'error' will be true if an
         // exception has occurred trying to grab the location
         // from the driver. Let's try retrieving the
         // location from one of our fall-backs
         if ($this->location->error) {
             $this->location = $this->getLocationFromFallback();
         }
         $this->session->set($key, $this->location);
     }
 }
コード例 #23
0
 /**
  * @param RequestInterface $request
  * @return SessionInterface
  */
 private function getSession(RequestInterface $request)
 {
     $session = $this->manager->driver();
     $cookieData = FigRequestCookies::get($request, $session->getName());
     $session->setId($cookieData->getValue());
     return $session;
 }
コード例 #24
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app['session'] = $this->app->share(function ($app) {
         // First, we will create the session manager which is responsible for the
         // creation of the various session drivers when they are needed by the
         // application instance, and will resolve them on a lazy load basis.
         $manager = new SessionManager($app);
         $driver = $manager->driver();
         $config = $app['config']['session'];
         // Once we get an instance of the session driver, we need to set a few of
         // the session options based on the application configuration, such as
         // the session lifetime and the sweeper lottery configuration value.
         $driver->setLifetime($config['lifetime']);
         $driver->setSweepLottery($config['lottery']);
         return $driver;
     });
 }
コード例 #25
0
 /**
  * Create the cache based session handler instance.
  *
  * @param string $driver
  * @return \Illuminate\Session\CacheBasedSessionHandler
  */
 protected function createCacheHandler($driver)
 {
     $handler = parent::createCacheHandler($driver);
     if (!$this->validateCacheHandler($driver, $handler)) {
         throw new \UnexpectedValueException('Wrong cache driver found');
     }
     return $handler;
 }
コード例 #26
0
ファイル: Toastr.php プロジェクト: kamaln7/toastr
 /**
  * Add a notification
  *
  * @param string $type Could be error, info, success, or warning.
  * @param string $message The notification's message
  * @param string $title The notification's title
  *
  * @return bool Returns whether the notification was successfully added or 
  * not.
  */
 public function add($type, $message, $title = null, $options = array())
 {
     $allowedTypes = array('error', 'info', 'success', 'warning');
     if (!in_array($type, $allowedTypes)) {
         return false;
     }
     $this->notifications[] = array('type' => $type, 'title' => $title, 'message' => $message, 'options' => $options);
     $this->session->flash('toastr::notifications', $this->notifications);
 }
コード例 #27
0
 /**
  * getSession.
  *
  * @method getSession
  *
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Session\Store
  */
 protected function getSession($request)
 {
     $session = $this->sessionManager->driver();
     if ($session->isStarted() === false) {
         $session->setId($request->cookies->get($session->getName()));
         $session->setRequestOnHandler($request);
         $session->start();
     }
     return $session;
 }
コード例 #28
0
ファイル: Environment.php プロジェクト: creolab/alert
 /**
  * Write all alerts to session flash
  */
 public function setFlash()
 {
     $flash = array();
     foreach ($this->bag->getMessages() as $type => $messages) {
         foreach ($messages as $message) {
             $flash[$type][] = $message;
         }
     }
     $this->session->flash(self::SESSION_KEY, $flash);
 }
コード例 #29
0
 /**
  * {@inheritdoc}
  *
  * @see BaseFacebook::clearPersistentData()
  */
 protected function clearPersistentData($key)
 {
     if (!in_array($key, self::$kSupportedKeys)) {
         self::errorLog('Unsupported key passed to clearPersistentData.');
         return;
     }
     $session_var_name = $this->constructSessionVariableName($key);
     if ($this->laravelSession->has($session_var_name)) {
         $this->laravelSession->forget($session_var_name);
     }
 }
コード例 #30
0
 /**
  * Override to return our own Store/Encrypted store
  */
 protected function buildSession($handler)
 {
     if ($handler instanceof NullSessionHandler) {
         return parent::buildSession($handler);
     }
     if ($this->app['config']['session.encrypt']) {
         return new EncryptedStore($this->app['config']['session.cookie'], $handler, $this->app['encrypter']);
     } else {
         return new Store($this->app['config']['session.cookie'], $handler);
     }
 }