本文整理汇总了PHP中Cake\View\View::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP View::__construct方法的具体用法?PHP View::__construct怎么用?PHP View::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\View\View
的用法示例。
在下文中一共展示了View::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
parent::__construct($request, $response, $eventManager, $viewOptions);
if (isset($viewOptions['config'])) {
$this->config = array_merge($this->config, $viewOptions['config']);
}
}
示例2: __construct
/**
* Constructor
*
* @param \Cake\Network\Request $request Request instance.
* @param \Cake\Network\Response $response Response instance.
* @param \Cake\Event\EventManager $eventManager EventManager instance.
* @param array $viewOptions An array of view options
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
parent::__construct($request, $response, $eventManager, $viewOptions);
if ($response && $response instanceof Response) {
$response->type($this->_responseType);
}
}
示例3: __construct
/**
* Constructor
*
* @param Request|null $request
* @param Response|null $response
* @param EventManager|null $eventManager
* @param array $viewOptions
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
if ($eventManager === null) {
$eventManager = EventManager::instance();
}
$this->_templatePath = Configure::read('App.paths.templates')[0];
parent::__construct($request, $response, $eventManager, $viewOptions);
}
示例4: __construct
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
parent::__construct($request, $response, $eventManager, $viewOptions);
$this->_serviceProvider = new ServiceProvider(Configure::read('App.paths.templates'), CACHE . 'bladeView');
$this->loadBlade();
$this->_loadHelpers();
$this->loadExtensions();
}
示例5: __construct
/**
* Upon construction, append the plugin's template paths to the paths to check
*
* @param \Cake\Network\Request|null $request Request instance.
* @param \Cake\Network\Response|null $response Response instance.
* @param \Cake\Event\EventManager|null $eventManager Event manager instance.
* @param array $viewOptions View options. See View::$_passedVars for list of
* options which get set as class properties.
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
parent::__construct($request, $response, $eventManager, $viewOptions);
$bakeTemplates = dirname(dirname(__FILE__)) . DS . 'Template' . DS;
$paths = (array) Configure::read('App.paths.templates');
if (!in_array($bakeTemplates, $paths)) {
$paths[] = $bakeTemplates;
Configure::write('App.paths.templates', $paths);
}
}
示例6: __construct
/**
* Constructor.
*
* @param Request $request Request.
* @param Response $response Response.
* @param EventManager $eventManager EventManager.
* @param array $viewOptions View options.
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
if ($eventManager === null) {
$eventManager = EventManager::instance();
}
$this->eventManager = $eventManager;
$this->twig = new \Twig_Environment($this->getLoader(), $this->resolveConfig());
$this->eventManager->dispatch(ConstructEvent::create($this, $this->twig));
parent::__construct($request, $response, $eventManager, $viewOptions);
$this->_ext = self::EXT;
$this->generateHelperList();
}
示例7: __construct
/**
* Constructor
*
* @param \Cake\Network\Request $request Request instance.
* @param \Cake\Network\Response $response Response instance.
* @param \Cake\Event\EventManager $eventManager Event manager instance.
* @param array $viewOptions View options. See View::$_passedVars for list of
* options which get set as class properties.
*
* @throws \Cake\Core\Exception\Exception
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
parent::__construct($request, $response, $eventManager, $viewOptions);
if (isset($viewOptions['name']) && $viewOptions['name'] == 'Error') {
$this->subDir = null;
$this->layoutPath = null;
$response->type('html');
return;
}
\PHPExcel_Cell::setValueBinder(new \PHPExcel_Cell_AdvancedValueBinder());
$this->PhpExcel = new \PHPExcel();
}
示例8: __construct
/**
* Constructor.
*
* @param Request $request Request.
* @param Response $response Response.
* @param EventManager $eventManager EventManager.
* @param array $viewOptions View options.
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
if ($eventManager === null) {
$eventManager = EventManager::instance();
}
$this->eventManager = $eventManager;
$this->twig = new \Twig_Environment($this->getLoader(), ['cache' => CACHE . 'twigView' . DS, 'charset' => strtolower(Configure::read('App.encoding')), 'auto_reload' => Configure::read('debug'), 'debug' => Configure::read('debug')]);
$this->eventManager->dispatch(ConstructEvent::create($this, $this->twig));
parent::__construct($request, $response, $eventManager, $viewOptions);
$this->_ext = self::EXT;
$this->generateHelperList();
}
示例9: __construct
/**
* Constructor
*
* @param \Cake\Network\Request $request Request instance.
* @param \Cake\Network\Response $response Response instance.
* @param \Cake\Event\EventManager $eventManager Event manager instance.
* @param array $viewOptions View options. See View::$_passedVars for list of
* options which get set as class properties.
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
parent::__construct($request, $response, $eventManager, $viewOptions);
$this->twig = new Twig_Environment($this->getFilesystemLoader(), ['debug' => Configure::read('debug'), 'autoescape' => false]);
$this->addGlobals();
$this->addExtensions();
if (Configure::read('debug')) {
$this->twig->addExtension(new Twig_Extension_Debug());
} else {
$this->twig->setCache(TMP . 'twig');
}
}
示例10: __construct
/**
* Constructor
*
* @param \Cake\Network\Request|null $request Request instance.
* @param \Cake\Network\Response|null $response Response instance.
* @param \Cake\Event\EventManager|null $eventManager Event manager instance.
* @param array $viewOptions View options. See View::$_passedVars for list of
* options which get set as class properties.
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
parent::__construct($request, $response, $eventManager, $viewOptions);
if ($this->subDir === null) {
$this->subDir = 'ajax';
$this->templatePath = str_replace(DS . 'json', '', $this->templatePath);
$this->templatePath = str_replace(DS . 'ajax', '', $this->templatePath);
}
if (isset($response)) {
$response->type('json');
}
}
示例11: __construct
/**
* Constructor
*
* @param \Cake\Network\Request $request Request instance.
* @param \Cake\Network\Response $response Response instance.
* @param \Cake\Event\EventManager $eventManager Event manager instance.
* @param array $viewOptions View options. See View::$_passedVars for list of
* options which get set as class properties.
*
* @throws \Cake\Core\Exception\Exception
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
parent::__construct($request, $response, $eventManager, $viewOptions);
if (isset($viewOptions['templatePath']) && $viewOptions['templatePath'] == 'Error') {
$this->layoutPath = null;
$this->subDir = null;
$response->type('html');
return;
}
// intitialize PHPExcel-Object
\PHPExcel_Cell::setValueBinder(new \PHPExcel_Cell_AdvancedValueBinder());
$this->PHPExcel = new \PHPExcel();
$this->currentSheetIndex = 0;
}
示例12: __construct
/**
* Constructor
*
* @param \Cake\Network\Request $request Request instance.
* @param \Cake\Network\Response $response Response instance.
* @param \Cake\Event\EventManager $eventManager EventManager instance.
* @param array $viewOptions An array of view options
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
if (!empty($viewOptions['templatePath']) && $viewOptions['templatePath'] == '/xlsx') {
$this->subDir = null;
}
parent::__construct($request, $response, $eventManager, $viewOptions);
if (isset($viewOptions['name']) && $viewOptions['name'] == 'Error') {
$this->subDir = null;
$this->layoutPath = null;
$response->type('html');
return;
}
if ($response && $response instanceof Response) {
$response->type('xlsx');
}
$this->PhpExcel = new PHPExcel();
}
示例13: __construct
/**
* Constructor
*
* @param \Cake\Network\Request $request Request instance.
* @param \Cake\Network\Response $response Response instance.
* @param \Cake\Event\EventManager $eventManager Event manager instance.
* @param array $viewOptions View options. See View::$_passedVars for list of
* options which get set as class properties.
*
* @throws \Cake\Core\Exception\Exception
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
$this->_passedVars[] = 'pdfConfig';
parent::__construct($request, $response, $eventManager, $viewOptions);
$this->pdfConfig = array_merge((array) Configure::read('CakePdf'), (array) $this->pdfConfig);
$response->type('pdf');
if (isset($viewOptions['name']) && $viewOptions['name'] == 'Error') {
$this->subDir = null;
$this->layoutPath = null;
$response->type('html');
return;
}
if (!$this->pdfConfig) {
throw new Exception(__d('cakepdf', 'Controller attribute $pdfConfig is not correct or missing'));
}
$this->renderer($this->pdfConfig);
}
示例14: __construct
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
parent::__construct($request, $response, $eventManager, $viewOptions);
//$this->_engine = new CakeTcpdf();
//$this->_engine->setupDefaults();
// @todo set response type before rendering not on construct
//$this->response->type('pdf');
/*
// set pdf layout path
if ($this->layoutPath === null) {
$this->layoutPath = 'pdf';
}
// set pdf subdir for views
if ($this->subDir === null) {
$this->subDir = 'pdf';
}
*/
// autoload PdfHelper
//$this->helpers()->load('Tcpdf.Pdf');
}
示例15: __construct
/**
* {@inheritDoc}
*
* The following helpers will be automatically loaded:
*
* - Url
* - Html
* - Form
* - Menu
* - jQuery
*/
public function __construct(Request $request = null, Response $response = null, EventManager $eventManager = null, array $viewOptions = [])
{
$defaultOptions = ['helpers' => ['Form' => ['className' => 'CMS\\View\\Helper\\FormHelper'], 'Html' => ['className' => 'CMS\\View\\Helper\\HtmlHelper'], 'Menu' => ['className' => 'Menu\\View\\Helper\\MenuHelper'], 'jQuery' => ['className' => 'Jquery\\View\\Helper\\JqueryHelper']]];
$viewOptions = Hash::merge($defaultOptions, $viewOptions);
parent::__construct($request, $response, $eventManager, $viewOptions);
}