當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Facades\Event類代碼示例

本文整理匯總了PHP中Illuminate\Support\Facades\Event的典型用法代碼示例。如果您正苦於以下問題:PHP Event類的具體用法?PHP Event怎麽用?PHP Event使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Event類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getRename

 /**
  * @return string
  */
 public function getRename()
 {
     $old_name = Input::get('file');
     $new_name = trim(Input::get('new_name'));
     $file_path = parent::getPath('directory');
     $thumb_path = parent::getPath('thumb');
     $old_file = $file_path . $old_name;
     if (!File::isDirectory($old_file)) {
         $extension = File::extension($old_file);
         $new_name = str_replace('.' . $extension, '', $new_name) . '.' . $extension;
     }
     $new_file = $file_path . $new_name;
     if (Config::get('lfm.alphanumeric_directory') && preg_match('/[^\\w-]/i', $new_name)) {
         return Lang::get('laravel-filemanager::lfm.error-folder-alnum');
     } elseif (File::exists($new_file)) {
         return Lang::get('laravel-filemanager::lfm.error-rename');
     }
     if (File::isDirectory($old_file)) {
         File::move($old_file, $new_file);
         Event::fire(new FolderWasRenamed($old_file, $new_file));
         return 'OK';
     }
     File::move($old_file, $new_file);
     if ('Images' === $this->file_type) {
         File::move($thumb_path . $old_name, $thumb_path . $new_name);
     }
     Event::fire(new ImageWasRenamed($old_file, $new_file));
     return 'OK';
 }
開發者ID:unisharp,項目名稱:laravel-filemanager,代碼行數:32,代碼來源:RenameController.php

示例2: listen

 protected function listen(DataProvider $provider)
 {
     Event::listen(DataProvider::EVENT_FETCH_ROW, function (DataRow $row, DataProvider $provider) use($provider) {
         if ($provider !== $provider) {
             return;
         }
         $this->rows_processed++;
         foreach ($this->fields as $field) {
             $name = $field->getName();
             $operation = $this->getFieldOperation($name);
             switch ($operation) {
                 case self::OPERTATION_SUM:
                     $this->src[$name] += $row->getCellValue($field);
                     break;
                 case self::OPERATION_COUNT:
                     $this->src[$name] = $this->rows_processed;
                     break;
                 case self::OPERATION_AVG:
                     if (empty($this->src["{$name}_sum"])) {
                         $this->src["{$name}_sum"] = 0;
                     }
                     $this->src["{$name}_sum"] += $row->getCellValue($field);
                     $this->src[$name] = round($this->src["{$name}_sum"] / $this->rows_processed, 2);
                     break;
                 default:
                     throw new Exception("TotalsRow:Unknown aggregation operation.");
             }
         }
     });
 }
開發者ID:creativify,項目名稱:Grids,代碼行數:30,代碼來源:TotalsRow.php

示例3: start

 /**
  * Prepares a new WebSocket server on a specified host & port.
  *
  * @param  string $tcpid
  *
  * @return YnievesDotNet\FourStream\FourStream\FourStreamServer
  */
 public function start($tcpid)
 {
     $oldNode = FSNode::all();
     echo "Closing old nodes", "\n";
     foreach ($oldNode as $node) {
         $node->delete();
     }
     $this->server = new Websocket(new Socket($tcpid));
     $this->server->on('open', function (Bucket $bucket) {
         Event::fire(new Events\ConnectionOpen($bucket));
     });
     $this->server->on('message', function (Bucket $bucket) {
         Event::fire(new Events\MessageReceived($bucket));
     });
     $this->server->on('binary-message', function (Bucket $bucket) {
         Event::fire(new Events\BinaryMessageReceived($bucket));
     });
     $this->server->on('ping', function (Bucket $bucket) {
         Event::fire(new Events\PingReceived($bucket));
     });
     $this->server->on('error', function (Bucket $bucket) {
         Event::fire(new Events\ErrorGenerated($bucket));
     });
     $this->server->on('close', function (Bucket $bucket) {
         Event::fire(new Events\ConnectionClose($bucket));
     });
     return $this;
 }
