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


PHP Library\Application類代碼示例

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


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

示例1: EndLog

 public static function EndLog(\Library\Application $app, $type)
 {
     $logs = Logger::GetLogs($app->user());
     $log = $logs[$type][$app->HttpRequest()->requestID()];
     $log->setLog_end(Logger::GetTime());
     $log->setLog_execution_time(($log->log_end - $log->log_start()) * 1000);
     $log->setLog_start(gmdate("Y-m-d H:i:s", $log->log_start()));
     $log->setLog_end(gmdate("Y-m-d H:i:s", $log->log_end()));
     Logger::AddLogToDatabase($app, $log);
     Logger::StoreLogs($app->user(), $logs);
 }
開發者ID:tymiles003,項目名稱:FieldWorkManager,代碼行數:11,代碼來源:TimeLogger.php

示例2: testNoTranslatorForEnglishLocale

 public function testNoTranslatorForEnglishLocale()
 {
     // Preserve state
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     }
     // Repeat application initialization with english locale
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en_UK';
     \Library\Application::init('Library', false);
     // Invoke translator with untranslatable string - must not trigger notice
     $translator = \Library\Application::getService('MvcTranslator')->getTranslator();
     $message = $translator->translate('this_string_is_not_translated');
     // Reset application state ASAP.
     if (isset($language)) {
         $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $language;
     } else {
         unset($_SERVER['HTTP_ACCEPT_LANGUAGE']);
     }
     \Library\Application::init('Library', false);
     $this->assertEquals('this_string_is_not_translated', $message);
     // No translations should be loaded
     $reflectionObject = new \ReflectionObject($translator);
     $reflectionProperty = $reflectionObject->getProperty('files');
     $reflectionProperty->setAccessible(true);
     $this->assertSame(array(), $reflectionProperty->getValue($translator));
 }
開發者ID:patrickpreuss,項目名稱:Braintacle,代碼行數:26,代碼來源:TranslatorTest.php

示例3: testRouter

 /**
  * Test route matches against various URIs
  */
 public function testRouter()
 {
     $application = \Library\Application::init('Console', true);
     $router = $application->getServiceManager()->get('HttpRouter');
     $request = new \Zend\Http\Request();
     $matchDefaultDefault = array('controller' => 'client', 'action' => 'index');
     $matchControllerDefault = array('controller' => 'controllername', 'action' => 'index');
     $matchControllerAction = array('controller' => 'controllername', 'action' => 'actionname');
     $request->setUri('/');
     $this->assertEquals($matchDefaultDefault, $router->match($request)->getParams());
     $request->setUri('/controllername');
     $this->assertEquals($matchControllerDefault, $router->match($request)->getParams());
     $request->setUri('/controllername/');
     $this->assertEquals($matchControllerDefault, $router->match($request)->getParams());
     $request->setUri('/controllername/actionname');
     $this->assertEquals($matchControllerAction, $router->match($request)->getParams());
     $request->setUri('/controllername/actionname/');
     $this->assertEquals($matchControllerAction, $router->match($request)->getParams());
     $request->setUri('/controllername/actionname/invalid');
     $this->assertNull($router->match($request));
     $request->setUri('/console');
     $this->assertEquals($matchDefaultDefault, $router->match($request)->getParams());
     $request->setUri('/console/');
     $this->assertEquals($matchDefaultDefault, $router->match($request)->getParams());
     $request->setUri('/console/controllername');
     $this->assertEquals($matchControllerDefault, $router->match($request)->getParams());
     $request->setUri('/console/controllername/');
     $this->assertEquals($matchControllerDefault, $router->match($request)->getParams());
     $request->setUri('/console/controllername/actionname');
     $this->assertEquals($matchControllerAction, $router->match($request)->getParams());
     $request->setUri('/console/controllername/actionname/');
     $this->assertEquals($matchControllerAction, $router->match($request)->getParams());
     $request->setUri('/console/controllername/actionname/invalid');
     $this->assertNull($router->match($request));
 }
開發者ID:hschletz,項目名稱:braintacle,代碼行數:38,代碼來源:RouterTest.php

示例4: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     // This table must exist before the view can be created
     \Library\Application::getService('Database\\Table\\ClientsAndGroups')->setSchema();
     \Library\Application::getService('Database\\Table\\WindowsProductKeys')->setSchema();
     parent::setUpBeforeClass();
 }
開發者ID:patrickpreuss,項目名稱:Braintacle,代碼行數:7,代碼來源:WindowsInstallationsTest.php

