當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Application::extend方法代碼示例

本文整理匯總了PHP中Pagekit\Application::extend方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::extend方法的具體用法?PHP Application::extend怎麽用?PHP Application::extend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pagekit\Application的用法示例。


在下文中一共展示了Application::extend方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: main

 /**
  * {@inheritdoc}
  */
 public function main(App $app)
 {
     $this->breadcrumbs = new BreadcrumbsManager($app);
     $app->extend('view', function ($view) {
         return $view->addGlobal('breadcrumbs', $this);
     });
 }
開發者ID:Bixie,項目名稱:pagekit-breadcrumbs,代碼行數:10,代碼來源:BreadcrumbsModule.php

示例2: main

 /**
  * {@inheritdoc}
  */
 public function main(App $app)
 {
     $app['system'] = $this;
     $app['isAdmin'] = false;
     $app->factory('finder', function () {
         return Finder::create();
     });
     $app['db.em'];
     // -TODO- fix me
     $theme = $this->config('site.theme');
     foreach (array_merge($this->config['extensions'], (array) $theme) as $module) {
         try {
             $app['module']->load($module);
         } catch (\RuntimeException $e) {
             $app['log']->warn("Unable to load extension: {$module}");
         }
     }
     if (!($app['theme'] = $app->module($theme))) {
         $app['theme'] = new Module(['name' => 'default-theme', 'path' => '', 'config' => [], 'layout' => 'views:system/blank.php']);
     }
     $app->extend('view', function ($view) use($app) {
         $theme = $app->isAdmin() ? $app->module('system/theme') : $app['theme'];
         $view->map('layout', $theme->get('layout', 'views:template.php'));
         return $view->addGlobal('theme', $app['theme']);
     });
 }
開發者ID:birah,項目名稱:pagekit,代碼行數:29,代碼來源:SystemModule.php

示例3: main

 /**
  * {@inheritdoc}
  */
 public function main(App $app)
 {
     $app['system'] = $this;
     $app['isAdmin'] = false;
     $app->factory('finder', function () {
         return Finder::create();
     });
     $app['db.em'];
     // -TODO- fix me
     $app->extend('view', function ($view) use($app) {
         $theme = $app->isAdmin() ? $app->module('system/theme') : $app['theme'];
         $view->map('layout', $theme->get('layout', 'views:template.php'));
         return $view->addGlobal('theme', $app['theme']);
     });
     $app->extend('assets', function ($factory) use($app) {
         $secret = $this->config['secret'];
         $version = substr(sha1($app['version'] . $secret), 0, 4);
         $factory->setVersion($version);
         return $factory;
     });
     $theme = $this->config('site.theme');
     $app['module']->addLoader(function ($module) use($app, $theme) {
         if (in_array($module['name'], $this->config['extensions'])) {
             $module['type'] = 'extension';
             $app['locator']->add("{$module['name']}:", $module['path']);
             $app['locator']->add("views:{$module['name']}", "{$module['path']}/views");
         } else {
             if ($module['name'] == $theme) {
                 $module['type'] = 'theme';
                 $app['locator']->add('theme:', $module['path']);
                 $app['locator']->add('views:', "{$module['path']}/views");
             }
         }
         return $module;
     });
     foreach (array_merge($this->config['extensions'], (array) $theme) as $module) {
         try {
             $app['module']->load($module);
         } catch (\RuntimeException $e) {
             $module = ucfirst($module);
             $app['log']->error("[{$module} exception]: {$e->getMessage()}");
         }
     }
     if (!($app['theme'] = $app->module($theme))) {
         $app['theme'] = new Module(['name' => 'theme-default', 'type' => 'theme', 'path' => '', 'config' => [], 'layout' => 'views:system/blank.php']);
     }
 }
開發者ID:aqnouch,項目名稱:rimbo,代碼行數:50,代碼來源:SystemModule.php

示例4: main

 /**
  * {@inheritdoc}
  */
 public function main(App $app)
 {
     $app['filter']->register('filesize', 'Bixie\\Framework\\Filter\\FileSizeFilter');
     $app->on('boot', function ($event, $app) {
         $app->extend('view', function ($view) use($app) {
             return $view->addHelper(new ImageHelper($app));
         });
     });
 }
開發者ID:Bixie,項目名稱:pagekit-framework,代碼行數:12,代碼來源:FrameworkModule.php

示例5: main

 /**
  * {@inheritdoc}
  */
 public function main(App $app)
 {
     $app['translator'] = function () {
         $translator = new Translator($this->getLocale());
         $translator->addLoader('php', new PhpFileLoader());
         $translator->addLoader('mo', new MoFileLoader());
         $translator->addLoader('po', new PoFileLoader());
         $translator->addLoader('array', new ArrayLoader());
         $this->loadLocale($this->getLocale(), $translator);
         return $translator;
     };
     $app->extend('view', function ($view) {
         return $view->addGlobal('intl', $this);
     });
     require __DIR__ . '/../functions.php';
 }
開發者ID:LibraryOfLawrence,項目名稱:pagekit,代碼行數:19,代碼來源:IntlModule.php

示例6: main

 /**
  * {@inheritdoc}
  */
 public function main(App $app)
 {
     $app['node'] = function ($app) {
         if ($id = $app['request']->attributes->get('_node') and $node = Node::find($id, true)) {
             return $node;
         }
         return Node::create();
     };
     $app['menu'] = function ($app) {
         $menus = new MenuManager($app->config($app['theme']->name), $this->config('menus'));
         foreach ($app['theme']->get('menus', []) as $name => $label) {
             $menus->register($name, $label);
         }
         return $menus;
     };
     $app->extend('view', function ($view) use($app) {
         return $view->addHelper(new MenuHelper($app['menu']));
     });
 }
開發者ID:LibraryOfLawrence,項目名稱:pagekit,代碼行數:22,代碼來源:SiteModule.php


注:本文中的Pagekit\Application::extend方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。