開發者ID:ynievesdotnet,項目名稱:fourstream,代碼行數:35,代碼來源:FourStreamServer.php

示例4: testPermanentlyDeleteUser

 public function testPermanentlyDeleteUser()
 {
     // Make sure our events are fired
     Event::fake();
     $this->actingAs($this->admin)->delete('/admin/access/user/' . $this->user->id)->notSeeInDatabase('users', ['id' => $this->user->id, 'deleted_at' => null])->visit('/admin/access/user/' . $this->user->id . '/delete')->seePageIs('/admin/access/user/deleted')->see('The user was deleted permanently.')->notSeeInDatabase('users', ['id' => $this->user->id]);
     Event::assertFired(UserPermanentlyDeleted::class);
 }
開發者ID:rappasoft,項目名稱:laravel-5-boilerplate,代碼行數:7,代碼來源:UserRouteTest.php

示例5: register

 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     $configPath = __DIR__ . '/../config/sql-logging.php';
     $this->mergeConfigFrom($configPath, 'sql-logging');
     if (config('sql-logging.log', false)) {
         Event::listen('illuminate.query', function ($query, $bindings, $time) {
             $data = compact('bindings', 'time');
             // Format binding data for sql insertion
             foreach ($bindings as $i => $binding) {
                 if ($binding instanceof \DateTime) {
                     $bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
                 } else {
                     if (is_string($binding)) {
                         $bindings[$i] = "'{$binding}'";
                     }
                 }
             }
             // Insert bindings into query
             $query = str_replace(array('%', '?'), array('%%', '%s'), $query);
             $query = vsprintf($query, $bindings);
             $log = new Logger('sql');
             $log->pushHandler(new StreamHandler(storage_path() . '/logs/sql-' . date('Y-m-d') . '.log', Logger::INFO));
             // add records to the log
             $log->addInfo($query, $data);
         });
     }
 }
開發者ID:oscaragcp,項目名稱:sql-logging,代碼行數:32,代碼來源:SqlLoggingServiceProvider.php

示例6: testLogoutRoute

 /**
  * Test the logout button redirects the user back to home and the login button is again visible
  */
 public function testLogoutRoute()
 {
     // Make sure our events are fired
     Event::fake();
     $this->actingAs($this->user)->visit('/logout')->see('Login')->see('Register');
     Event::assertFired(UserLoggedOut::class);
 }
開發者ID:rappasoft,項目名稱:laravel-5-boilerplate,代碼行數:10,代碼來源:LoggedInRouteTest.php

示例7: boot

 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     Event::listen('Aacotroneo\\Saml2\\Events\\Saml2LoginEvent', function (Saml2LoginEvent $event) {
         $user = $event->getSaml2User();
         /*$userData = [
               'id' => $user->getUserId(),
               'attributes' => $user->getAttributes(),
               'assertion' => $user->getRawSamlAssertion()
           ];*/
         $laravelUser = User::where("username", "=", $user->getUserId())->get()->first();
         if ($laravelUser != null) {
             Auth::login($laravelUser);
         } else {
             //if first user then create it and login
             $count = \App\User::all()->count();
             if ($count == 0) {
                 $data = array();
                 $data['lastname'] = "";
                 $data['firstname'] = "";
                 $data['username'] = $user->getUserId();
                 $data['role'] = "admin";
                 $user = \App\User::create($data);
                 \Auth::login($user);
                 return \Redirect::to('/');
             } else {
                 abort(401);
             }
         }
         //if it does not exist create it and go on  or show an error message
     });
 }
開發者ID:ghyster,項目名稱:dns-angular,代碼行數:38,代碼來源:EventServiceProvider.php

