本文整理汇总了PHP中throwError函数的典型用法代码示例。如果您正苦于以下问题:PHP throwError函数的具体用法?PHP throwError怎么用?PHP throwError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了throwError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ofType
function ofType($type, $val)
{
if ($val instanceof $type) {
return $val;
}
throwError("Not of type '{$type}'");
}
示例2: addDataRow
public function addDataRow($values, $name = false)
{
/**
* Adds a data row to the existing graph
*
* @param $values: An array of values
* @param $name (optional): The name of the data row
*
* @return: TRUE if adding the data row suceeded, FALSE if not
*/
if (!is_array($values)) {
throwError('First argument should be an array', __METHOD__);
return false;
}
if ($name !== false) {
$name = (string) $name;
} else {
$name = 'Data row ' . ($this->nrOfDataRows + 1);
}
$this->dataRow[] = $values;
$this->dataRowNames[] = $name;
$this->nrOfDataRows++;
$max = max($values);
$min = min($values);
$this->calculateGraduation($min, $max);
$this->averages[] = false;
$this->averagesNames[] = false;
$this->movingAverages[] = false;
$this->movingAveragesNames[] = false;
$this->hyperlinks[] = false;
// re-calculate rect width
$this->calculateRectSpecs();
return true;
}
示例3: makeZip
/**
*
* make zip archive
* if exists additional paths, add additional items to the zip
*/
public function makeZip($srcPath, $zipFilepath, $additionPaths = array())
{
if (!is_dir($srcPath)) {
throwError("The path: '{$srcPath}' don't exists, can't zip");
}
$this->zip = new ZipArchive();
$success = $this->zip->open($zipFilepath, ZipArchive::CREATE);
if ($success == false) {
throwError("Can't create zip file: {$zipFilepath}");
}
$this->addItem($srcPath, $srcPath);
if (gettype($additionPaths) != "array") {
throwError("Wrong additional paths variable.");
}
//add additional paths
if (!empty($additionPaths)) {
foreach ($additionPaths as $path) {
if (!is_dir($path)) {
throwError("Path: {$path} not found, can't zip");
}
$this->addItem($path, $path);
}
}
$this->zip->close();
}
示例4: addStep
/**
* Adds a new {@link WizardStep} to this wizard.
* @param string $name A short id/name for this step.
* @param ref object $step
* @access public
* @return ref object
*/
function addStep($name, $step)
{
if (count($this->getSteps())) {
throwError(new Error("SingleStepWizards can only have one step. Cannot add '" . $name . "' step.", "Wizard"));
}
return parent::addStep($name, $step);
}
示例5: isArrayAndReturnValue
function isArrayAndReturnValue($val, $index)
{
if (isArray($val) && array_key_exists($index, $val)) {
return $val[$index];
}
throwError("The array doesn't has {$index}");
}
示例6: output
/**
* Outputs the content of the current template with $variables containing
* the variable output.
* @param optional mixed $variables,... Either an associative array or a {@link FieldSet} containing
* a number of [key]=>content pairs.
* @access public
* @return void
**/
function output()
{
// go through each argument, check if its good and set all the variables.
for ($i = 0; $i < func_num_args(); $i++) {
$__v = func_get_arg($i);
if (is_array($__v)) {
// ok, register them all as local variables
foreach (array_keys($__v) as $__k) {
${$__k} = $__v[$__k];
}
} else {
if ($__v instanceof FieldSet) {
$__keys = $__v->getKeys();
foreach ($__keys as $__k) {
${$__k} = $__v->get($__k);
}
} else {
throwError(new Error("Template::output() - could not output: variables passed to method do not seem to be an associative array or a FieldSet."));
return false;
}
}
}
// for
// otherwise, let's continue and output the file.
include $this->_fullPath;
}
示例7: getTargetId
/**
* Answers the target Id for all NavBlocks in the menu
*
* @return string the target id
* @access public
* @since 4/12/06
*/
function getTargetId()
{
if ($this->_element->hasAttribute('target_id')) {
return $this->_element->getAttribute('target_id');
}
throwError(new Error("No target_id available " . $this->_element->toString(true), "XmlSiteComponents"));
}
示例8: HarmoniTimespan
/**
* The constructor.
*
* @param long $_start the start of the time span
* @param long $_end the end of the time span
*
* @access public
* @return void
*/
function HarmoniTimespan($start, $end)
{
if ($start > $end) {
throwError(new Error("The end of a Timespan cannot come before the end", "HarmoniTimespan", true));
}
$this->_start = $start;
$this->_end = $end;
}
示例9: executeAction
/**
* Executes the specified action in the specified module, using the Harmoni object as a base.
* @param string $module The module in which to execute.
* @param string $action The specific action to execute.
* @access public
* @return ref mixed A {@link Layout} or TRUE/FALSE
*/
function executeAction($module, $action)
{
$fullPath = $this->_mkFullPath($module, $action);
if (!$this->actionExists($module, $action)) {
throwError(new Error("FlatFileActionSource::executeAction({$module}, {$action}) - could not proceed because the file to include does not exist!", "ActionHandler", true));
}
$result = (include $fullPath);
return $result;
}
示例10: suffixForPower
/**
* Answer the string suffix for the desired muliple of 2^10 bytes
* i.e. 0 -> B, 10 -> kB, 20 -> MB, 30 -> GB, etc.
*
* @param integer $power A multiple of 10; Range, 0-80
* @return string
* @access public
* @since 10/11/05
* @static
*/
static function suffixForPower($power)
{
$multiple = intval($power / 10);
if ($multiple < 0 || $multiple > 8) {
throwError(new Error("Invalid power, {$power}. Valid values are multiples of ten, 0-80.", "ByteSize", true));
}
$suffixes = array("B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
return $suffixes[$multiple];
}
示例11: TemplateFactory
function TemplateFactory($searchPath1)
{
if (!func_num_args()) {
throwError(new Error("TemplateFactory - you must specify at least one search path.", "TemplateFactory", true));
}
foreach (func_get_args() as $arg) {
$this->_paths[] = $arg;
}
}
示例12: __autoload
function __autoload($classname)
{
$clbase = strtolower($classname) . '.php';
$classfile = $_SERVER['DOCUMENT_ROOT'] . '/class/' . $clbase;
if (file_exists($classfile)) {
require $classfile;
} else {
throwError('missing class file');
}
}
示例13: createTokensObject
/**
* Create a Tokens Object
*
* @return object Tokens
* @access public
* @since 3/1/05
*/
function createTokensObject()
{
$tokensClass = $this->_configuration->getProperty('tokens_class');
$newTokens = new $tokensClass($this->_configuration);
$validatorRule = ExtendsValidatorRule::getRule('LDAPAuthNTokens');
if ($validatorRule->check($newTokens)) {
return $newTokens;
} else {
throwError(new Error("Configuration Error: tokens_class, '" . $tokensClass . "' does not extend UsernamePasswordAuthNTokens.", "LDAPAuthNMethod", true));
}
}
示例14: level
/**
* Sets the DebugHandler service's output level to $level. If not specified will
* return the current output level.
* @param optional integer $level
* @static
* @access public
* @return integer The current debug output level.
**/
static function level($level = null)
{
if (!Services::serviceAvailable("Debug")) {
throwError(new Error("Debug::level({$level}) called but Debug service isn't available.", "debug wrapper", false));
return;
}
$debugHandler = Services::getService("Debug");
if (is_int($level)) {
$debugHandler->setOutputLevel($level);
}
return $debugHandler->getOutputLevel();
}
示例15: printTime
function printTime()
{
if (!isset($this->_start) || !isset($this->_end)) {
$err = "Must call start() and end() first.";
throwError(new Error($err, "Timer", true));
}
list($sm, $ss) = explode(" ", $this->_start);
list($em, $es) = explode(" ", $this->_end);
$s = $ss + $sm;
$e = $es + $em;
return $e - $s;
}