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


PHP Bundle::prefix方法代码示例

本文整理汇总了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));
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:10,代码来源:bundle.test.php

示例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'));
开发者ID:SerdarSanri,项目名称:analytics-s2s,代码行数:20,代码来源:start.php

示例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');
    }
});
开发者ID:SerdarSanri,项目名称:google-api-php-client,代码行数:31,代码来源:routes.php


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