本文整理汇总了PHP中Library\Application类的典型用法代码示例。如果您正苦于以下问题:PHP Application类的具体用法?PHP Application怎么用?PHP Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$helperClass = static::_getHelperClass();
$moduleName = substr($helperClass, 0, strpos($helperClass, '\\'));
$application = \Library\Application::init($moduleName, true);
static::$_serviceManager = $application->getServiceManager();
static::$_helperManager = static::$_serviceManager->get('ViewHelperManager');
}
开发者ID:hschletz,项目名称:braintacle,代码行数:9,代码来源:AbstractTest.php
示例17: setUp
public function setUp()
{
$this->_authService = $this->createMock('Model\\Operator\\AuthenticationService');
$application = \Library\Application::init('Console', true);
$serviceManager = $application->getServiceManager();
$serviceManager->setService('Zend\\Authentication\\AuthenticationService', $this->_authService);
$this->_view = new \Zend\View\Renderer\PhpRenderer();
$this->_view->setHelperPluginManager($serviceManager->get('ViewHelperManager'));
$this->_view->setResolver(new \Zend\View\Resolver\TemplateMapResolver(array('layout' => \Console\Module::getPath('views/layout/layout.php'))));
}
开发者ID:hschletz,项目名称:braintacle,代码行数:10,代码来源:LayoutTest.php
示例18: testService
public function testService()
{
$serviceManager = \Library\Application::getService('serviceManager');
// Service must not be shared so that a different result is returned
// each time.
$now1 = $serviceManager->get('Library\\Now');
sleep(1);
$now2 = $serviceManager->get('Library\\Now');
$this->assertGreaterThan($now1->getTimestamp(), $now2->getTimestamp());
}
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:10,代码来源:NowTest.php
示例19: __invoke
/**
* @internal
*/
public function __invoke(\Interop\Container\ContainerInterface $container, $requestedName, array $options = null)
{
$applicationConfig = $container->get('ApplicationConfig');
if (isset($applicationConfig['Library\\UserConfig'])) {
return $applicationConfig['Library\\UserConfig'];
} else {
$reader = new \Zend\Config\Reader\Ini();
return $reader->fromFile(getenv('BRAINTACLE_CONFIG') ?: \Library\Application::getPath('user_config/braintacle.ini'));
}
}
开发者ID:hschletz,项目名称:braintacle,代码行数:13,代码来源:UserConfigFactory.php
示例20: setUp
/**
* Set up application config
*/
public function setUp()
{
parent::setUp();
$this->setTraceError(true);
$this->setApplicationConfig(\Library\Application::getApplicationConfig('Console', true));
// Put application in authenticated state
$auth = $this->createMock('Model\\Operator\\AuthenticationService');
$auth->expects($this->atLeastOnce())->method('hasIdentity')->willReturn(true);
$serviceManager = $this->getApplicationServiceLocator();
$serviceManager->setService('Model\\Operator\\AuthenticationService', $auth);
}
开发者ID:hschletz,项目名称:braintacle,代码行数:14,代码来源:AbstractControllerTest.php
注:本文中的Library\Application类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论