示例5: testMessageTranslated

 public function testMessageTranslated()
 {
     $validator = new LogLevel();
     $validator->setTranslator(\Library\Application::init('Library', true)->getServiceManager()->get('MvcTranslator'));
     $validator->isValid('Error');
     $this->assertEquals(array(LogLevel::LOG_LEVEL => "'Error' ist kein gültiger Loglevel"), $validator->getMessages());
 }
開發者ID:hschletz,項目名稱:braintacle,代碼行數:7,代碼來源:LogLevelTest.php

示例6: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     // GroupInfo initialization depends on Config table
     $config = \Library\Application::getService('Database\\Table\\Config');
     $config->setSchema();
     parent::setUpBeforeClass();
 }
開發者ID:patrickpreuss,項目名稱:Braintacle,代碼行數:7,代碼來源:GroupInfoTest.php

示例7: _createView

 /**
  * Create a new view renderer
  *
  * @return \Zend\View\Renderer\PhpRenderer
  */
 protected function _createView()
 {
     $application = \Library\Application::init('Console', true);
     $view = new \Zend\View\Renderer\PhpRenderer();
     $view->setHelperPluginManager($application->getServiceManager()->get('ViewHelperManager'));
     return $view;
 }
開發者ID:hschletz,項目名稱:braintacle,代碼行數:12,代碼來源:AbstractFormTest.php

示例8: testHelperInterface

 /**
  * Test if the helper is properly registered with the service manager
  */
 public function testHelperInterface()
 {
     // Test if the helper is registered with the application's service manager
     $this->assertTrue(\Library\Application::getService('ViewHelperManager')->has($this->_getHelperName()));
     // Get helper instance through service manager and test for required interface
     $this->assertInstanceOf('Zend\\View\\Helper\\HelperInterface', $this->_getHelper());
 }
開發者ID:patrickpreuss,項目名稱:Braintacle,代碼行數:10,代碼來源:AbstractTest.php

示例9: testFind

 /**
  * @dataProvider findProvider
  */
 public function testFind($criteria, $order, $direction, $clearBlacklist, $expectedOrder, $expectedResult)
 {
     if ($clearBlacklist) {
         \Library\Application::getService('Database\\Table\\DuplicateMacAddresses')->delete(true);
         \Library\Application::getService('Database\\Table\\DuplicateSerials')->delete(true);
         \Library\Application::getService('Database\\Table\\DuplicateAssetTags')->delete(true);
     }
     $ordercolumns = array('Id' => 'clients.id', 'Name' => 'clients.name', 'NetworkInterface.MacAddress' => 'networkinterface_macaddr');
     $sql = new \Zend\Db\Sql\Sql(\Library\Application::getService('Db'), 'clients');
     $select = $sql->select()->columns(array('id', 'name', 'lastcome', 'ssn', 'assettag'))->order(array($ordercolumns[$order] => $direction));
     $clientManager = $this->getMockBuilder('Model\\Client\\ClientManager')->disableOriginalConstructor()->getMock();
     $clientManager->method('getClients')->with(array('Id', 'Name', 'LastContactDate', 'Serial', 'AssetTag'), $order, $direction, null, null, null, null, false, false, false)->willReturn($select);
     $clients = $this->getMockBuilder('Database\\Table\\Clients')->disableOriginalConstructor()->setMethods(array('getSql', 'selectWith'))->getMock();
     $clients->method('getSql')->willReturn($sql);
     $clients->method('selectWith')->with($this->callback(function ($select) use($expectedOrder) {
         return $select->getRawState($select::ORDER) == $expectedOrder;
     }))->willReturnCallback(function ($select) use($sql) {
         // Build simple result set to bypass hydrator
         $resultSet = new \Zend\Db\ResultSet\ResultSet();
         $resultSet->initialize($sql->prepareStatementForSqlObject($select)->execute());
         return $resultSet;
     });
     $duplicates = $this->_getModel(array('Database\\Table\\Clients' => $clients, 'Model\\Client\\ClientManager' => $clientManager));
     $resultSet = $duplicates->find($criteria, $order, $direction);
     $this->assertInstanceOf('Zend\\Db\\ResultSet\\AbstractResultSet', $resultSet);
     $this->assertEquals($expectedResult, $resultSet->toArray());
 }
開發者ID:patrickpreuss,項目名稱:Braintacle,代碼行數:30,代碼來源:DuplicatesManagerTest.php

