当前位置: 首页>>代码示例>>PHP>>正文


PHP compact函数代码示例

本文整理汇总了PHP中compact函数的典型用法代码示例。如果您正苦于以下问题:PHP compact函数的具体用法?PHP compact怎么用?PHP compact使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了compact函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: display

 /**
  * Displays a view
  *
  * @param mixed What page to display
  * @return void
  * @throws NotFoundException When the view file could not be found
  *	or MissingViewException in debug mode.
  */
 public function display()
 {
     $path = func_get_args();
     //debug($path);
     $count = count($path);
     //debug($count);
     if (!$count) {
         return $this->redirect('/');
     }
     $page = $subpage = $title_for_layout = null;
     //debug(Inflector::humanize($path[$count - 1]));
     if (!empty($path[0])) {
         $page = $path[0];
     }
     if (!empty($path[1])) {
         $subpage = $path[1];
     }
     if (!empty($path[$count - 1])) {
         $title_for_layout = Inflector::humanize($path[$count - 1]);
     }
     $this->set(compact('page', 'subpage', 'title_for_layout'));
     //debug($this->render(implode('/', $path)));
     //debug($page);
     //debug($subpage);
     //debug($title_for_layout);
     try {
         $this->render(implode('/', $path));
     } catch (MissingViewException $e) {
         if (Configure::read('debug')) {
             throw $e;
         }
         throw new NotFoundException();
     }
 }
开发者ID:pavsnellski,项目名称:SMC,代码行数:42,代码来源:PagesController.php

示例2: handle

 /**
  * Handle the event.
  *
  * @param  ChildWasRegistered  $event
  * @return void
  */
 public function handle(ChildWasRegistered $event)
 {
     $parent = $event->user;
     Mail::send('register.mail.registered', compact('parent'), function ($message) use($parent) {
         $message->to($parent->email)->from('hello@shapingyounghearts.org')->subject('Thank you for registering');
     });
 }
开发者ID:octopoda,项目名称:FLDS,代码行数:13,代码来源:EmailUserFurtherRegistrationInstructions.php

示例3: about

 public function about()
 {
     $first = 'Haonan';
     $last = 'Xu';
     $people = [];
     return view('pages.about', compact('first', 'last', 'people'));
 }
开发者ID:xwysam,项目名称:learnL5,代码行数:7,代码来源:AboutController.php

示例4: getInstallPath

 /**
  * Return the install path based on package type.
  *
  * @param  PackageInterface $package
  * @param  string           $frameworkType
  * @return string
  */
 public function getInstallPath(PackageInterface $package, $frameworkType = '')
 {
     $type = $this->package->getType();
     $prettyName = $this->package->getPrettyName();
     if (strpos($prettyName, '/') !== false) {
         list($vendor, $name) = explode('/', $prettyName);
     } else {
         $vendor = '';
         $name = $prettyName;
     }
     $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type'));
     $extra = $package->getExtra();
     if (!empty($extra['installer-name'])) {
         $availableVars['name'] = $extra['installer-name'];
     }
     if ($this->composer->getPackage()) {
         $extra = $this->composer->getPackage()->getExtra();
         if (!empty($extra['installer-paths'])) {
             $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type);
             if ($customPath !== false) {
                 return $this->templatePath($customPath, $availableVars);
             }
         }
     }
     $packageType = substr($type, strlen($frameworkType) + 1);
     $locations = $this->getLocations();
     if (!isset($locations[$packageType])) {
         throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type));
     }
     return $this->templatePath($locations[$packageType], $availableVars);
 }
开发者ID:SebFav,项目名称:ApplicationInternet2,代码行数:38,代码来源:BaseInstaller.php

示例5: index

 /**
  * Return an index of archived posts.
  *
  * @param PostRepositoryInterface $posts
  * @param                         $year
  * @param null                    $month
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function index(PostRepositoryInterface $posts, $year, $month = null)
 {
     $this->dispatch(new AddPostsBreadcrumb());
     $this->dispatch(new AddArchiveBreadcrumb());
     $posts = $posts->findManyByDate($year, $month);
     return view('anomaly.module.posts::archive/index', compact('year', 'month', 'posts'));
 }
开发者ID:jacksun101,项目名称:posts-module,代码行数:15,代码来源:ArchiveController.php

示例6: index

 /**
  * index method
  *
  * @access public
  * @return void
  */
 public function index()
 {
     $this->set('testData', 'Some test data');
     $test2 = 'more data';
     $test3 = 'even more data';
     $this->set(compact('test2', 'test3'));
 }
