本文整理汇总了PHP中App::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP App::instance方法的具体用法?PHP App::instance怎么用?PHP App::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: withoutEvents
protected function withoutEvents()
{
$mock = Mockery::mock('Illuminate\\Contracts\\Events\\Dispatcher');
$mock->shouldReceive('fire');
App::instance('events', $mock);
return $this;
}
示例2: sendEmail
function sendEmail($email_template, $subject = '', $additional_data = array(), $from_email = '', $from_name = '')
{
$config = (require APPDIR . 'config/email.php');
$app = App::instance();
$data = array('user' => $this);
$data = array_merge($data, $additional_data);
$message = $app->twig->render('emails/' . $email_template, $data);
$this->last_email_html = $message;
$mail = $app->email;
foreach ($config as $key => $value) {
$mail->{$key} = $value;
}
if ($from_email) {
$mail->From = $from_email;
}
if ($from_name) {
$mail->FromName = $from_name;
}
$mail->Subject = $subject;
$mail->Body = $message;
$mail->isHTML($config['isHTML']);
$mail->addAddress($this->email);
$mail->send();
return $this;
}
示例3: getInstance
/**
* 单例模式
*
* @return obj
*/
public static function getInstance() {
if(!isset(self::$instance)) {
$class = __CLASS__;
self::$instance = new $class();
}
return self::$instance;
}
示例4: get_instance
/**
* Get singleton instance
*
* @return Event
*/
public static function get_instance()
{
if (!isset(self::$instance)) {
self::$instance = new App();
}
return self::$instance;
}
示例5: __construct
public function __construct($config)
{
$this->_objects['app'] = App::instance();
$this->_objects['router'] = Router::instance();
$this->_objects['inputs'] = Inputs::instance();
$this->_objects['session'] = Session::instance();
$this->_objects['log'] = Log::factory();
if (!isset($this->app->config['database']['redis'][$config['serverId']])) {
$config['serverId'] = 0;
}
$current = $this->app->config['database']['redis'][$config['serverId']];
$current['serverId'] = $config['serverId'];
$this->_objects['db'] = Db::factory($current);
$this->_objects['infoModel'] = new Info_Model($current);
$info = $this->db->info();
$dbs = $this->infoModel->getDbs($info);
if (!isset($current['max_databases'])) {
$databasesConfig = $this->_objects['db']->config('GET', 'databases');
$current['max_databases'] = $databasesConfig['databases'];
}
// Take care of invalid dbId's. If invalid, set to first available database
if (!is_numeric($config['dbId']) || $config['dbId'] < 0 || $config['dbId'] >= $current['max_databases']) {
$config['dbId'] = $dbs[0];
}
$current['newDB'] = !in_array($config['dbId'], $dbs) ? true : false;
$current['database'] = $config['dbId'];
// Extract number of keys
foreach ($dbs as $i) {
if (preg_match('/^keys=([0-9]+),expires=([0-9]+)/', $info["db{$i}"], $matches)) {
$current['dbs'][$i] = array('id' => $i, 'keys' => $matches[1], 'name' => isset($current['dbNames'][$i]) ? $current['dbNames'][$i] : null);
}
}
$this->db->select($current['database']);
$this->app->current = $current;
}
示例6: setupTestModel
public function setupTestModel($name)
{
$mock = Mockery::mock($name);
$mock->shouldIgnoreMissing();
\App::instance($name, $mock);
return $mock;
}
示例7: Main
/**
* @static
* @return App
*/
public static function Main()
{
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
示例8: app
public static function app()
{
if (is_null(App::$instance)) {
App::$instance = new App();
}
return App::$instance;
}
示例9: getInstance
static function getInstance()
{
if (!self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
示例10: setUp
public function setUp()
{
$this->dbRef = new DBTest();
$this->dbRef->setUp();
$this->DB = $this->dbRef->DB;
$this->Person = new PersonModelTest(\App::instance());
}
示例11: start
public static function start()
{
self::init();
self::safe();
self::checkFolders();
return App::instance();
}
示例12: shouldReceive
public static function shouldReceive()
{
$repo = get_called_class() . 'RepositoryInterface';
$mock = Mockery::mock($repo);
App::instance($repo, $mock);
return call_user_func_array([$mock, 'shouldReceive'], func_get_args());
}
示例13: __construct
public function __construct()
{
// constructor
$this->app = App::instance();
// Get variables by post request
if ($this->app->post('columns')) {
$columns = $this->app->post()->get('columns');
$order = $this->app->post()->get('order');
$start = $this->app->post()->get('start');
$length = $this->app->post()->get('length');
$search = $this->app->post()->get('search');
$draw = $this->app->post()->get('draw');
} else {
// Get variables by get request
$columns = $this->app->get()->get('columns');
$order = $this->app->get()->get('order');
$start = $this->app->get()->get('start');
$length = $this->app->get()->get('length');
$search = $this->app->get()->get('search');
$draw = $this->app->get()->get('draw');
}
// Save for later use
$this->columns = $columns;
$this->order = $order;
$this->start = $start;
$this->length = $length;
$this->search = $search;
$this->draw = $draw;
}
示例14: testDestroyShouldCallDestroyMethod
public function testDestroyShouldCallDestroyMethod()
{
$mock = Mockery::mock('PostRepositoryInterface');
$mock->shouldReceive('destroy')->once()->andReturn(true);
App::instance('PostRepositoryInterface', $mock);
$response = $this->call('DELETE', route('v1.posts.destroy', array(1)));
$this->assertTrue(empty($response->original));
}
示例15: baseUrl
function baseUrl($path = '')
{
$baseUrl = App::instance()->request()->getBaseUrl();
$strippedBaseUrl = str_replace('index.php/', '', $baseUrl);
$generated = $strippedBaseUrl . '/' . $path;
$sanitized = str_replace('index.php/', '', $generated);
return $sanitized;
}