示例10: setPackageData

 /**
  * Set attributes from given package
  *
  * Attributes are populated with values from the given package and
  * hardcoded defaults.
  *
  * @param array $data Package data
  */
 public function setPackageData($data)
 {
     $node = $this->createElement('DOWNLOAD');
     $node->setAttribute('ID', $data['Id']);
     $node->setAttribute('PRI', $data['Priority']);
     $node->setAttribute('ACT', strtoupper($data['DeployAction']));
     $node->setAttribute('DIGEST', $data['Hash']);
     $node->setAttribute('PROTO', 'HTTP');
     $node->setAttribute('FRAGS', $data['NumFragments']);
     $node->setAttribute('DIGEST_ALGO', 'SHA1');
     $node->setAttribute('DIGEST_ENCODE', 'Hexa');
     $node->setAttribute('PATH', $data['DeployAction'] == 'store' ? $data['ActionParam'] : '');
     $node->setAttribute('NAME', $data['DeployAction'] == 'launch' ? $data['ActionParam'] : '');
     $node->setAttribute('COMMAND', $data['DeployAction'] == 'execute' ? $data['ActionParam'] : '');
     $node->setAttribute('NOTIFY_USER', $data['Warn'] ? '1' : '0');
     $node->setAttribute('NOTIFY_TEXT', $this->_escapeMessage($data['WarnMessage']));
     $node->setAttribute('NOTIFY_COUNTDOWN', $data['WarnCountdown']);
     $node->setAttribute('NOTIFY_CAN_ABORT', $data['WarnAllowAbort'] ? '1' : '0');
     $node->setAttribute('NOTIFY_CAN_DELAY', $data['WarnAllowDelay'] ? '1' : '0');
     $node->setAttribute('NEED_DONE_ACTION', $data['PostInstMessage'] ? '1' : '0');
     $node->setAttribute('NEED_DONE_ACTION_TEXT', $this->_escapeMessage($data['PostInstMessage']));
     $node->setAttribute('GARDEFOU', 'rien');
     if ($this->hasChildNodes()) {
         $this->replaceChild($node, $this->firstChild);
     } else {
         $this->appendChild($node);
     }
     if (!\Library\Application::isProduction()) {
         $this->forceValid();
     }
 }
開發者ID:patrickpreuss,項目名稱:Braintacle,代碼行數:39,代碼來源:Metadata.php

示例11: testMissingTranslationDoesNotTriggerNoticeWhenDisabled

 /**
  * @dataProvider missingTranslationProvider
  */
 public function testMissingTranslationDoesNotTriggerNoticeWhenDisabled($locale)
 {
     \Locale::setDefault($locale);
     $application = \Library\Application::init('Library', true, array('Library\\UserConfig' => array('debug' => array('report missing translations' => false))));
     $translator = $application->getServiceManager()->get('MvcTranslator');
     $this->assertEquals('this_string_is_not_translated', $translator->translate('this_string_is_not_translated'));
 }
開發者ID:hschletz,項目名稱:braintacle,代碼行數:10,代碼來源:TranslatorTest.php

示例12: testMessageTranslated

 public function testMessageTranslated()
 {
     $validator = new ProductKey();
     $validator->setTranslator(\Library\Application::init('Library', true)->getServiceManager()->get('MvcTranslator'));
     $validator->isValid('invalid');
     $this->assertEquals(array(ProductKey::PRODUCT_KEY => "'invalid' ist kein gültiger Lizenzschlüssel"), $validator->getMessages());
 }
開發者ID:hschletz,項目名稱:braintacle,代碼行數:7,代碼來源:ProductKeyTest.php

示例13: getConnection

 public function getConnection()
 {
     if (!$this->_db) {
         $pdo = \Library\Application::getService('Db')->getDriver()->getConnection()->getResource();
         $this->_db = $this->createDefaultDBConnection($pdo, ':memory:');
     }
     return $this->_db;
 }
開發者ID:patrickpreuss,項目名稱:Braintacle,代碼行數:8,代碼來源:AbstractTableTest.php

示例14: _createView

 /**
  * Create a new view renderer
  *
  * @return \Zend\View\Renderer\PhpRenderer
  */
 protected function _createView()
 {
     // Clone helper plugin manager to prevent state changes leaking into other tests
     $plugins = clone \Library\Application::getService('ViewHelperManager');
     $view = new \Zend\View\Renderer\PhpRenderer();
     $view->setHelperPluginManager($plugins);
     return $view;
 }
開發者ID:patrickpreuss,項目名稱:Braintacle,代碼行數:13,代碼來源:AbstractFormTest.php

示例15: testLoggerService

 /**
  * Test service
  */
 public function testLoggerService()
 {
     $logger = \Library\Application::getService('Library\\Logger');
     $this->assertInstanceOf('\\Zend\\Log\\Logger', $logger);
     // Log a message. The NULL writer should be attached so that no
     // exception should be thrown.
     $logger->debug('test');
 }
開發者ID:patrickpreuss,項目名稱:Braintacle,代碼行數:11,代碼來源:LoggerServiceFactoryTest.php


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