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


PHP sfContext::getUser方法代码示例

本文整理汇总了PHP中sfContext::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP sfContext::getUser方法的具体用法?PHP sfContext::getUser怎么用?PHP sfContext::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfContext的用法示例。


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

示例1: getThemeForRequest

 /**
  * Attempts to return the theme for the current request
  * 
  * This first throws a sympal.theme.set_theme_from_request event, giving
  * anyone the opportunity to determine the theme. If this event is not
  * handled, we continue with some default rules for setting themes.
  * 
  * @param sfContext $context
  * @param array An array of valid themes, to be used for user-entered themes
  * 
  * @return string The theme (defaults to the default theme)
  */
 public function getThemeForRequest(sfContext $context, $validThemes)
 {
     $event = $context->getEventDispatcher()->notifyUntil(new sfEvent($this, 'theme.set_theme_from_request', array('context' => $context)));
     if ($event->isProcessed()) {
         return $event->getReturnValue();
     }
     if ($this->getOption('allow_changing_theme_by_url', true)) {
         $user = $context->getUser();
         $request = $context->getRequest();
         if ($theme = $request->getParameter($this->getOption('theme_request_parameter_name', 'sf_theme'))) {
             // make sure the theme is valid
             if (in_array($theme, $validThemes)) {
                 $user->setCurrentTheme($theme);
                 return $theme;
             } else {
                 // unset the user attribute
                 $user->setCurrentTheme(false);
             }
         }
         if ($theme = $user->getCurrentTheme()) {
             return $theme;
         }
     }
     // Get the theme from module/route. False is a valid response (don't set theme)
     $module = $context->getModuleName();
     $route = $context->getRouting()->getCurrentRouteName();
     $theme = $this->getThemeFromConfig($module, $route);
     if ($theme || $theme === false) {
         return $theme;
     }
     return $this->getOption('default_theme');
 }
开发者ID:rafaelgou,项目名称:sfThemePlugin,代码行数:44,代码来源:sfThemeController.class.php

示例2: initialize

 /**
  * Initializes this Filter.
  *
  * @param sfContext $context    The current application context
  * @param array     $parameters An associative array of initialization parameters
  *
  * @return boolean true
  */
 public function initialize($context, $parameters = array())
 {
     $this->request = $context->getRequest();
     $this->response = $context->getResponse();
     $this->user = $context->getUser();
     return parent::initialize($context, $parameters);
 }
开发者ID:theolymp,项目名称:diem,代码行数:15,代码来源:dmFilter.php

示例3: dirname

<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
require_once $_test_dir . '/unit/sfContextMock.class.php';
$t = new lime_test(48, new lime_output_color());
$context = new sfContext();
$context->getUser()->setCulture('en_US');
$v = new sfDateValidator();
$v->initialize($context);
// ->execute()
$t->diag('->execute()');
$validDates = array('2/21/2008', '02/01/1990', '12/31/2001', '2/29/2004');
$invalidDates = array('2/21', '2/29/2005', '3/32/2001', '13/1/2001', '2007ghgre7-1-120', 'foobar');
$validCompareDates = array(array('2/21/2008', '==', '2/21/2008'), array('2/21/2008', '>', '2/20/2007'), array('2/21/2008', '>=', '2/21/2008'), array('2/21/2008', '>=', '2/20/2007'), array('2/21/2008', '<', '3/22/2009'), array('2/21/2008', '<=', '3/22/2009'), array('2/21/2008', '<=', '2/21/2008'));
$invalidCompareDates = array(array('2/1/2008', '==', '2/2/2008'), array('2/1/2008', '>', '2/2/2008'), array('2/1/2008', '>', '2/1/2008'), array('2/1/2008', '>=', '2/2/2008'), array('2/1/2008', '<', '1/31/2008'), array('2/1/2008', '<', '2/1/2008'), array('2/1/2008', '<=', '1/31/2008'));
$v->initialize($context);
foreach ($validDates as $value) {
    $error = null;
    $t->ok($v->execute($value, $error), sprintf('->execute() returns true for a valid date "%s"', $value));
    $t->is($error, null, '->execute() doesn\'t change "$error" if it returns true');
}
foreach ($invalidDates as $value) {
    $error = null;
    $t->ok(!$v->execute($value, $error), sprintf('->execute() returns false for an invalid date "%s"', $value));
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:31,代码来源:sfDateValidatorTest.php

示例4: doGeneratePdf

 protected function doGeneratePdf(sfContext $context, $chartBuilder, $file)
 {
     // definition of chart builder class
     $this->setChartBuilder($chartBuilder);
     // creation of a context
     $context->getConfiguration()->loadHelpers('Partial');
     $context->getRequest()->setRequestFormat('html');
     $config = sfTCPDFPluginConfigHandler::loadConfig();
     sfTCPDFPluginConfigHandler::includeLangFile($context->getUser()->getCulture());
     $doc_title = $this->getName() . " Report";
     $doc_subject = $this->getName() . " Report generated by Otokou";
     $doc_keywords = "report, otokou";
     //create new PDF document (document units are set by default to millimeters)
     $pdf = new sfTCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor(PDF_AUTHOR);
     $pdf->SetTitle($doc_title);
     $pdf->SetSubject($doc_subject);
     $pdf->SetKeywords($doc_keywords);
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
     //set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set image scale factor
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     //initialize document
     $pdf->AliasNbPages();
     // report informations
     $pdf->AddPage();
     $html = get_partial('report/general_info', array('report' => $this));
     $pdf->writeHTML($html, true, false, true, false, '');
     // vehicles overall performances
     $html = '<h1>Vehicles performances</h1>' . '<p>The values presented below are calculated overall the entire life period of the vehicle(s).</p>' . get_partial('report/vehicles_performances', array('vehicles' => $this->getVehicles()));
     $pdf->writeHTML($html, true, false, true, false, '');
     // charts
     $pdf->AddPage();
     $html = '<h1>Costs</h1>';
     $pdf->writeHTML($html, true, false, true, false, '');
     $counter = 0;
     $options = array();
     $attributes = array('absolute' => true);
     $charts = $this->defineCharts($options, $attributes);
     $nc = count($charts);
     foreach ($charts as $c) {
         $counter++;
         //$html = get_partial('report/chart', array('chart' => $c));
         //$pdf->writeHTML($html, true, false, true, false, '');
         $html = '<h2>' . $c['title'] . '</h2><p>' . $c['comment'] . '</p>';
         $pdf->writeHTML($html);
         $c['chart']->generate();
         $pdf->Image($c['chart']->getChartFileSystemPath());
         if ($counter < $nc) {
             $pdf->AddPage();
         }
     }
     // Close and output PDF document
     $pdf->Output($file, 'F');
 }
开发者ID:rbolliger,项目名称:otokou,代码行数:64,代码来源:Report.class.php


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