示例8: upload

 /**
  * Upload an image/file and (for images) create thumbnail
  *
  * @param UploadRequest $request
  * @return string
  */
 public function upload()
 {
     try {
         $res = $this->uploadValidator();
         if (true !== $res) {
             return Lang::get('laravel-filemanager::lfm.error-invalid');
         }
     } catch (\Exception $e) {
         return $e->getMessage();
     }
     $file = Input::file('upload');
     $new_filename = $this->getNewName($file);
     $dest_path = parent::getPath('directory');
     if (File::exists($dest_path . $new_filename)) {
         return Lang::get('laravel-filemanager::lfm.error-file-exist');
     }
     $file->move($dest_path, $new_filename);
     if ('Images' === $this->file_type) {
         $this->makeThumb($dest_path, $new_filename);
     }
     Event::fire(new ImageWasUploaded(realpath($dest_path . '/' . $new_filename)));
     // upload via ckeditor 'Upload' tab
     if (!Input::has('show_list')) {
         return $this->useFile($new_filename);
     }
     return 'OK';
 }
開發者ID:laravel2580,項目名稱:llaravel-filemanager,代碼行數:33,代碼來源:UploadController.php

示例9: __construct

 /**
  * EventsDataSource constructor.
  */
 public function __construct()
 {
     $this->points = [];
     Event::listen('*', function () {
         $this->points[] = ['memory' => memory_get_usage(true), 'time' => microtime(true)];
     });
 }
開發者ID:lahaxearnaud,項目名稱:clockwork,代碼行數:10,代碼來源:MemoryDataSource.php

示例10: title

 public function title()
 {
     $oldTitle = $this->page->getTitle();
     $this->page->setTitle($this->request->input('title'));
     Event::fire(new Events\PageTitleWasChanged($this->page, $oldTitle, $this->page->getTitle()));
     return ['status' => $this->page->getCurrentVersion()->getStatus(), 'location' => (string) $this->page->url(true)];
 }
開發者ID:imanghafoori1,項目名稱:boom-core,代碼行數:7,代碼來源:Save.php

示例11: getRegisteredSettings

 /**
  * Handle registering and returning registered settings.
  *
  * @return array
  */
 public function getRegisteredSettings()
 {
     $registry = new SettingsRegistry();
     $registry->register('General', [['name' => 'app.site.name', 'type' => 'text', 'label' => 'Site name', 'options' => ['required' => 'required']], ['name' => 'app.site.desc', 'type' => 'text', 'label' => 'Site desc', 'options' => ['required' => 'required']]]);
     Event::fire('register.settings', [$registry]);
     return $registry->collectSettings();
 }
開發者ID:kamaroly,項目名稱:shift,代碼行數:12,代碼來源:SettingsService.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $category = $this->categoryRepo->insert($request->input());
     Event::fire(new CategoryCreated($category));
     // TODO: flash message
     return redirect()->back();
 }
開發者ID:karlos545,項目名稱:takeaway,代碼行數:13,代碼來源:CategoriesController.php

示例13: handle

 /**
  * Write a logout history item for this user
  *
  * @param $user
  */
 public static function handle($user)
 {
     $user->login_history()->save(new UserLoginHistory(['source' => Request::getClientIp(), 'user_agent' => Request::header('User-Agent'), 'action' => 'logout']));
     $message = 'User logged out from ' . Request::getClientIp();
     Event::fire('security.log', [$message, 'authentication']);
     return;
 }
開發者ID:freedenizen,項目名稱:web,代碼行數:12,代碼來源:Logout.php

示例14: boot

 public function boot(Guard $guard, MixPanel $mixPanel)
 {
     include __DIR__ . '/Http/routes.php';
     $this->app->make(config('auth.model'))->observe(new MixPanelUserObserver($mixPanel));
     $eventHandler = new MixPanelEventHandler($guard, $mixPanel);
     Event::subscribe($eventHandler);
 }
開發者ID:janusnic,項目名稱:MixPanel,代碼行數:7,代碼來源:MixPanelServiceProvider.php

示例15: deleteType

 public static function deleteType($id)
 {
     // firing event so it can get catched for permission handling
     Event::fire('customprofile.deleting');
     $success = ProfileFieldType::findOrFail($id)->delete();
     return $success;
 }
開發者ID:donotgowiththeflow,項目名稱:laravel-acl-seeinfront,代碼行數:7,代碼來源:CustomProfileRepository.php


注:本文中的Illuminate\Support\Facades\Event類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。