本文整理汇总了PHP中Alias::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Alias::add方法的具体用法?PHP Alias::add怎么用?PHP Alias::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alias
的用法示例。
在下文中一共展示了Alias::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: error_get_last
$error = error_get_last();
if (!empty($error)) {
ob_clean();
$errstr = $error['message'];
$errline = $error['line'];
$errfile = $error['file'];
$errorOutput($errstr, $errline, $errfile, debug_backtrace());
}
};
$exceptionHandler = function ($e) use($errorOutput) {
ob_clean();
$message = $e->getMessage();
$line = $e->getLine();
$file = $e->getFile();
$errorOutput($message, $line, $file, $e->getTrace());
die;
};
//Run the framework!
$framework->bootstrap();
set_error_handler($errorHandler);
set_exception_handler($exceptionHandler);
register_shutdown_function($shutdownHandler);
//If you want to delete alias cache on every run, set deleteAliases in config.php to true
//Add an alias to the app, which enables you to run container operations within "alias" alias as shown below
Container::open('aliases')->add('alias', Container::open('aliases'));
//now we can use Storage:: alias to operate specific container instance
Alias::add('storage', Container::open('storage'));
/*
Your code goes down here
*/
require 'app.php';
示例2: importAlias
protected function importAlias()
{
$this->truncateTables(array('alias'));
$handle = $this->openCsvFile('alias.csv');
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, ';'); $current_line++) {
$res = false;
$fields = $this->filterFields('Alias', $this->alias_fields, $line);
if (!isset($fields['id'])) {
$alias = new Alias((int) $line[0]);
$alias->id = $line[0];
} else {
$alias = new Alias((int) $fields['id']);
}
foreach ($fields as $key => $field) {
$alias->{$key} = $field;
}
$alias->force_id = true;
if (!$res) {
$alias->add();
}
}
$this->closeCsvFile($handle);
return true;
}