开发者ID:evrard,项目名称:cakephp2x,代码行数:13,代码来源:theme.test.php

示例7: sendEmailConfirmationTo

 public function sendEmailConfirmationTo(User $user)
 {
     $this->to = $user->email;
     $this->view = 'emails.confirm';
     $this->data = compact('user');
     $this->deliver();
 }
开发者ID:ljjakovljevic,项目名称:ekof-bp,代码行数:7,代码来源:AppMailer.php

示例8: index

 /**
  * Init the index view with the current
  * average rate data stored in the db.
  *
  * @return Response
  */
 public function index()
 {
     // Select the rates of the year 2015.
     // NOTE: Just for the purpose of the exercise,
     // would be nicer to provide all the results available
     // grouped accordingly
     $rates = Db::table('monthly_rates')->select('currency_from', 'currency_to', 'month', 'avg_rate')->where('year', 2015)->orderBy('currency_from')->orderBy('currency_to')->get();
     // Initialize the messages array as charts.js expects it
     if (empty($rates)) {
         $messages = [[]];
     } else {
         $messages = [];
     }
     $monthRates = [];
     $totRates = count($rates);
     // Aggregate the messages as an array
     // currencyfrom_currencyto => [1 => avg_rate, 2 => ...]
     // where the inner array index corresponds to a month
     for ($i = 0; $i < $totRates; $i++) {
         $rate = $rates[$i];
         $monthRates[$rate->month] = $rate->avg_rate;
         if ($i == $totRates - 1) {
             $key = $rate->currency_from . '-' . $rate->currency_to;
             $messages[$key] = $monthRates;
         } elseif ($rate->currency_from != $rates[$i + 1]->currency_from || $rate->currency_to != $rates[$i + 1]->currency_to) {
             // Build the array key and store the data
             $key = $rate->currency_from . '-' . $rate->currency_to;
             $messages[$key] = $monthRates;
             $monthRates = [];
         }
     }
     return view('socket', compact('messages'));
 }
开发者ID:staribelli,项目名称:market-trade-processor,代码行数:39,代码来源:CurrencymessageController.php

