本文整理汇总了PHP中Bundle::prefix方法的典型用法代码示例。如果您正苦于以下问题:PHP Bundle::prefix方法的具体用法?PHP Bundle::prefix怎么用?PHP Bundle::prefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bundle
的用法示例。
在下文中一共展示了Bundle::prefix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPrefixMethodReturnsCorrectPrefix
/**
* Test the Bundle::prefix method.
*
* @group laravel
*/
public function testPrefixMethodReturnsCorrectPrefix()
{
$this->assertEquals('dummy::', Bundle::prefix('dummy'));
$this->assertEquals('', Bundle::prefix(DEFAULT_BUNDLE));
}
示例2: function
<?php
/**
* @link https://github.com/lordcoste/analytics-s2s
* @author Colao Stefano < lordcoste@gmail.com >
*/
const BUNDLE_NAME = 'analytics-s2s';
Autoloader::map(array('Analytics' => Bundle::path(BUNDLE_NAME) . 'Analytics.php', 'AnalyticsService' => Bundle::path(BUNDLE_NAME) . 'AnalyticsService.php', 'Google_Client' => Bundle::path(BUNDLE_NAME) . 'google-api' . DS . 'Google_Client.php', 'Google_AnalyticsService' => Bundle::path(BUNDLE_NAME) . 'google-api' . DS . 'contrib' . DS . 'Google_AnalyticsService.php'));
IoC::singleton('google-analytics', function () {
$prefix = Bundle::prefix(BUNDLE_NAME);
if (!File::exists(Config::get($prefix . 'google.certificate_path'))) {
throw new Exception("Can't find the .p12 certificate in: " . Config::get($prefix . 'google.certificate_path'));
}
$config = array('oauth2_client_id' => Config::get($prefix . 'google.client_id'), 'use_objects' => Config::get($prefix . 'google.use_objects'));
$google = new Google_Client($config);
$google->setAccessType('offline');
$google->setAssertionCredentials(new Google_AssertionCredentials(Config::get($prefix . 'google.service_email'), array('https://www.googleapis.com/auth/analytics.readonly'), file_get_contents(Config::get($prefix . 'google.certificate_path'))));
return new AnalyticsService($google);
});
Analytics::init(IoC::resolve('google-analytics'));
示例3: Exception
$class_file = $class_name . ".php";
$classes = Google::services();
if (Session::has('token')) {
$google->setAccessToken(Session::get('token'));
try {
if (in_array($class_file, $classes)) {
$service = new $class_name($google);
} else {
throw new Exception('Google API Service not found');
}
} catch (apiServiceException $e) {
print 'There was an API service error ' . $e->getCode() . ':' . $e->getMessage();
} catch (apiException $e) {
print 'There was a general API error ' . $e->getCode() . ':' . $e->getMessage();
} catch (Exception $e) {
print 'There was a general error ' . $e->getCode() . ':' . $e->getMessage();
}
}
if ($google->getAccessToken()) {
Session::put('token', $google->getAccessToken());
return View::make(Bundle::prefix(BUNDLE_NAME) . 'index');
} else {
$data = array('google_auth_url' => $google->createAuthUrl());
return View::make(Bundle::prefix(BUNDLE_NAME) . 'index', $data);
}
});
Route::get('(:bundle)/logout', function () {
if (Session::has('token')) {
Session::forget('token');
}
});