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


PHP kernel函数代码示例

本文整理汇总了PHP中kernel函数的典型用法代码示例。如果您正苦于以下问题:PHP kernel函数的具体用法?PHP kernel怎么用?PHP kernel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: newRenderer

 public function newRenderer()
 {
     $kernel = kernel();
     $this->env = $kernel->twig->env;
     $this->loader = $kernel->twig->loader;
     return $this->env;
 }
开发者ID:azole,项目名称:Phifty,代码行数:7,代码来源:Twig.php

示例2: registerBundleDir

 public function registerBundleDir($dir)
 {
     $this->bundleDirs[] = $dir;
     if ($twig = kernel()->twig) {
         $twig->loader->addPath($dir);
     }
 }
开发者ID:appleboy,项目名称:Phifty,代码行数:7,代码来源:BundleManager.php

示例3: execute

 public function execute()
 {
     $router = kernel()->router;
     $router->compile();
     $dumper = new ConsoleDumper();
     $dumper->dump($router->routes);
 }
开发者ID:corneltek,项目名称:phifty,代码行数:7,代码来源:RouterCommand.php

示例4: execute

 public function execute()
 {
     $bundles = kernel()->bundles;
     $config = [];
     $kernel = kernel();
     $config['name'] = 'site/' . strtolower($kernel->getApplicationId());
     $config['version'] = '1.0';
     $config['require'] = [];
     foreach ($bundles as $bundle) {
         if ($bundle instanceof ComposerConfigBridge) {
             if ($deps = $bundle->getComposerDependency()) {
                 $this->mergeConfig($config, $deps);
             }
         }
     }
     foreach ($kernel->services as $service) {
         if ($service instanceof ComposerConfigBridge) {
             if ($deps = $service->getComposerDependency()) {
                 $this->mergeConfig($config, $deps);
             }
         }
     }
     $config['require-dev'] = ["corneltek/phpunit-testmore" => "dev-master"];
     $config['scripts'] = ["post-install-cmd" => ["Phifty\\Installer\\ComposerInstaller::postInstall"]];
     echo json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
 }
开发者ID:azole,项目名称:Phifty,代码行数:26,代码来源:ComposerConfigCommand.php

示例5: generate

 public function generate($ns, $controllerName)
 {
     $app = strtolower($ns) == 'app' ? kernel()->getApp() : (kernel()->bundle($ns) ?: kernel()->bundles->load($ns));
     if (!$app) {
         throw new Exception("Application or bundle not found.");
     }
     if (strrpos($controllerName, 'Controller') === false) {
         $controllerName .= 'Controller';
     }
     $args = func_get_args();
     $args = array_splice($args, 2);
     $controllerActions = array('indexAction');
     foreach ($args as $arg) {
         $controllerActions[] = $arg . 'Action';
     }
     $dir = $app->locate();
     $className = $ns . '\\Controller\\' . $controllerName;
     $classDir = $dir . DIRECTORY_SEPARATOR . 'Controller';
     $classFile = $classDir . DIRECTORY_SEPARATOR . $controllerName . '.php';
     if (!file_exists($classDir)) {
         mkdir($classDir, 0755, true);
     }
     if (file_exists($classFile)) {
         $this->logger->info("Found existing {$classFile}, skip");
         return;
     }
     $this->render('Controller.php.twig', $classFile, array('namespace' => $ns, 'controllerName' => $controllerName, 'controllerActions' => $controllerActions));
 }
开发者ID:corneltek,项目名称:phifty,代码行数:28,代码来源:Generator.php

示例6: testKernel

 public function testKernel()
 {
     $kernel = kernel();
     $this->assertNotNull($kernel);
     $this->assertFileExists($kernel->webroot);
     $this->assertFileExists($kernel->rootDir);
 }
开发者ID:corneltek,项目名称:phifty,代码行数:7,代码来源:KernelTest.php

