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


PHP View::setLayoutsDir方法代码示例

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


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

示例1: boot

 /**
  * @param Event $event
  * @param Application $application
  * @return mixed
  */
 public function boot(Event $event, Application $application)
 {
     $config = $application->getConfig()->application;
     if (isset($config->view) && $config->view !== false) {
         $view = new View();
         $view->setViewsDir($config->view->viewsDir);
         $view->setLayoutsDir($config->view->layoutsDir);
         $view->setLayout($config->view->layout);
         $application->getDI()->setShared('view', $view);
     }
 }
开发者ID:vegas-cmf,项目名称:mvc,代码行数:16,代码来源:Boot.php

示例2: registerServices

 public function registerServices(DiInterface $di)
 {
     global $config;
     $di->setShared('url', function () use($config) {
         $url = new UrlResolver();
         $url->setBaseUri($config->backend->baseUri);
         return $url;
     });
     $di->setShared('dispatcher', function () {
         $dispatcher = new Dispatcher();
         $dispatcher->setDefaultNamespace("Multiple\\Backend\\Controllers");
         return $dispatcher;
     });
     $di->setShared('view', function () use($config) {
         $view = new View();
         $view->setViewsDir($config->backend->viewsDir);
         $view->setLayoutsDir('layouts/');
         $view->setPartialsDir('partials/');
         $view->registerEngines(array('.phtml' => function ($view, $di) use($config) {
             $volt = new VoltEngine($view, $di);
             $volt->setOptions(array('compiledPath' => $config->backend->cacheDir, 'compiledSeparator' => '_'));
             return $volt;
         }, '.volt' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
         return $view;
     });
 }
开发者ID:lnmtien,项目名称:phalcon-base,代码行数:26,代码来源:Module.php

示例3: registerServices

 public function registerServices(DiInterface $di)
 {
     /**
      * Read configuration
      */
     $config = (include __DIR__ . "/config/config.php");
     $di['dispatcher'] = function () {
         $dispatcher = new Dispatcher();
         $dispatcher->setDefaultNamespace("Modules\\Backend\\Controllers");
         return $dispatcher;
     };
     /**
      * Setting up the view component
      */
     $di['view'] = function () {
         $view = new View();
         $view->setViewsDir(__DIR__ . '/views/');
         $view->setLayoutsDir('../../common/layouts/backend/');
         $view->setTemplateAfter('main');
         return $view;
     };
     /**
      * Database connection is created based in the parameters defined in the configuration file
      */
     $di['db'] = function () use($config) {
         return new MySQLAdapter(array("host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->name));
     };
 }
开发者ID:hoangnghia,项目名称:it102,代码行数:28,代码来源:Module.php

示例4: registerServices

 /**
  * Register specific services for the module
  */
 function registerServices(\Phalcon\DiInterface $di)
 {
     //Registering a dispatcher
     $di->set('dispatcher', function () {
         $dispatcher = new Dispatcher();
         $dispatcher->setDefaultNamespace('Modules\\Frontend\\Controllers');
         return $dispatcher;
     });
     $config = $di->getShared('config');
     $di->set('view', function () use($config, $di) {
         $view = new View();
         $router = $di->getShared('router');
         /*
          * @todo 给layouts等目录统一变量
          * */
         $view->setViewsDir(__DIR__ . '/views/');
         $view->setLayoutsDir('/../../../layouts/');
         // 多模块的话, 可能会有多个风格,所以需要切换layout,这里的Path是根据当前module的Path向上走的
         $view->setLayout('index');
         $view->registerEngines(array('.volt' => function ($view, $di) use($config) {
             $volt = new VoltEngine($view, $di);
             $volt->setOptions(array('compiledPath' => $config->application->cacheDir, 'compiledSeparator' => '_'));
             return $volt;
         }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
         return $view;
     }, true);
 }
开发者ID:justforleo,项目名称:phalcon-cmf,代码行数:30,代码来源:Module.php

示例5: registerServices

 public function registerServices(DiInterface $di)
 {
     $di['dispatcher'] = function () {
         $eventsManager = new \Phalcon\Events\Manager();
         //Attach a listener
         $eventsManager->attach("dispatch:beforeException", function ($event, $dispatcher, $exception) {
             //controller or action doesn't exist
             if ($exception instanceof \Phalcon\Mvc\Dispatcher\Exception) {
                 $dispatcher->forward(array('controller' => 'error', 'action' => 'error404'));
                 return false;
             }
             switch ($exception->getCode()) {
                 case \Phalcon\Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
                 case \Phalcon\Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                     $dispatcher->forward(array('controller' => 'error', 'action' => 'error404'));
                     return false;
             }
         });
         $dispatcher = new Dispatcher();
         $dispatcher->setDefaultNamespace("Modules\\Frontend\\Controllers");
         $dispatcher->setEventsManager($eventsManager);
         return $dispatcher;
     };
     $di['view'] = function () {
         $view = new View();
         $view->setViewsDir(__DIR__ . '/views/');
         $view->setLayoutsDir('../../common/layout_frontend/');
         return $view;
     };
 }
开发者ID:OwLoop,项目名称:Fresh,代码行数:30,代码来源:Module.php

示例6: setView

 private function setView($manager, $theme)
 {
     /* ==================================================
      * ตั้งค่าเรียกใช้งานไฟล์ View ทั้งหมด
      * Setting up the view component
      * ================================================== */
     $manager->set('view', function () use($theme) {
         $view = new View();
         $view->setViewsDir(__DIR__ . '/views/');
         /* ตำแหน่งเก็บไฟล์ views ทั้งหมด */
         $view->setLayoutsDir(sprintf('%s/%s/', $this->config->theme->themesDir, $theme));
         /* ตำแหน่งเก็บไฟล์ layouts ทั้งหมด */
         $view->setTemplateAfter('layouts/' . $this->layoutName);
         /* เลือกไฟล์ layout เริ่มต้น*/
         /* สร้างโฟล์เดอร์เก็บไฟล์ cache */
         $cacheDir = sprintf('%s/%s/%s/', APPLICATION_PATH, $this->config->application->cacheDir, $this->moduleName);
         if (!is_dir($cacheDir)) {
             mkdir($cacheDir);
         }
         $view->registerEngines(array('.phtml' => function ($view, $di) {
             $volt = new VoltEngine($view, $di);
             $volt->setOptions(array('compiledPath' => sprintf('%s/%s/%s/', APPLICATION_PATH, $this->config->application->cacheDir, $this->moduleName), 'compiledSeparator' => '_'));
             return $volt;
         }));
         return $view;
     });
 }
开发者ID:drivesoftz,项目名称:phalcon2-app-modules,代码行数:27,代码来源:Module.php

示例7: setView

 private function setView()
 {
     $view = new View();
     $view->setViewsDir($this->config->application->viewsDir);
     $view->setLayoutsDir('layouts/');
     $view->setLayout('index');
     $view->registerEngines(['.volt' => $this->setVolt($view), '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php']);
     return $view;
 }
开发者ID:xsat,项目名称:www.test.com,代码行数:9,代码来源:MainApplication.php

示例8: registerServices

 /**
  * Register specific services for the module
  */
 public function registerServices(\Phalcon\DiInterface $dependencyInjector)
 {
     /**
      * Read configuration
      */
     $config = (require_once MODULES_DIR . $this->module_name . DS . "config" . DS . "config.php");
     //Registering a dispatcher
     $dependencyInjector->set('dispatcher', function () {
         $dispatcher = new \Phalcon\Mvc\Dispatcher();
         //Attach a event listener to the dispatcher
         $eventManager = new \Phalcon\Events\Manager();
         //$eventManager->attach('dispatch', new \Acl($this->module_name));
         $dispatcher->setEventsManager($eventManager);
         $dispatcher->setDefaultNamespace("Mod\\ModMan\\Controllers\\");
         return $dispatcher;
     });
     /**
      * Setting up the view component
      */
     $dependencyInjector->set('view', function () use($config) {
         $view = new \Phalcon\Mvc\View();
         $view->setViewsDir($config->module->viewsDir);
         $view->setViewsDir(MODULES_DIR . $this->module_name . DS . 'views' . DS);
         $view->setLayoutsDir(MODULES_DIR . $this->module_name . DS . 'layouts' . DS);
         //$view->setTemplateAfter('index');
         $view->registerEngines(array('.volt' => function ($view, $di) {
             $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
             $volt->setOptions(array('compiledPath' => MODULES_DIR . $this->module_name . DS . 'views' . DS . '_compiled' . DS, 'stat' => true, 'compileAlways' => true));
             return $volt;
         }));
         return $view;
     });
     /**
      * Database connection is created based in the parameters defined in the configuration file
      * http://stackoverflow.com/questions/22197678/how-to-connect-multiple-database-in-phalcon-framework
      */
     $dependencyInjector->set('db', function () use($config) {
         return new DbAdapter(array("host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->name));
     });
 }
开发者ID:vfeitoza,项目名称:phalcon-multi-module-skeleton,代码行数:43,代码来源:Module.php

示例9: registerServices

 /**
  *
  * @param \Phalcon\DI $di
  */
 public function registerServices($di)
 {
     Admin::instance();
     require __DIR__ . '/../../../../phad/phad.php';
     $di['phadConfig'] = function () {
         $config = (require __DIR__ . '/../../../../phad-config.php');
         return new Config($config);
     };
     $di['view'] = function () {
         $view = new ViewEngine();
         $view->setViewsDir(__DIR__ . '/Views/');
         $view->setLayoutsDir('Layouts/');
         $view->setPartialsDir('Partials/');
         return $view;
     };
     $di['viewSimple'] = function () {
         $view = new Simple();
         $view->setViewsDir(__DIR__ . '/Views/');
         return $view;
     };
     $di['flashSession'] = function () {
         $flashClasses = ['error' => 'alert alert-danger', 'success' => 'alert alert-success', 'notice' => 'alert alert-info', 'warning' => 'alert alert-warning'];
         return new FlashSession($flashClasses);
     };
     $di['session'] = function () {
         $session = new Session();
         $session->start();
         return $session;
     };
     $di['phadAuth'] = function () {
         return new Auth();
     };
     $di['assets'] = function () use($di) {
         $options = ['sourceBasePath' => __DIR__ . '/Assets/', 'targetBasePath' => __DIR__ . '/../../../../public/backend-assets/'];
         $assets = new AssetsManager($options);
         $assets->collection('backend_css')->setTargetPath('final.css')->setTargetUri('backend-assets/final.css')->addCss('bootstrap/css/bootstrap.min.css')->addCss('css/styles.css')->join(true)->addFilter(new AssetsNullFilter());
         $assets->collection('backend_js')->setTargetPath('final.js')->setTargetUri('backend-assets/final.js')->addJs('bootstrap/js/bootstrap.min.js')->addJs('js/custom.js')->join(true)->addFilter(new AssetsNullFilter());
         return $assets;
     };
 }
开发者ID:argentum88,项目名称:phad,代码行数:44,代码来源:Module.php

示例10: registerViewService

 /**
  * @param \Phalcon\DI\FactoryDefault     $di
  */
 protected function registerViewService($di)
 {
     /**
      * Setting up the view component
      */
     $di['view'] = function () use($di) {
         /*
          * Obtengo el nombre del modulo para poder obner el archivo de configuracion
          */
         $module = $this->name;
         $this->layout_dir = '../../../../public/layouts/' . $di->get('modules')->{$module}->layout . '/';
         $view = new View();
         $view->setViewsDir($this->path . $this->view_dir);
         $view->setLayoutsDir($this->layout_dir);
         $view->setTemplateAfter($this->template);
         $view->setVar('project-setting', $di->get('config')->project->toArray());
         /*
          * Registra Constantes de Modulo
          */
         $view->setVar('module-setting', $di->get('modules')->{$module}->toArray());
         // Set the engine
         $view->registerEngines(array(".mustache" => function ($view, DI $di) {
             $module = $this->name;
             $partial_url = '../public/layouts/' . $di->get('modules')->{$module}->layout . '/partials';
             $partial_loader = new Mustache_Loader_FilesystemLoader($partial_url);
             $config = $di->get('config')->cache->frontend;
             if ($config->active == 0) {
                 $options = array('partials_loader' => $partial_loader);
             } else {
                 $options = array('cache' => '/var/www/var/cache/elephant', 'cache_file_mode' => $config->mode, 'partials_loader' => $partial_loader, 'strict_callables' => $config->callables);
             }
             $mustache = new Mustache($view, $di, $options);
             return $mustache;
         }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
         return $view;
     };
 }
开发者ID:Jonhathan-Rodas,项目名称:elephant,代码行数:40,代码来源:Module.php

示例11: registerServices

 /**
  * Registers services related to the module
  *
  * @param DiInterface $di        	
  */
 public function registerServices(DiInterface $di)
 {
     /**
      * Read configuration
      */
     $config = new Ini(APP_PATH . "/apps/teacher/config/config.ini");
     /**
      * Setting up the view component
      */
     $di['view'] = function () {
         $view = new View();
         $view->setViewsDir(__DIR__ . '/views/');
         // set layout
         $view->setLayoutsDir('../../../layouts/');
         $view->setTemplateAfter('main');
         return $view;
     };
     /**
      * Database connection is created based in the parameters defined in the configuration file
      */
     $di['db'] = function () use($config) {
         return new DbAdapter(array('host' => $config->database->host, 'username' => $config->database->username, 'password' => $config->database->password, 'dbname' => $config->database->dbname));
     };
 }
开发者ID:nhannv56,项目名称:hoctap,代码行数:29,代码来源:Module.php

示例12: function

/**
 * If the configuration specify the use of metadata adapter use it or use memory otherwise
 */
$di->set('modelsMetadata', function () {
    return new MetaDataAdapter();
});
/**
 * Start the session the first time some component request the session service
 */
$di->set('session', function () {
    $session = new SessionAdapter();
    $session->start();
    return $session;
});
$di->set('view', function () use($config, $di) {
    $view = new View();
    $router = $di->getShared('router');
    /*
     * @todo 给layouts等目录统一变量
     * */
    $view->setViewsDir(__DIR__ . '/views/');
    $view->setLayoutsDir('/../../../layouts/');
    // 多模块的话, 可能会有多个风格,所以需要切换layout,这里的Path是根据当前module的Path向上走的
    $view->setLayout('adminCommon');
    $view->registerEngines(array('.volt' => function ($view, $di) use($config) {
        $volt = new VoltEngine($view, $di);
        $volt->setOptions(array('compiledPath' => $config->application->cacheDir, 'compiledSeparator' => '_'));
        return $volt;
    }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
    return $view;
}, true);
开发者ID:justforleo,项目名称:phalcon-cmf,代码行数:31,代码来源:services.php

示例13: Dispatcher

    $eventsManager = $manager->getShared('eventsManager');
    $dispatcher = new Dispatcher();
    $dispatcher->setEventsManager($eventsManager);
    return $dispatcher;
});
/* ==================================================
 * ตั้งค่าการเชื่อมต่อฐานข้อมูล
 * ================================================== */
$manager->set('db', function () {
    return new DbAdapter(array('host' => $this->config->database->host, 'username' => $this->config->database->username, 'password' => $this->config->database->password, 'dbname' => $this->config->database->dbname, 'options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . $this->config->database->charset)));
});
$manager->set('view', function () {
    $view = new View();
    $view->setViewsDir(__DIR__ . '/views/');
    /* ตำแหน่งเก็บไฟล์ views ทั้งหมด */
    $view->setLayoutsDir(sprintf('%s/%s/', $this->config->theme->themesDir, $this->config->theme->themeDefault));
    /* ตำแหน่งเก็บไฟล์ layouts ทั้งหมด */
    $view->setTemplateAfter('layouts/' . $this->config->theme->layoutDefault);
    /* เลือกไฟล์ layout เริ่มต้น*/
    /* สร้างโฟล์เดอร์เก็บไฟล์ cache */
    $cacheDir = sprintf('%s/%s/', APPLICATION_PATH, $this->config->application->cacheDir);
    if (!is_dir($cacheDir)) {
        mkdir($cacheDir);
    }
    $view->registerEngines(array('.phtml' => function ($view, $di) {
        $volt = new VoltEngine($view, $di);
        $volt->setOptions(array('compiledPath' => sprintf('%s/%s/', APPLICATION_PATH, $this->config->application->cacheDir), 'compiledSeparator' => '_'));
        return $volt;
    }));
    return $view;
});
开发者ID:drivesoftz,项目名称:phalcon2-app-basic,代码行数:31,代码来源:services.php

示例14: initView

 /**
  *
  * @param type $options
  */
 protected function initView($options = [])
 {
     $config = $this->_di->get('config');
     $di = $this->_di;
     if (!file_exists($config->volt->path)) {
         mkdir($config->volt->path, 0777, true);
     }
     $this->_di->setShared('volt', function ($view, $di) use($config) {
         $volt = new Volt($view, $di);
         $volt->setOptions(['compiledPath' => $config->volt->path, 'compiledExtension' => $config->volt->extension, 'compiledSeparator' => $config->volt->separator, 'compileAlways' => (bool) $config->volt->compileAlways, 'stat' => (bool) $config->volt->stat]);
         $compiler = $volt->getCompiler();
         $compiler->addFunction('is_a', 'is_a');
         return $volt;
     });
     $this->_di->setShared('view', function () use($config) {
         $view = new View();
         $view->setViewsDir($config->application->viewsDir);
         $view->setMainView('index');
         $view->setLayoutsDir('layouts/');
         $view->setPartialsDir('partials/');
         $view->registerEngines(['.volt' => 'volt', '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php']);
         return $view;
     });
 }
开发者ID:denners777,项目名称:api-phalcon,代码行数:28,代码来源:bootstrap.php

示例15: function

});
/**
 * The URL component is used to generate all kinds of URLs in the application
 */
$di->setShared('url', function () use($config) {
    $url = new UrlResolver();
    $url->setBaseUri($config->application->baseUri);
    return $url;
});
/**
 * Setting up the view component
 */
$di->setShared('view', function () use($config) {
    $view = new View();
    $view->setViewsDir($config->application->viewsDir);
    $view->setLayoutsDir('../../common/layouts/');
    $view->setTemplateAfter('main');
    $view->registerEngines(array('.volt' => function ($view, $di) use($config) {
        $volt = new VoltEngine($view, $di);
        $volt->setOptions(array('compiledPath' => $config->application->cacheDir, 'compiledSeparator' => '_', 'stat' => true, 'compileAlways' => true));
        return $volt;
    }, '.phtml' => 'Phalcon\\Mvc\\View\\Engine\\Php'));
    return $view;
});
/**
 * Database connection is created based in the parameters defined in the configuration file
 */
$di->setShared('db', function () use($config) {
    $dbConfig = $config->database->toArray();
    $adapter = $dbConfig['adapter'];
    unset($dbConfig['adapter']);
开发者ID:zedmaster,项目名称:ticobox,代码行数:31,代码来源:services.php


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