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


PHP AgaviRequestDataHolder类代码示例

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


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

示例1: 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

示例2: createDOM

 protected function createDOM(AgaviRequestDataHolder $rd)
 {
     $results = $rd->getParameter("searchResult", null);
     $count = $rd->getParameter("searchCount");
     $DOM = new DOMDocument("1.0", "UTF-8");
     $root = $DOM->createElement("results");
     $DOM->appendChild($root);
     foreach ($results as $result) {
         $resultNode = $DOM->createElement("result");
         $root->appendChild($resultNode);
         foreach ($result as $fieldname => $field) {
             $node = $DOM->createElement("column");
             $node->nodeValue = $field;
             $name = $DOM->createAttribute("name");
             $name->nodeValue = $fieldname;
             $node->appendChild($name);
             $resultNode->appendChild($node);
         }
     }
     if ($count) {
         $count = array_values($count[0]);
         $node = $DOM->createElement("total");
         $node->nodeValue = $count[0];
         $root->appendChild($node);
     }
     return $DOM;
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:27,代码来源:ApiSearchSuccessView.class.php

示例3: testSaveState

 /**
  * @depends testReadState
  * @group Database
  */
 public function testSaveState()
 {
     info("\tTesting state-save\n");
     $token = str_shuffle("ABCDEF123456789");
     $params = array("cmd" => "write", "data" => '[{"name":"test-case-setting","value":"TEST_CASE_' . $token . '"}]', "id" => 1, "session" => "session", "user" => "user");
     $paramHolder = new AgaviRequestDataHolder();
     $paramHolder->setParameters($params);
     $controller = AgaviContext::getInstance()->getController();
     $container = $controller->createExecutionContainer("AppKit", "Ext.ApplicationState", $paramHolder, "javascript", "write");
     try {
         $result = $container->execute();
         $data = json_decode($result->getContent(), true);
     } catch (Exception $e) {
         $this->fail("An exception was thrown during state write: " . $e->getMessage());
     }
     // Check for success state
     if (@(!$data["success"])) {
         $this->fail("Could not write view state! Your cronk settings may not be saved in icinga-web.");
     }
     // Finally get sure the enry is really set
     $entryFound = false;
     foreach ($data["data"] as $entry) {
         if ($entry["name"] == 'test-case-setting' && $entry["value"] == 'TEST_CASE_' . $token) {
             $entryFound = true;
         }
     }
     if (!$entryFound) {
         $this->fail("Write returned success, but preference could not be found in DB!\n");
     }
     success("\tWriting state succeeded!\n");
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:35,代码来源:persistenceView.php

示例4: authenticate

 /**
  * Tries to authenticate the user with the given request data.
  *
  * @param AgaviRequestDataHolder $request_data
  *
  * @return string name of agavi view to select
  */
 protected function authenticate(AgaviRequestDataHolder $request_data)
 {
     $translation_manager = $this->getContext()->getTranslationManager();
     $user = $this->getContext()->getUser();
     $auth_request = $request_data->getHeader('AUTH_REQUEST');
     $username = $auth_request['username'];
     $password = $auth_request['password'];
     $service_locator = $this->getContext()->getServiceLocator();
     $authentication_service = $service_locator->getAuthenticationService();
     $auth_response = $authentication_service->authenticate($username, $password);
     $log_message = sprintf("username='%s' message='%s' auth_provider='%s' errors=''", $username, $auth_response->getMessage(), get_class($authentication_service), join(';', $auth_response->getErrors()));
     $log_message_part = sprintf("for username '{$username}' via auth provider %s.", get_class($authentication_service));
     if ($auth_response->getState() === AuthResponse::STATE_AUTHORIZED) {
         $view_name = 'Success';
         $user->setAttributes(array_merge(['acl_role' => AclService::ROLE_NON_PRIV], $auth_response->getAttributes()));
         $user->setAuthenticated(true);
         $this->logInfo('[AUTHORIZED] ' . $log_message);
     } elseif ($auth_response->getState() === AuthResponse::STATE_UNAUTHORIZED) {
         $view_name = 'Error';
         $user->setAuthenticated(false);
         $this->setAttribute('errors', ['auth' => $translation_manager->_('invalid_login', 'honeybee.system_account.user.errors')]);
         $this->logError('[UNAUTHORIZED] ' . $log_message);
     } else {
         $view_name = 'Error';
         $user->setAuthenticated(false);
         $this->setAttribute('errors', ['auth' => $auth_response->getMessage()]);
         $vm->setError('invalid_login', $tm->_('invalid_login', 'honeybee.system_account.user.errors'));
         $this->logError("[ERROR] state='" . $auth_response->getState() . "' " . $log_message);
     }
     return $view_name;
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-vendor,代码行数:38,代码来源:ApiLoginAction.class.php

示例5: executeWrite

 public function executeWrite(AgaviRequestDataHolder $rd)
 {
     $username = $rd->getParameter('username');
     $password = $rd->getParameter('password');
     $do = $rd->getParameter('dologin');
     $this->setAttribute('authenticated', false);
     $this->setAttribute('executed', false);
     if ($do) {
         $this->setAttribute('executed', true);
         $user = $this->getContext()->getUser();
         try {
             $user->doLogin($username, $password);
             /*
              * Behaviour for blocking whole access if no icinga access
              */
             //if(!$user->hasCredential("icinga.user")) {
             //    $user->doLogout();
             //    $this->setAttribute('authenticated', false);
             //}
             $this->setAttribute('authenticated', true);
         } catch (AgaviSecurityException $e) {
             $this->setAttribute('authenticated', false);
         }
     }
     return $this->getDefaultViewName();
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:26,代码来源:AjaxLoginAction.class.php

示例6: execute

 public function execute(AgaviRequestDataHolder $rd)
 {
     $type = $rd->getParameter('type', AppKitMessageQueueItem::INFO ^ AppKitMessageQueueItem::ERROR);
     $aggregator = $this->getContext()->getModel('MessageQueueAggregator', 'AppKit');
     $aggregator->setType($type);
     return 'Success';
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:7,代码来源:ShowErrorsAction.class.php

示例7: executeHtml

 public function executeHtml(AgaviRequestDataHolder $rd)
 {
     $this->setAttribute('title', 'Icinga.CronkLoader');
     $tm = $this->getContext()->getTranslationManager();
     try {
         $model = $this->getContext()->getModel('Provider.CronksData', 'Cronks');
         $crname = $rd->getParameter('cronk');
         /*
          * Allow external initialization of cronk stubs
          */
         $parameters = $rd->getParameter('p', array());
         if ($model->hasCronk($crname)) {
             $cronk = $model->getCronk($crname);
             if (array_key_exists('ae:parameter', $cronk) && is_array($cronk['ae:parameter'])) {
                 $cronk['ae:parameter'] = $this->rebuildComplexData($cronk['ae:parameter']);
                 $parameters = (array) $cronk['ae:parameter'] + $parameters + array('module' => $cronk['module'], 'action' => $cronk['action']);
             }
             if (array_key_exists('state', $cronk) && isset($cronk['state'])) {
                 $parameters['state'] = $cronk['state'];
             }
             return $this->createForwardContainer($cronk['module'], $cronk['action'], $parameters, 'simple', 'write');
         } else {
             return $tm->_('Sorry, cronk "%s" not found', null, null, array($crname));
         }
     } catch (Exception $e) {
         return $tm->_('Exception thrown: %s', null, null, array($e->getMessage()));
     }
     return 'Some strange error occured';
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:29,代码来源:CronkLoaderSuccessView.class.php

示例8: 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

示例9: executeJson

 public function executeJson(AgaviRequestDataHolder $rd)
 {
     $connection = $rd->getParameter("connection", "icinga");
     $model = $this->getContext()->getModel('System.StatusMap', 'Cronks', array("connection" => $connection));
     $jsonData = $model->getParentChildStructure();
     return trim(json_encode($jsonData), '[]');
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:7,代码来源:StatusMapSuccessView.class.php

示例10: 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

示例11: executeConsole

 public function executeConsole(AgaviRequestDataHolder $request_data)
 {
     if ($this->hasAttribute('error')) {
         return $this->cliError($this->getAttribute('error'));
     }
     $error_message = 'Watching items had errors.' . PHP_EOL . PHP_EOL;
     $validation_errors = $this->getErrorMessages();
     if (!empty($validation_errors)) {
         $error_message .= implode(PHP_EOL, $validation_errors) . PHP_EOL;
     }
     if (!$this->hasAttribute('report')) {
         return $this->cliError($error_message);
     }
     $report = $this->getAttribute('report');
     $error_message .= 'Report for each item:' . PHP_EOL . PHP_EOL;
     foreach ($report as $directory => $data) {
         $error_message .= $data['name'] . ': ' . ($data['success'] ? 'OK' : 'FAILED');
         if (!$data['success'] && $request_data->getParameter('verbose', true)) {
             $error_message .= PHP_EOL . 'Command: ' . $data['cmd'] . PHP_EOL;
             if (!empty($data['stdout'])) {
                 $error_message .= 'STDOUT: ' . PHP_EOL . $data['stdout'];
             }
             if (!empty($data['stderr'])) {
                 $error_message .= 'STDERR: ' . PHP_EOL . $data['stderr'];
             }
             if (empty($data['stdout']) && empty($data['stderr'])) {
                 $error_message .= PHP_EOL;
             }
         }
         $error_message .= PHP_EOL . PHP_EOL;
     }
     return $this->cliError($error_message);
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-vendor,代码行数:33,代码来源:WatchScssErrorView.class.php

示例12: executeWrite

 public function executeWrite(AgaviRequestDataHolder $request_data)
 {
     $size = $request_data->getParameter('size', 1);
     $aggregate_root_type = $request_data->getParameter('type');
     $fixture_service = $this->getServiceLocator()->getFixtureService();
     $type_prefix = $aggregate_root_type->getPrefix();
     $documents[$type_prefix] = $fixture_service->generate($type_prefix, $size);
     $json = json_encode($documents, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     $errors = [];
     $report = [];
     $success = true;
     if ($request_data->hasParameter('target')) {
         $target = $request_data->getParameter('target');
         if (is_writable(dirname($target))) {
             $success = file_put_contents($target, $json, LOCK_EX) !== false;
             if (!$success) {
                 $errors[] = sprintf('failed to write to: %s', $target);
             }
         } else {
             $errors[] = sprintf('target filename is not writable: %s', $target);
             $success = false;
         }
     } else {
         $this->setAttribute('data', $json);
     }
     $this->setAttribute('report', $report);
     $this->setAttribute('size', count($documents[$type_prefix]));
     if (!$success) {
         $this->setAttribute('errors', $errors);
         return 'Error';
     }
     return 'Success';
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-vendor,代码行数:33,代码来源:GenerateAction.class.php

示例13: executeRead

 public function executeRead(AgaviRequestDataHolder $rd)
 {
     // the validator already pulled the product object from the database and put it into the request data
     // so there's not much we need to do here
     $this->setAttribute('product', $rd->getParameter('product'));
     return 'Success';
 }
开发者ID:horros,项目名称:agavi,代码行数:7,代码来源:ViewAction.class.php

示例14: executeWrite

 public function executeWrite(AgaviRequestDataHolder $rd)
 {
     if (!$this->context->getUser()->isAuthenticated() || !$this->context->getUser()->hasCredential('icinga.user')) {
         return array('Api', 'GenericError');
     }
     if ($this->context->getUser()->getNsmUser()->getTarget('IcingaCommandRo')) {
         $errors = array('Commands are disabled for this user');
         $this->getContainer()->setAttributeByRef('errors', $errors, 'org.icinga.api.auth');
         $this->getContainer()->setAttribute('success', false, 'org.icinga.api.auth');
         return array('Api', 'GenericError');
     }
     $command = $rd->getParameter("command");
     $targets = json_decode($rd->getParameter("target"), true);
     $data = json_decode($rd->getParameter("data"), true);
     if (!is_array($data)) {
         $this->setAttribute('error', 'Parameter data={} could not decoded from json');
         return 'Error';
     }
     if (!is_array($targets)) {
         $targets = array($targets);
     }
     $api = $this->getContext()->getModel("System.CommandSender", "Cronks");
     $api->setCommandName($command);
     $api->setData($data);
     $api->setSelection($targets);
     // send it
     try {
         $api->dispatchCommands();
         $this->setAttribute("success", true);
     } catch (Exception $e) {
         $this->setAttribute("error", $e->getMessage());
         return 'Error';
     }
     return 'Success';
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:35,代码来源:ApiCommandAction.class.php

示例15: executeConsole

 public function executeConsole(\AgaviRequestDataHolder $request_data)
 {
     $report = $this->getAttribute('report');
     if ($request_data->getParameter('silent', false)) {
         return;
     }
     $message = 'The following items were compiled:' . PHP_EOL . PHP_EOL;
     foreach ($report as $directory => $data) {
         $message .= '- ' . $data['name'] . PHP_EOL;
         if ($request_data->getParameter('verbose', false)) {
             $message .= 'Command: ' . $data['cmd'] . PHP_EOL;
             if (!empty($data['stdout'])) {
                 $message .= 'STDOUT: ' . PHP_EOL . $data['stdout'] . PHP_EOL;
             }
             if (!empty($data['stderr'])) {
                 $message .= 'STDERR: ' . PHP_EOL . $data['stderr'] . PHP_EOL;
             }
             if (empty($data['stdout']) && empty($data['stderr'])) {
                 $message .= PHP_EOL;
             }
             if (!empty($data['autoprefixer']['stdout'])) {
                 $message .= 'Autoprefixer STDOUT: ' . PHP_EOL . $data['autoprefixer']['stdout'];
             }
             if (!empty($data['autoprefixer']['stderr'])) {
                 $message .= 'Autoprefixer STDERR: ' . PHP_EOL . $data['autoprefixer']['stderr'];
             }
             if (empty($data['autoprefixer']['autoprefixer']['stdout']) && empty($data['autoprefixer']['stderr'])) {
                 $message .= PHP_EOL;
             }
         }
     }
     return $message . PHP_EOL;
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-vendor,代码行数:33,代码来源:CompileScssSuccessView.class.php


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