示例9: actionProject

 public function actionProject()
 {
     $form = "";
     if (Yii::app()->getRequest()->ispostRequest) {
         $project_des = Yii::app()->request->getParam('project_des');
         $project_price = Yii::app()->request->getParam('project_price');
         $project_name = Yii::app()->request->getParam('project_name');
         $project_type = Yii::app()->request->getParam('project_type');
         $project_time = Yii::app()->request->getParam('project_time');
         if ($project_des != '') {
             Yii::app()->session['project_des'] = Yii::app()->request->getParam('project_des');
         }
         if ($project_name != '') {
             Yii::app()->session['project_name'] = Yii::app()->request->getParam('project_name');
         }
         if ($project_price != '') {
             Yii::app()->session['project_price'] = Yii::app()->request->getParam('project_price');
         }
         if ($project_type != '') {
             Yii::app()->session['project_type'] = Yii::app()->request->getParam('project_type');
         }
         if ($project_time != '') {
             Yii::app()->session['project_time'] = Yii::app()->request->getParam('project_time');
         }
         echo 'success!';
     }
     $this->renderPartial('_project', compact("form"), false, true);
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:28,代码来源:ContactController.php

示例10: index

 public function index(WpApiContract $wp_client)
 {
     $posts = $wp_client->getPosts();
     $posts = json_decode($posts);
     //dd($posts);
     return view('layouts.index', compact('posts'));
 }
开发者ID:jedifunk,项目名称:jbfj-laravel-wp-api,代码行数:7,代码来源:WpController.php

示例11: index

 /**
  * Display a listing of products on the wishlist.
  *
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $wishlist = $this->wishlist;
     $items = $this->wishlist->items();
     $total = $this->wishlist->total();
     return View::make('cart.wishlist', compact('wishlist', 'items', 'total'));
 }
开发者ID:Denniskevin,项目名称:demo-cart,代码行数:12,代码来源:WishlistController.php

示例12: pending_leads_by_source

 public function pending_leads_by_source()
 {
     $data_sources = $this->reporting->pendingLeadsBySource()->lists('label');
     $data_count = $this->reporting->pendingLeadsBySource()->lists('data');
     $leads = $this->reporting->allPendingBySource();
     return view('admin.leadrouter.pending_leads_by_source', compact('leads', 'data_sources', 'data_count'));
 }
开发者ID:jdelise,项目名称:career_site,代码行数:7,代码来源:ReportingController.php

示例13: demo

 public function demo()
 {
     $data = [];
     $data['username'] = 'Asna';
     $data['password'] = 'family';
     return view('page.demo', compact('data'));
 }
开发者ID:asna8,项目名称:Articles,代码行数:7,代码来源:DemoController.php

示例14: index

 /**
  * index method
  *
  * @return void
  * @access public
  */
 public function index($type = null, $lat = null, $long = null, $opt1 = null, $opt2 = null)
 {
     $params = array('limit' => 35, 'page' => 1);
     if (!empty($type) && !empty($lat) && !empty($long)) {
         $lat = floatval($lat);
         $long = floatval($long);
         $opt1 = floatval($opt1);
         $opt2 = floatval($opt2);
         switch ($type) {
             case 'near':
                 if (!empty($opt1)) {
                     $cond = array('loc' => array('$near' => array($lat, $long), '$maxDistance' => $opt1));
                 } else {
                     $cond = array('loc' => array('$near' => array($lat, $long)));
                 }
                 break;
             case 'box':
                 $lowerLeft = array($lat, $long);
                 $upperRight = array($opt1, $opt2);
                 $cond = array('loc' => array('$within' => array('$box' => array($lowerLeft, $upperRight))));
                 break;
             case 'circle':
                 $center = array($lat, $long);
                 $radius = $opt1;
                 $cond = array('loc' => array('$within' => array('$center' => array($center, $radius))));
                 break;
         }
         $params['conditions'] = $cond;
     } else {
         $params['order'] = array('_id' => -1);
     }
     $results = $this->Geo->find('all', $params);
     $this->set(compact('results'));
 }
开发者ID:ThemisB,项目名称:mongoDB-Datasource,代码行数:40,代码来源:geos_controller.php

示例15: getIndex

 public function getIndex()
 {
     $title = 'Search';
     $company_results = Company::select('companies.*', 'c.name as country', 'a.city as city')->join('adresses as a', 'companies.address_id', '=', 'a.id')->join('countries as c', 'a.country_id', '=', 'c.id')->orderBy('companies.id', 'DESC')->take(5)->get();
     $company_data = [];
     foreach ($company_results as $curr_company) {
         $curr_company = (object) ['DT_RowId' => $curr_company->id, 'name' => $curr_company->name, 'references' => $curr_company->references, 'country' => $curr_company->country, 'city' => $curr_company->city];
         $curr_entry = (object) $curr_company;
         $company_data[] = $curr_entry;
     }
     $company_init = json_encode(['data' => $company_data]);
     $venue_results = Venue::select('venues.*', 'c.name as country', 'a.city as city')->join('adresses as a', 'venues.address_id', '=', 'a.id')->join('countries as c', 'a.country_id', '=', 'c.id')->orderBy('venues.id', 'DESC')->take(5)->get();
     $venue_data = [];
     foreach ($venue_results as $curr_venue) {
         $curr_venue = (object) ['DT_RowId' => $curr_venue->id, 'name' => $curr_venue->name, 'capacity' => $curr_venue->capacity, 'rigging_capacity' => $curr_venue->rigging_capacity, 'country' => $curr_venue->country, 'city' => $curr_venue->city];
         $curr_entry = (object) $curr_venue;
         $venue_data[] = $curr_entry;
     }
     $venue_init = json_encode(['data' => $venue_data]);
     $contact_results = Contact::select('contacts.*', 'c.name as country')->join('adresses as a', 'contacts.address_id', '=', 'a.id')->join('countries as c', 'a.country_id', '=', 'c.id')->orderBy('contacts.id', 'DESC')->take(5)->get();
     $contact_data = [];
     foreach ($contact_results as $curr_contact) {
         $curr_contact = (object) ['DT_RowId' => $curr_contact->id, 'first_name' => $curr_contact->first_name, 'last_name' => $curr_contact->last_name, 'country' => $curr_contact->country, 'function' => $curr_contact->function];
         $curr_entry = (object) $curr_contact;
         $contact_data[] = $curr_entry;
     }
     $contact_init = json_encode(['data' => $contact_data]);
     return View::make('site/' . $this->name . '/index', compact('title', 'company_init', 'venue_init', 'contact_init'));
 }
开发者ID:strikles,项目名称:php,代码行数:29,代码来源:SearchController.php


注:本文中的compact函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。