示例7: execute

 public function execute()
 {
     // xxx: Can use universal requirement checker.
     //
     // $req = new Universal\Requirement\Requirement;
     // $req->extensions( 'apc','mbstring' );
     // $req->classes( 'ClassName' , 'ClassName2' );
     // $req->functions( 'func1' , 'func2' , 'function3' )
     //
     $exts = array('apc', 'pdo', 'pdo_mysql', 'pdo_sqlite', 'pdo_pgsql', 'gd', 'mysqli');
     echo "extensions:\n";
     foreach ($exts as $ext) {
         $this->printResult($ext, extension_loaded($ext));
     }
     $this->printResult('reflection', class_exists('ReflectionObject'));
     echo "classes:\n";
     $this->printResult('lazyrecord', class_exists('LazyRecord\\BaseModel', true));
     $this->printResult('assetkit', class_exists('AssetKit\\AssetLoader', true));
     $this->printResult('roller', class_exists('Roller\\Router', true));
     echo "config:\n";
     $this->printResult('short_open_tag', ini_get('short_open_tag'));
     $this->printResult('roller extension', extension_loaded('roller'));
     $kernel = kernel();
     if ($configext = $kernel->config->get('Requirement.Extensions')) {
         foreach ($configext as $extname) {
             $this->printResult("{$extname} extension", extension_loaded($extname));
         }
     }
     // TODO:
     //   1. get services and get dependencies from these services for checking
     foreach ($kernel->bundles as $bundle) {
         // $dir = $plugin->getTemplateDir();
     }
 }
开发者ID:corneltek,项目名称:phifty,代码行数:34,代码来源:CheckCommand.php

示例8: run

 public function run()
 {
     $kernel = kernel();
     $frameworkId = $kernel::FRAMEWORK_ID;
     $appId = $kernel->config->framework->ApplicationID;
     /* merge/update framework locale into app locale dir */
     $finder = Finder::create()->files()->name('*.po')->in(PH_ROOT . DIRECTORY_SEPARATOR . 'locale');
     $itr = $finder->getIterator();
     foreach ($itr as $item) {
         # echo $item->getPathname(). "\n";
         $sourceDir = dirname($item->getPathname());
         $sourceRelPath = FileUtils::remove_base($item->getPathname(), PH_ROOT);
         $sourceRelDir = dirname($sourceRelPath);
         $targetDir = PH_APP_ROOT . DIRECTORY_SEPARATOR . $sourceRelDir;
         FileUtils::mkpath($targetDir);
         $sourcePo = $sourceDir . DIRECTORY_SEPARATOR . $frameworkId . '.po';
         $targetPo = $targetDir . DIRECTORY_SEPARATOR . $appId . '.po';
         # var_dump( $sourcePo , $targetPo );
         if (file_exists($targetPo)) {
             $this->log("Msgcat " . basename($sourcePo) . ' => ' . basename($targetPo));
             $merged = '';
             $h = popen("msgcat {$sourcePo} {$targetPo}", 'r');
             while (!feof($h)) {
                 // send the current file part to the browser
                 $merged .= fread($h, 1024);
             }
             pclose($h);
             $this->log("Writing back to ");
             file_put_contents($targetPo, $merged);
         } else {
             $this->log("Copying files..");
             copy($sourcePo, $targetPo);
         }
     }
 }
开发者ID:corneltek,项目名称:phifty,代码行数:35,代码来源:Locale.php

示例9: execute

 public function execute()
 {
     $options = $this->options;
     $config = $this->getAssetConfig();
     $loader = $this->getAssetLoader();
     $installer = $options->link ? new LinkInstaller($config) : new Installer($config);
     $installer->logger = $this->logger;
     $loader = $this->getAssetLoader();
     $kernel = kernel();
     $this->logger->info("Installing assets from applications...");
     foreach ($kernel->applications as $application) {
         $assetNames = $application->assets();
         $assets = $loader->loadAssets($assetNames);
         foreach ($assets as $asset) {
             $this->logger->info("Installing {$asset->name} ...");
             $installer->install($asset);
         }
     }
     $this->logger->info("Installing assets from bundles...");
     foreach ($kernel->bundles as $plugin) {
         $assetNames = $plugin->assets();
         $assets = $loader->loadAssets($assetNames);
         foreach ($assets as $asset) {
             $this->logger->info("Installing {$asset->name} ...");
             $installer->install($asset);
         }
     }
     $compiledDir = $config->getCompiledDir();
     if (!file_exists($compiledDir)) {
         $this->logger->info("Creating asset compiled dir: {$compiledDir}");
         $this->logger->info("Please chmod this directory as you need.");
         mkdir($compiledDir, 0777, true);
     }
     $this->logger->info("Done");
 }
