本文整理汇总了PHP中Library\Application::isDevelopment方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::isDevelopment方法的具体用法?PHP Application::isDevelopment怎么用?PHP Application::isDevelopment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Library\Application
的用法示例。
在下文中一共展示了Application::isDevelopment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testEnvironment
/**
* Tests for environment detection methods
*
* The tests cover getEnvironment(), isProduction(), isDevelopment() and
* isTest() with all relevant values for the APPLICATION_ENV environment
* variable.
*/
public function testEnvironment()
{
// Assume that the tests have been invoked with APPLICATION_ENV set to
// "test". Otherwise the tests might be incomplete.
$this->assertEquals('test', getenv('APPLICATION_ENV'));
$this->assertEquals('test', Application::getEnvironment());
$this->assertFalse(Application::isProduction());
$this->assertTrue(Application::isDevelopment());
$this->assertTrue(Application::isTest());
// Unset APPLICATION_ENV, equivalent to "production"
putenv('APPLICATION_ENV');
$this->assertEquals('production', Application::getEnvironment());
$this->assertTrue(Application::isProduction());
$this->assertFalse(Application::isDevelopment());
$this->assertFalse(Application::isTest());
// Test "development" environment
putenv('APPLICATION_ENV=development');
$this->assertEquals('development', Application::getEnvironment());
$this->assertFalse(Application::isProduction());
$this->assertTrue(Application::isDevelopment());
$this->assertFalse(Application::isTest());
// Test invalid environment. Ensure that the variable is reset to its
// default in either case.
putenv('APPLICATION_ENV=invalid');
try {
Application::getEnvironment();
} catch (\DomainException $expected) {
$invalidEnvironmmentDetected = true;
}
// Reset to default.
putenv('APPLICATION_ENV=test');
if (!isset($invalidEnvironmmentDetected)) {
$this->fail('Invalid environment was undetected.');
}
}
示例2: onBootstrap
/**
* @internal
*/
public function onBootstrap(\Zend\EventManager\EventInterface $e)
{
\Zend\Filter\StaticFilter::getPluginManager()->setInvokableClass('Library\\FixEncodingErrors', 'Library\\Filter\\FixEncodingErrors');
$serviceManager = $e->getApplication()->getServiceManager();
// Register form element view helpers
$formElementHelper = $serviceManager->get('ViewHelperManager')->get('formElement');
$formElementHelper->addClass('Library\\Form\\Element\\SelectSimple', 'formselectsimple');
$formElementHelper->addType('select_untranslated', 'formselectuntranslated');
if (\Locale::getPrimaryLanguage(\Locale::getDefault()) != 'en') {
$mvcTranslator = $serviceManager->get('MvcTranslator');
if (Application::isDevelopment()) {
$translator = $mvcTranslator->getTranslator();
$translator->enableEventManager();
$translator->getEventManager()->attach(\Zend\I18n\Translator\Translator::EVENT_MISSING_TRANSLATION, array($this, 'onMissingTranslation'));
}
// Validators have no translator by default. Attach translator, but
// use a different text domain to avoid warnings if the Zend
// translations are not loaded. For custom messages, the text domain
// must be reset manually to 'default' for individual validators.
\Zend\Validator\AbstractValidator::setDefaultTranslator($mvcTranslator);
\Zend\Validator\AbstractValidator::setDefaultTranslatorTextDomain('Zend');
}
}
示例3: exportAction
/**
* Download client as XML file
*
* @return \Zend\Http\Response Response with downloadable XML content
*/
public function exportAction()
{
$document = $this->_currentClient->toDomDocument();
if (\Library\Application::isDevelopment()) {
$document->forceValid();
}
$filename = $document->getFilename();
$xml = $document->saveXml();
$response = $this->getResponse();
$response->getHeaders()->addHeaders(array('Content-Type' => 'text/xml; charset="utf-8"', 'Content-Disposition' => "attachment; filename=\"{$filename}\"", 'Content-Length' => strlen($xml)));
$response->setContent($xml);
return $response;
}
示例4: loadVendorDatabase
/**
* Load vendor database
*
* Clears the database and iterates over $input. Each entry of the form
* "MAC_address[/bits] TAB short_name [whitespace # long_name]" gets parsed
* and added to the database.
*
* @param array|\Traversable $input
*/
public static function loadVendorDatabase($input)
{
self::$_vendorList = array();
foreach ($input as $line) {
/* This regular expression matches lines of the following pattern:
<MAC address><TAB><short name>[<whitespace># <long name>]
Matching lines leave $data as an array with exaxtly 5 elements:
[0] unused
[1] MAC address with optional mask suffix ("/36")
[2] short vendor name (used if [4] is empty)
[3] unused
[4] long vendor name or empty string
*/
if (!preg_match("/^(\\H+)\t(\\H+)\\h*(# )?(.*)/", $line, $data)) {
continue;
}
// remove ':' and '-' delimiters
$mac = str_replace(array(':', '-'), '', $data[1]);
// extract bitmask if present
$pos = strpos($mac, '/');
if ($pos !== false) {
$mask = substr($mac, $pos + 1);
if ($mask % 4 != 0) {
// The precision of this string-based implementation is
// limited to 4 bits (1 hex digit). Entries with a number
// of mask bits that is not a multiple of 4 cannot be
// matched and are ignored.
if (\Library\Application::isDevelopment()) {
trigger_error("Ignoring MAC address {$data['1']} because mask is not a multiple of 4.", E_USER_NOTICE);
}
continue;
}
$numDigits = $mask / 4;
$mac = substr($mac, 0, $pos);
$mac = str_pad($mac, $numDigits, '0');
// Fill with zeroes if too short
$mac = substr($mac, 0, $numDigits);
// Crop to maximun length if too long
} else {
$numDigits = strlen($mac);
}
self::$_vendorList[] = array('address' => strtoupper($mac), 'length' => $numDigits, 'vendor' => $data[4] ?: $data[2]);
}
}
示例5: while
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
// Absence of the controller variable hints an invalid route which requires
// special treatment.
if (!isset($this->controller)) {
$this->layout()->noRoute = true;
print "<p class='textcenter'><strong>Error:</strong> No route matched.</p>\n";
return;
}
print "<h1>An error occurred</h1>\n";
print $this->htmlTag('h2', $this->message);
// @codeCoverageIgnoreStart
if (\Library\Application::isDevelopment() and isset($this->exception)) {
print "<h3>Exception Message trace:</h3>\n";
$exception = $this->exception;
while ($exception) {
print $this->htmlTag('p', '<strong>Message:</strong> ' . $this->escapeHtml($exception->getMessage()));
print $this->htmlTag('p', sprintf('<strong>Source:</strong> %s, line %d', $this->escapeHtml($exception->getFile()), $this->escapeHtml($exception->getLine())));
print "<h4>Stack trace:</h4>\n";
print $this->htmlTag('pre', $this->escapeHtml($exception->getTraceAsString()));
$exception = $exception->getPrevious();
}
// The additional debug information below might contain sensitive data.
if ($this->controller == 'login') {
print 'Details hidden for security reasons.';
return;
}
$request = $this->request;