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


PHP xPDO::setDebug方法代码示例

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


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

示例1: array

 /**
  * Create or grab a reference to a static xPDO/modX instance.
  *
  * The instances can be reused by multiple tests and test suites.
  *
  * @param string $class A fixture class to get an instance of.
  * @param string $name A unique identifier for the fixture.
  * @param boolean $new
  * @param array $options An array of configuration options for the fixture.
  * @return object|null An instance of the specified fixture class or null on failure.
  */
 public static function &getFixture($class, $name, $new = false, array $options = array())
 {
     if (!$new && array_key_exists($name, self::$fixtures) && self::$fixtures[$name] instanceof $class) {
         $fixture =& self::$fixtures[$name];
     } else {
         $properties = array();
         include_once dirname(dirname(dirname(__FILE__))) . '/core/model/modx/modx.class.php';
         include dirname(__FILE__) . '/properties.inc.php';
         self::$properties = $properties;
         if (array_key_exists('debug', self::$properties)) {
             self::$debug = (bool) self::$properties['debug'];
         }
         $fixture = null;
         $driver = self::$properties['xpdo_driver'];
         switch ($class) {
             case 'modX':
                 if (!defined('MODX_REQP')) {
                     define('MODX_REQP', false);
                 }
                 if (!defined('MODX_CONFIG_KEY')) {
                     define('MODX_CONFIG_KEY', array_key_exists('config_key', self::$properties) ? self::$properties['config_key'] : 'test');
                 }
                 $fixture = new modX(null, self::$properties["{$driver}_array_options"]);
                 if ($fixture instanceof modX) {
                     $logLevel = array_key_exists('logLevel', self::$properties) ? self::$properties['logLevel'] : modX::LOG_LEVEL_WARN;
                     $logTarget = array_key_exists('logTarget', self::$properties) ? self::$properties['logTarget'] : (XPDO_CLI_MODE ? 'ECHO' : 'HTML');
                     $fixture->setLogLevel($logLevel);
                     $fixture->setLogTarget($logTarget);
                     if (!empty(self::$debug)) {
                         $fixture->setDebug(self::$properties['debug']);
                     }
                     $fixture->initialize(self::$properties['context']);
                     $fixture->user = $fixture->newObject('modUser');
                     $fixture->user->set('id', $fixture->getOption('modx.test.user.id', null, 1));
                     $fixture->user->set('username', $fixture->getOption('modx.test.user.username', null, 'test'));
                     $fixture->getRequest();
                     $fixture->getParser();
                     $fixture->request->loadErrorHandler();
                 }
                 break;
             case 'xPDO':
                 $fixture = new xPDO(self::$properties["{$driver}_string_dsn_test"], self::$properties["{$driver}_string_username"], self::$properties["{$driver}_string_password"], self::$properties["{$driver}_array_options"], self::$properties["{$driver}_array_driverOptions"]);
                 if ($fixture instanceof xPDO) {
                     $logLevel = array_key_exists('logLevel', self::$properties) ? self::$properties['logLevel'] : xPDO::LOG_LEVEL_WARN;
                     $logTarget = array_key_exists('logTarget', self::$properties) ? self::$properties['logTarget'] : (XPDO_CLI_MODE ? 'ECHO' : 'HTML');
                     $fixture->setLogLevel($logLevel);
                     $fixture->setLogTarget($logTarget);
                     if (!empty(self::$debug)) {
                         $fixture->setDebug(self::$properties['debug']);
                     }
                 }
                 break;
             default:
                 $fixture = new $class($options);
                 break;
         }
         if ($fixture !== null && $fixture instanceof $class) {
             self::$fixtures[$name] = $fixture;
         } else {
             die("Error setting fixture {$name} of expected class {$class}.");
         }
     }
     return $fixture;
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:75,代码来源:MODxTestHarness.php

示例2: microtime

<?php

$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tstart = $mtime;
$properties = array();
include_once dirname(dirname(dirname(__FILE__))) . '/xpdo/xpdo.class.php';
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/config.core.php';
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/_build/build.properties.php';
foreach (array('mysql', 'sqlsrv') as $driver) {
    $xpdo = new xPDO($properties["{$driver}_string_dsn_nodb"], $properties["{$driver}_string_username"], $properties["{$driver}_string_password"], $properties["{$driver}_array_options"], $properties["{$driver}_array_driverOptions"]);
    $xpdo->setPackage('modx', dirname(XPDO_CORE_PATH) . '/model/');
    $xpdo->setDebug(true);
    $manager = $xpdo->getManager();
    $generator = $manager->getGenerator();
    $generator->classTemplate = <<<EOD
<?php
/**
 * [+phpdoc-package+]
 * [+phpdoc-subpackage+]
 */
/**
 * [+phpdoc-package+]
 * [+phpdoc-subpackage+]
 */
class [+class+] extends [+extends+] {
}
EOD;
    $generator->platformTemplate = <<<EOD
<?php
开发者ID:adamwintle,项目名称:flexibility5,代码行数:31,代码来源:build.modx.php

示例3: xPDO

            <p>Adjust the permissions and try again.</p>', $d));
        exit;
    }
}
if ($verbose) {
    print_msg(sprintf('<br/><strong>Ok:</strong> The necessary directories exist and have the correct permissions inside of <br/>
        <code>%s</code>', $package_dir));
}
// Delete/regenerate map files?
if (file_exists($xml_schema_file) && !$regenerate_schema && $verbose) {
    print_msg(sprintf('<br/><strong>Ok:</strong> Using existing XML schema file:<br/><code>%s</code>', $xml_schema_file));
}
$xpdo = new xPDO("mysql:host={$database_server};dbname={$dbase}", $database_user, $database_password, $table_prefix);
// Set the package name and root path of that package
$xpdo->setPackage($package_name, $package_dir, $package_dir);
$xpdo->setDebug($debug);
$manager = $xpdo->getManager();
$generator = $manager->getGenerator();
//Use this to create an XML schema from an existing database
if ($regenerate_schema) {
    $xml = $generator->writeSchema($xml_schema_file, $package_name, 'xPDOObject', $table_prefix, $restrict_prefix);
    if ($verbose) {
        print_msg(sprintf('<br/><strong>Ok:</strong> XML schema file generated: <code>%s</code>', $xml_schema_file));
    }
}
// Use this to generate classes and maps from your schema
if ($regenerate_classes) {
    print_msg('<br/>Attempting to remove/regenerate class files...');
    delete_class_files($class_dir);
    delete_class_files($mysql_class_dir);
}
开发者ID:idcooldi,项目名称:modx_utils,代码行数:31,代码来源:write_schema.php

示例4: setDebug

 /**
  * Sets the debugging features of the modX instance.
  *
  * @param boolean|int $debug Boolean or bitwise integer describing the
  * debug state and/or PHP error reporting level.
  * @param boolean $stopOnNotice Indicates if processing should stop when
  * encountering PHP errors of type E_NOTICE.
  * @return boolean|int The previous value.
  */
 public function setDebug($debug = true, $stopOnNotice = false)
 {
     $oldValue = $this->getDebug();
     if ($debug === true) {
         error_reporting(-1);
         parent::setDebug(true);
     } elseif ($debug === false) {
         error_reporting(0);
         parent::setDebug(false);
     } else {
         error_reporting(intval($debug));
         parent::setDebug(intval($debug));
     }
     $this->stopOnNotice = $stopOnNotice;
     return $oldValue;
 }
开发者ID:JoeBlow,项目名称:revolution,代码行数:25,代码来源:modx.class.php


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