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


PHP AgaviConfig类代码示例

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


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

示例1: main

 /**
  * Executes this task.
  */
 public function main()
 {
     if ($this->path === null) {
         throw new BuildException('The path attribute must be specified');
     }
     $check = new AgaviModuleFilesystemCheck();
     $check->setConfigDirectory($this->project->getProperty('module.config.directory'));
     $check->setPath($this->path->getAbsolutePath());
     if (!$check->check()) {
         throw new BuildException('The path attribute must be a valid module base directory');
     }
     /* We don't know whether the module is configured or not here, so load the
      * values we want properly. */
     $this->tryLoadAgavi();
     $this->tryBootstrapAgavi();
     require_once AgaviConfigCache::checkConfig(sprintf('%s/%s/module.xml', $this->path->getAbsolutePath(), (string) $this->project->getProperty('module.config.directory')));
     $actionPath = AgaviToolkit::expandVariables(AgaviToolkit::expandDirectives(AgaviConfig::get(sprintf('modules.%s.agavi.action.path', strtolower($this->path->getName())), '%core.module_dir%/${moduleName}/actions/${actionName}Action.class.php')), array('moduleName' => $this->path->getName()));
     $pattern = '#^' . AgaviToolkit::expandVariables(str_replace('\\$\\{actionName\\}', '${actionName}', preg_quote($actionPath, '#')), array('actionName' => '(?P<action_name>.*?)')) . '$#';
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path->getAbsolutePath()));
     for (; $iterator->valid(); $iterator->next()) {
         $rdi = $iterator->getInnerIterator();
         if ($rdi->isDot() || !$rdi->isFile()) {
             continue;
         }
         $file = $rdi->getPathname();
         if (preg_match($pattern, $file, $matches)) {
             $this->log(str_replace(DIRECTORY_SEPARATOR, '.', $matches['action_name']));
         }
     }
 }
开发者ID:horros,项目名称:agavi,代码行数:33,代码来源:AgaviDisplayactionsTask.php

