private function _testEnabled($method = 'GET')
 {
     $request = new Request();
     $request->env('REQUEST_METHOD', $method);
     $request->here = '/pages/home';
     $response = new Response();
     $View = new View($request, $response);
     $View->loadHelper('ViewMemcached.ViewMemcached', ['cacheConfig' => TEST_CACHE_CONFIG]);
     $View->viewPath = 'Pages';
     $View->set('test', 'value');
     $View->render('home', 'default');
     return $View->ViewMemcached->enabled();
 }
Exemplo n.º 2
0
 /**
  * Prepares a View instance with which the given view file
  * will be rendered.
  *
  * @return View
  */
 protected function _getView()
 {
     $view = new View();
     foreach ($this->config('helpers') as $helper) {
         $view->loadHelper($helper);
     }
     return $view;
 }
Exemplo n.º 3
0
 /**
  * Lazy loads helpers.
  *
  * @param string $name Name of the property being accessed.
  * @return \Cake\View\Helper|null Helper instance if helper with provided name exists
  */
 public function __get($name)
 {
     if (isset($this->_helperMap[$name]) && !isset($this->{$name})) {
         $config = ['enabled' => false] + (array) $this->_helperMap[$name]['config'];
         $this->{$name} = $this->_View->loadHelper($this->_helperMap[$name]['class'], $config);
         return $this->{$name};
     }
 }
Exemplo n.º 4
0
 /**
  * Test loading helper when duplicate.
  *
  * @return void
  */
 public function testLoadHelperDuplicate()
 {
     $View = new View();
     $this->assertNotEmpty($View->loadHelper('Html', ['foo' => 'bar']));
     try {
         $View->loadHelper('Html', ['test' => 'value']);
         $this->fail('No exception');
     } catch (\RuntimeException $e) {
         $this->assertContains('The "Html" alias has already been loaded', $e->getMessage());
     }
 }
Exemplo n.º 5
0
 /**
  * Load view helpers by configure.
  *
  * @param View $view
  * @return void
  */
 protected static function _loadHelper(View $view)
 {
     $hooks = self::_getConfigData(Hook::HOOK_CONFIG_HELPER_KEY);
     foreach ($hooks as $helperName => $params) {
         list($controllers, $config) = self::_createParams($params);
         if (self::_inController($controllers, $view->request->param('controller'))) {
             $view->loadHelper($helperName, $config);
         }
     }
 }
Exemplo n.º 6
0
 /**
  * Load base helpers.
  *
  * @param View $view
  */
 public static function baseHelpers(View $view)
 {
     $view->loadHelper('Html', ['className' => 'Union/Core.Html']);
     $view->loadHelper('Union/Core.Document');
     $view->loadHelper('Url', ['className' => 'Union/Core.Url']);
     $view->loadHelper('Form', ['className' => 'Union/Core.Form', 'widgets' => ['_default' => ['Union\\Core\\View\\Widget\\BasicWidget']]]);
     $view->loadHelper('Paginator', ['templates' => 'Union/Core.paginate_tpl']);
     $view->loadHelper('Union/Core.Less');
     $view->loadHelper('Union/Core.Union');
     $view->loadHelper('Union/Core.Assets');
     $view->loadHelper('Union/Core.ToolBar');
     $view->loadHelper('Union/Core.XmlForm');
     if ($view->request->param('prefix') == 'admin') {
         $view->loadHelper('Union/Core.Ace');
         $view->loadHelper('Union/Core.Admin');
         $view->helpers()->get('Paginator')->config(['templates' => 'Union/Core.paginate_tpl_admin']);
     }
 }