开发者ID:appleboy,项目名称:Phifty,代码行数:35,代码来源:AssetInstallCommand.php

示例10: execute

 public function execute()
 {
     $kernel = kernel();
     $localeDir = $kernel->config->get('framework', 'Services.LocaleService.Directory') ?: 'locale';
     $frameworkLocaleDir = PH_ROOT . DIRECTORY_SEPARATOR . 'locale';
     $langs = $kernel->config->get('framework', 'Services.LocaleService.Langs')->config;
     $cwd = getcwd();
     $appPoFiles = array();
     $frameworkId = Kernel::FRAMEWORK_ID;
     $appId = $kernel->config->framework->ApplicationID;
     $frameworkPoFilename = $frameworkId . '.po';
     $appPoFilename = $appId . '.po';
     $this->logger->info("Compiling message catalog...");
     // Update message catalog
     $finder = Finder::create()->files()->name('*.po')->in($localeDir);
     foreach ($finder->getIterator() as $file) {
         $targetFile = futil_replace_extension($file, 'mo');
         $this->logger->info("Compiling messages {$file} to {$targetFile}");
         $cmd = sprintf('msgfmt -v --use-fuzzy -o %s %s', $targetFile, $file);
         $this->logger->debug($cmd);
         system($cmd, $retval);
         if ($retval != 0) {
             die('xgettext error');
         }
     }
 }
开发者ID:corneltek,项目名称:phifty,代码行数:26,代码来源:LocaleUpdateCommand.php

示例11: testCurrentUserService

 public function testCurrentUserService()
 {
     $kernel = kernel();
     $service = new Phifty\ServiceProvider\CurrentUserServiceProvider();
     $service->register($kernel, array());
     ok($service);
     ok($kernel->currentUser);
 }
开发者ID:corneltek,项目名称:phifty,代码行数:8,代码来源:CurrentUserServiceTest.php

示例12: execute

 public function execute()
 {
     $kernel = kernel();
     $webroot = $kernel->webroot;
     foreach (kernel()->plugins as $plugin) {
         // Exporting Web directory
     }
 }
开发者ID:corneltek,项目名称:phifty,代码行数:8,代码来源:ExportCommand.php

示例13: schema

 public function schema()
 {
     $this->column('lang')->varchar(12)->validValues(function () {
         return array_flip(kernel()->locale->available());
     })->label('語言')->default(function () {
         return kernel()->locale->getDefault();
     })->renderAs('SelectInput');
 }
开发者ID:corneltek,项目名称:phifty,代码行数:8,代码来源:I18NSchema.php

示例14: testRegisterTwigService

 public function testRegisterTwigService()
 {
     $kernel = kernel();
     $twig = new \Phifty\Service\TwigService();
     $twig->register($kernel, array('Environment' => array('debug' => true, 'cache' => 'cache/path', 'autoload' => 'auto_reload'), 'TemplateDirs' => array('applications', 'bundles')));
     $this->assertNotNull($kernel->twig);
     $this->assertNotNull($kernel->twig->env, 'get environment');
     $this->assertNotNull($kernel->twig->loader, 'get loader');
 }
开发者ID:azole,项目名称:Phifty,代码行数:9,代码来源:TwigServiceTest.php

示例15: render

 public function render($attributes = array())
 {
     $id = $this->getSerialId();
     $html = parent::render($attributes);
     $recordClass = $this->record_class;
     $record = new $recordClass();
     $deleteAction = $record->getRecordActionClass('Delete');
     $env = kernel()->twig->env;
     $html .= $env->render('@CRUD/widgets/quick_crud_widget.html', array('deleteAction' => str_replace('\\', '::', $deleteAction), 'selectInputId' => $id, 'dataLabelField' => $record->getDataLabelField(), 'dataValueField' => $record->getDataValueField(), 'dialogPath' => $this->dialog_path, 'self' => $this));
     return $html;
 }
开发者ID:phifty-framework,项目名称:CRUD,代码行数:11,代码来源:QuickCRUDSelectInput.php


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