示例2: executeConsole

 public function executeConsole(AgaviRequestDataHolder $request_data)
 {
     $migration_description = $request_data->getParameter('description');
     $migration_timestamp = date('YmdHis');
     $migration_slug = StringToolkit::asSnakeCase(trim($request_data->getParameter('name', 'default')));
     $migration_name = StringToolkit::asStudlyCaps($migration_slug);
     $migration_dir = $this->getAttribute('migration_dir');
     // Bit of a hack to build namespace
     if (!preg_match('#.+/app/(?:modules|migration)/(\\w+_?)(?:$|/.+)#', $migration_dir, $matches)) {
         throw new RuntimeError(sprintf('Could not find namespace info in path %s', $migration_dir));
     }
     $namespace_parts = explode('_', $matches[1]);
     if (count($namespace_parts) == 1) {
         // @todo app migration - introduce a project root namespace setting
         $namespace_parts = ['Your', 'Application'];
     }
     // And a hack to determine the technology namespace
     $target = $request_data->getParameter('target');
     if (strpos($target, 'event_source')) {
         $technology = 'CouchDb';
     } elseif (strpos($target, 'view_store')) {
         $technology = 'Elasticsearch';
     } else {
         $technology = 'RabbitMq';
     }
     $migration_filepath = sprintf('%1$s%2$s%3$s_%4$s%2$s%4$s.php', $migration_dir, DIRECTORY_SEPARATOR, $migration_timestamp, $migration_slug);
     $twig_renderer = TwigRenderer::create(['template_paths' => [__DIR__]]);
     $twig_renderer->renderToFile($technology . 'Migration.tpl.twig', $migration_filepath, ['name' => $migration_name, 'timestamp' => $migration_timestamp, 'description' => $migration_description, 'folder' => $migration_dir, 'filepath' => $migration_filepath, 'vendor_prefix' => $namespace_parts[0], 'package_prefix' => $namespace_parts[1], 'technology' => $technology, 'project_prefix' => AgaviConfig::get('core.project_prefix')]);
     return $this->cliMessage('-> migration template was created here:' . PHP_EOL . $migration_filepath . PHP_EOL);
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-vendor,代码行数:30,代码来源:CreateSuccessView.class.php

示例3: __construct

 public function __construct()
 {
     if (file_exists($this->icingaWebDir . '/app/config.php')) {
         require $this->icingaWebDir . '/lib/agavi/src/agavi.php';
         require $this->icingaWebDir . '/app/config.php';
         require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Exception.php';
         require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Locator/Injectable.php';
         require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Access.php';
         require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Record/Abstract.php';
         require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Record.php';
         require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Record/Iterator.php';
         require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Null.php';
         require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Core.php';
         require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Configurable.php';
         require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Manager/Exception.php';
         require_once $this->icingaWebDir . '/lib/doctrine/lib/Doctrine/Manager.php';
         require_once $this->icingaWebDir . '/app/modules/AppKit/lib/database/models/generated/BaseNsmUser.php';
         require_once $this->icingaWebDir . '/app/modules/AppKit/lib/database/models/NsmUser.php';
         Agavi::bootstrap('production');
         AgaviConfig::set('core.default_context', 'web');
         AgaviConfig::set('core.context_implementation', 'AppKitAgaviContext');
         AgaviContext::getInstance('web')->getController()->dispatch();
         $icingWebUser = new NsmUser('nsm_user');
         //                $icingWebUser->
         $icingWebUser->updatePassword($newPassword);
     }
 }
开发者ID:stpq,项目名称:icinga_configurator,代码行数:27,代码来源:IEIcingaWebUser.php

示例4: execute

 /**
  * Execute this configuration handler.
  *
  * @param      AgaviXmlConfigDomDocument The document to parse.
  *
  * @return     string Data to be written to a cache file.
  *
  * @throws     <b>AgaviParseException</b> If a requested configuration file is
  *                                        improperly formatted.
  *
  * @author     Sean Kerr <skerr@mojavi.org>
  * @author     Dominik del Bondio <ddb@bitxtender.com>
  * @author     David Zülke <david.zuelke@bitextender.com>
  * @since      0.9.0
  */
 public function execute(AgaviXmlConfigDomDocument $document)
 {
     // set up our default namespace
     $document->setDefaultNamespace(self::XML_NAMESPACE, 'compile');
     $config = $document->documentURI;
     $data = array();
     // let's do our fancy work
     foreach ($document->getConfigurationElements() as $configuration) {
         if (!$configuration->has('compiles')) {
             continue;
         }
         foreach ($configuration->get('compiles') as $compileFile) {
             $file = trim($compileFile->getValue());
             $file = AgaviToolkit::expandDirectives($file);
             $file = self::replacePath($file);
             $file = realpath($file);
             if (!is_readable($file)) {
                 // file doesn't exist
                 $error = 'Configuration file "%s" specifies nonexistent ' . 'or unreadable file "%s"';
                 $error = sprintf($error, $config, $compileFile->getValue());
                 throw new AgaviParseException($error);
             }
             if (AgaviConfig::get('core.debug', false)) {
                 // debug mode, just require() the files, makes for nicer stack traces
                 $contents = 'require(' . var_export($file, true) . ');';
             } else {
                 // no debug mode, so make things fast
                 $contents = $this->formatFile(file_get_contents($file));
             }
             // append file data
             $data[$file] = $contents;
         }
     }
     return $this->generate($data, $config);
 }
开发者ID:horros,项目名称:agavi,代码行数:50,代码来源:AgaviCompileConfigHandler.class.php

示例5: testModuleLoading

 /**
  * @group Module 
  */
 public function testModuleLoading()
 {
     $ctx = IcingaWebTestTool::getContext();
     $ctx->getController()->initializeModule(self::MODULE_NAME);
     $re = AgaviConfig::get('modules.' . strtolower(self::MODULE_NAME) . '.enabled');
     $this->assertTrue($re);
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:10,代码来源:ModuleLoadingTest.php

示例6: executeHtml

 /**
  * Execute any html related presentation logic and sets up our template attributes.
  *
  * @param AgaviRequestDataHolder $request_data
  */
 public function executeHtml(AgaviRequestDataHolder $request_data)
 {
     $this->setAttribute(self::ATTRIBUTE_RENDERED_NAVIGATION, '');
     $this->setupHtml($request_data);
     if ($this->container->hasAttributeNamespace('org.agavi.controller.forwards.login')) {
         // forward from controller due to secure action (and login action could not authenticate automatically)
         // store the input URL in the session for a redirect after login
         $base_href = $this->routing->getBaseHref();
         $url = $this->request->getUrl();
         // we only want to store the requested URL when it starts with the current base href
         if (strpos($url, "{$base_href}", 0) === 0) {
             // only store URL when it was a GET as otherwise the URL may not even have a read method
             if ($this->request->getMethod() !== 'read') {
                 // we store the REFERER when the request is not GET, as it's most probably a form on that page.
                 // when no valid REFERER is available we use the target input URL instead
                 $url = $request_data->get('headers', 'REFERER', $url);
             }
             $this->user->setAttribute('redirect_url', $url, 'de.honeybee-cms.login');
         }
         // as this is an internal forward the input form will not be the expected output of users/consumers,
         // thus we need to tell them that they're not authenticated and must fill the form or fix it otherwise
         $this->getResponse()->setHttpStatusCode(401);
     } else {
         // clear redirect from session as it's probably just a direct request of this login form
         if ($this->request->getMethod() === 'read') {
             $this->user->removeAttribute('redirect_url', 'de.honeybee-cms.login');
         } else {
             // when users submit wrong credentials we don't want to forget his original target url
         }
     }
     $this->setAttribute('reset_password_enabled', AgaviConfig::get('core.reset_password_enabled', true));
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-vendor,代码行数:37,代码来源:LoginInputView.class.php

示例7: executeSimple

 /**
  * retrieves content via model and returns it
  * @param   AgaviRequestDataHolder      $rd             required by Agavi but not used here
  * @return  string                      $content        generated content
  * @author  Christian Doebler <christian.doebler@netways.de>
  */
 public function executeSimple(AgaviRequestDataHolder $rd)
 {
     if ($rd->getParameter('interface', false) == true) {
         return $this->executeHtml($rd);
     }
     try {
         try {
             $modules = AgaviConfig::get("org.icinga.modules", array());
             $fileName = $rd->getParameter('template');
             $file = null;
             foreach ($modules as $name => $path) {
                 if (file_exists($path . "/config/templates/" . $fileName . '.xml')) {
                     $file = AppKitFileUtil::getAlternateFilename($path . "/config/templates/", $fileName, '.xml');
                 }
             }
             if ($file === null) {
                 $file = AppKitFileUtil::getAlternateFilename(AgaviConfig::get('modules.cronks.xml.path.to'), $fileName, '.xml');
             }
             $model = $this->getContext()->getModel('System.StaticContent', 'Cronks', array('rparam' => $rd->getParameter('p', array())));
             $model->setTemplateFile($file->getRealPath());
             $content = $model->renderTemplate($rd->getParameter('render', 'MAIN'), $rd->getParameters());
             return sprintf('<div class="%s">%s</div>', 'static-content-container', $content);
         } catch (AppKitFileUtilException $e) {
             $msg = 'Could not find template for ' . $rd->getParameter('template');
             AppKitAgaviUtil::log('Could not find template for ' . $rd->getParameter('template'), AgaviLogger::ERROR);
             return $msg;
         }
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:37,代码来源:StaticContentSuccessView.class.php

示例8: executeWrite

 public function executeWrite(\AgaviRequestDataHolder $request_data)
 {
     $report = array();
     try {
         $style = $request_data->getParameter('style', AgaviConfig::get('sass.style', 'compressed'));
         $themes = $request_data->getParameter('themes', []);
         $packer = new AssetCompiler();
         // just in case
         $packer->symlinkModuleAssets();
         if (empty($themes)) {
             $compilation_succeeded = $packer->compileThemes($style, $report);
         } else {
             foreach ($themes as $theme) {
                 $compilation_succeeded = $packer->compileTheme($theme, $style, $report);
             }
         }
         $compilation_succeeded &= $packer->compileModuleStyles($style, $report);
         $this->setAttribute('report', $report);
     } catch (\Exception $e) {
         $this->setAttribute('error', $e->getMessage());
         return 'Error';
     }
     if (!$compilation_succeeded) {
         return 'Error';
     }
     return 'Success';
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-vendor,代码行数:27,代码来源:CompileScssAction.class.php

示例9: executeJson

 public function executeJson(AgaviRequestDataHolder $rd)
 {
     try {
         $modules = AgaviConfig::get("org.icinga.modules", array());
         $fileName = $rd->getParameter('template');
         $file = null;
         foreach ($modules as $name => $path) {
             if (file_exists($path . "/config/templates/" . $fileName . '.xml')) {
                 $file = AppKitFileUtil::getAlternateFilename($path . "/config/templates/", $fileName, '.xml');
             }
         }
         if ($file === null) {
             $file = AppKitFileUtil::getAlternateFilename(AgaviConfig::get('modules.cronks.xml.path.grid'), $rd->getParameter('template'), '.xml');
         }
         $template = new CronkGridTemplateXmlParser($file->getRealPath());
         $template->parseTemplate();
         $user = $this->getContext()->getUser()->getNsmUser();
         $data = $template->getTemplateData();
         if ($user->hasTarget('IcingaCommandRestrictions')) {
             $template->removeRestrictedCommands();
         }
         return json_encode(array('template' => $template->getTemplateData(), 'fields' => $template->getFields(), 'keys' => $template->getFieldKeys(), 'params' => $rd->getParameters(), 'connections' => IcingaDoctrineDatabase::$icingaConnections));
     } catch (AppKitFileUtilException $e) {
         $msg = 'Could not find template for ' . $rd->getParameter('template');
         AppKitAgaviUtil::log('Could not find template for ' . $rd->getParameter('template'), AgaviLogger::ERROR);
         return $msg;
     }
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:28,代码来源:MetaInformationSuccessView.class.php

示例10: registerValidators

 public static function registerValidators(Form_FormModel $form, AgaviValidationManager $vm, array $parameters, array $files = array())
 {
     $conditions = array();
     foreach ($form->getChildren() as $child) {
         if ($child instanceof Form_Elements_FieldsetModel) {
             continue;
         }
         $parents = (array) $child->parents;
         $depends = array();
         foreach ($parents as $id => $condition) {
             $depend = bin2hex("{$id}_{$condition['opration']}_{$condition['condition']}");
             $parent = $form->getChildById($id);
             if (is_null($parent)) {
                 throw new Exception("can't find parent with id={$id} for {$child->id}");
             }
             if (!isset($conditions[$depend])) {
                 $vm->createValidator('Form_ValidatorModel', array($parent->name), array(), array('model' => 'Elements.Condition', 'name' => $depend, 'module' => 'Form', 'configuration' => $condition, 'provides' => $depend, 'severity' => 'info'));
                 $conditions[$depend] = true;
             }
             $depends[] = $depend;
         }
         if (is_callable(array($child, 'registerValidators'))) {
             $child->registerValidators($vm, $depends, $parameters, $files);
         } else {
             $vm->createValidator('Form_ValidatorModel', array($child->name), array('' => 'field is required'), array('element' => $child, 'name' => $child->name, 'export' => $child->name, 'depends' => $depends, 'translation_domain' => AgaviConfig::get('Form.TranslationDomain'), 'required' => (bool) $child->required));
         }
     }
 }
开发者ID:armezit,项目名称:agavi-form-models-set,代码行数:28,代码来源:ValidatorModel.class.php

示例11: executeWrite

 public function executeWrite(\AgaviRequestDataHolder $request_data)
 {
     $report = array();
     $success = false;
     try {
         $optimize_style = $request_data->getParameter('optimize', AgaviConfig::get('requirejs.optimize_style', 'uglify2'));
         $buildfile_path = $request_data->getParameter('buildfile', AgaviConfig::get('requirejs.buildfile_path', AgaviConfig::get('core.pub_dir') . "/static/buildconfig.js"));
         $packer = new AssetCompiler();
         // just in case
         $packer->symlinkModuleAssets();
         // render buildconfig.js and put it into the target location for compilation
         $template_service = new ModuleTemplateRenderer();
         $buildconfig_content = $template_service->render('rjs/buildconfig.js');
         $success = file_put_contents($buildfile_path, $buildconfig_content, LOCK_EX);
         if (!$success) {
             $this->setAttribute('error', 'Could not write file: ' . $buildfile_path);
         }
         $success = $packer->compileJs($buildfile_path, $optimize_style, $report);
         $this->setAttribute('report', $report);
     } catch (\Exception $e) {
         $this->setAttribute('error', $e->getMessage());
         return 'Error';
     }
     if (!$success) {
         return 'Error';
     }
     return 'Success';
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-vendor,代码行数:28,代码来源:CompileJsAction.class.php

示例12: executeHtml

 public function executeHtml(AgaviRequestDataHolder $rd)
 {
     $this->setupHtml($rd);
     if ($this->getContext()->getUser()->isAuthenticated() !== true) {
         $this->getResponse()->setHttpStatusCode('403');
     }
     $this->setAttribute('message', false);
     $message = AgaviConfig::get('modules.appkit.auth.message', false);
     if ($rd->has('cookies', 'icinga-web-loginname') && AgaviConfig::get('modules.appkit.auth.behaviour.store_loginname', false) === true) {
         $this->setAttribute('username', $rd->get('cookies', 'icinga-web-loginname'));
     }
     if ($message !== false && is_array($message)) {
         if (isset($message['show']) && $message['show'] == true) {
             if (isset($message['include_file']) && file_exists($message['include_file'])) {
                 $text = file_get_contents($message['include_file']);
             } else {
                 $text = isset($message['text']) ? $message['text'] : null;
             }
             if ($text) {
                 $text = AppKitAgaviUtil::replaceConfigVars($text);
             }
             $this->setAttribute('message', true);
             $this->setAttribute('message_text', $text);
             $this->setAttribute('message_title', $message['title']);
             $this->setAttribute('message_expand_first', isset($message['expand_first']) ? (bool) $message['expand_first'] : false);
         }
     }
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:28,代码来源:AjaxLoginSuccessView.class.php

示例13: dispatch

 public static function dispatch($arguments = array())
 {
     $GLOBALS['__PHPUNIT_BOOTSTRAP'] = dirname(__FILE__) . '/templates/AgaviBootstrap.tpl.php';
     $suites = (include AgaviConfigCache::checkConfig(AgaviConfig::get('core.testing_dir') . '/config/suites.xml'));
     $master_suite = new AgaviTestSuite('Master');
     if (!empty($arguments['include-suite'])) {
         $names = explode(',', $arguments['include-suite']);
         unset($arguments['include-suite']);
         foreach ($names as $name) {
             if (empty($suites[$name])) {
                 throw new InvalidArgumentException(sprintf('Invalid suite name %1$s.', $name));
             }
             $master_suite->addTest(self::createSuite($name, $suites[$name]));
         }
     } else {
         $excludes = array();
         if (!empty($arguments['exclude-suite'])) {
             $excludes = explode(',', $arguments['exclude-suite']);
             unset($arguments['exclude-suite']);
         }
         foreach ($suites as $name => $suite) {
             if (!in_array($name, $excludes)) {
                 $master_suite->addTest(self::createSuite($name, $suite));
             }
         }
     }
     $runner = new PHPUnit_TextUI_TestRunner();
     $runner->doRun($master_suite, $arguments);
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:29,代码来源:AgaviTesting.class.php

示例14: execute

 public function execute(AgaviRequestDataHolder $rd)
 {
     $enable_silent = AgaviConfig::get('modules.appkit.auth.behaviour.enable_silent', false);
     $enable_dialog = AgaviConfig::get('modules.appkit.auth.behaviour.enable_dialog', false);
     $this->setAttribute('authenticated', false);
     $this->setAttribute('template', false);
     if (!$enable_dialog && !$enable_silent) {
         return 'ConfigError';
     }
     $dispatch = $this->getContext()->getModel('Auth.Dispatch', 'AppKit');
     if ($enable_silent == true) {
         if ($dispatch->hasSilentProvider()) {
             $username = $dispatch->guessUsername();
             if ($username !== false) {
                 $user = $this->getContext()->getUser();
                 try {
                     $user->doLogin($username, null, false);
                     $this->setAttribute('authenticated', true);
                 } catch (AgaviSecurityException $e) {
                     if ($enable_dialog == false) {
                         return 'Error';
                     }
                 }
             }
         }
     }
     return $this->getDefaultViewName();
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:28,代码来源:SilentAuthAction.class.php

示例15: setUp

 public function setUp()
 {
     $this->_file = tempnam(AgaviConfig::get('core.cache_dir'), 'AgaviFileLoggerAppenderTest');
     unlink($this->_file);
     $this->_fa = new AgaviFileLoggerAppender();
     $this->_fa->initialize($this->getContext(), array('file' => $this->_file));
     $this->_fa->setLayout(new AgaviPassthruLoggerLayout());
 }
开发者ID:horros,项目名称:agavi,代码行数:8,代码来源:AgaviFileLoggerAppenderTest.php


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