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


PHP IoC::instance方法代码示例

本文整理汇总了PHP中IoC::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP IoC::instance方法的具体用法?PHP IoC::instance怎么用?PHP IoC::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IoC的用法示例。


在下文中一共展示了IoC::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setup

 private static function setup()
 {
     // Query metadata and store into our config
     $sql = "select `key`, `value` from meta";
     Config::set('metadata', Db::pairs($sql));
     // look up which page has our posts
     $page = Pages::find(array('id' => Config::get('metadata.posts_page')));
     IoC::instance('posts_page', $page, true);
 }
开发者ID:nathggns,项目名称:anchor-cms,代码行数:9,代码来源:anchor.php

示例2: search_results

function search_results()
{
    $posts = IoC::resolve('search');
    if ($result = $posts->valid()) {
        // register single post
        IoC::instance('article', $posts->current(), true);
        // move to next
        $posts->next();
    }
    return $result;
}
开发者ID:rubenvincenten,项目名称:anchor-site,代码行数:11,代码来源:search.php

示例3: setup

 private static function setup()
 {
     // Query metadata and store into our config
     $sql = "select `key`, `value` from meta";
     $meta = array();
     foreach (Db::results($sql) as $row) {
         $meta[$row->key] = $row->value;
     }
     Config::set('metadata', $meta);
     // look up which page has our posts
     $page = Pages::find(array('id' => Config::get('metadata.posts_page')));
     IoC::instance('posts_page', $page, true);
 }
开发者ID:rubenvincenten,项目名称:anchor-site,代码行数:13,代码来源:anchor.php

示例4: posts

function posts()
{
    if (has_posts() === false) {
        return false;
    }
    $posts = IoC::resolve('posts');
    if ($result = $posts->valid()) {
        // register single post
        IoC::instance('article', $posts->current(), true);
        // move to next
        $posts->next();
    }
    return $result;
}
开发者ID:nathggns,项目名称:anchor-cms,代码行数:14,代码来源:posts.php

示例5: comments

function comments()
{
    if (has_comments() === false) {
        return false;
    }
    $items = IoC::resolve('comments');
    if ($result = $items->valid()) {
        // register single comment
        IoC::instance('comment', $items->current(), true);
        // move to next
        $items->next();
    }
    return $result;
}
开发者ID:reqshark,项目名称:anchor-cms,代码行数:14,代码来源:comments.php

示例6: search

 public function search($term = '')
 {
     if (Input::method() == 'POST') {
         if (Input::post('term') !== false) {
             return Response::redirect('search/' . rawurlencode(Input::post('term')));
         }
     }
     $search = Posts::search($term, array('status' => 'published'));
     IoC::instance('search', $search, true);
     $page = new StdClass();
     $page->title = 'Search';
     IoC::instance('page', $page, true);
     Template::render('search');
 }
开发者ID:rubenvincenten,项目名称:anchor-site,代码行数:14,代码来源:routes.php

示例7: search

 public function search($term = '')
 {
     if (Input::method() == 'POST') {
         if (Input::post('term') !== false) {
             return Response::redirect('search/' . rawurlencode(Input::post('term')));
         }
     }
     $search = Posts::search($term, array('status' => 'published', 'limit' => Config::get('metadata.posts_per_page', 10), 'offset' => Input::get('offset', 0)));
     IoC::instance('search', $search, true);
     $total = Posts::search_count($term, array('status' => 'published'));
     IoC::instance('total_search', $total, true);
     $page = new StdClass();
     $page->id = -1;
     $page->title = 'Search';
     IoC::instance('page', $page, true);
     Template::render('search');
 }
开发者ID:reqshark,项目名称:anchor-cms,代码行数:17,代码来源:routes.php

示例8: menu_items

function menu_items($params = array())
{
    if (!has_menu_items()) {
        return false;
    }
    if (($pages = IoC::resolve('menu')) === false) {
        $params['status'] = 'published';
        $pages = Pages::list_all($params);
        IoC::instance('menu', $pages, true);
    }
    if ($result = $pages->valid()) {
        // register single post
        IoC::instance('menu_item', $pages->current(), true);
        // move to next
        $pages->next();
    }
    return $result;
}
开发者ID:reqshark,项目名称:anchor-cms,代码行数:18,代码来源:menus.php

示例9: doRequest

 private function doRequest($URI, $data = [])
 {
     Input::$input = $data;
     Laravel\Routing\Filter::register(require APP_PATH . 'filters' . EXT);
     $loader = new Laravel\Routing\Loader(APP_PATH, ROUTE_PATH);
     $router = new Laravel\Routing\Router($loader, CONTROLLER_PATH);
     IoC::instance('laravel.routing.router', $router);
     Laravel\Request::$route = $router->route(Laravel\Request::method(), Laravel\URI::current());
     if (!is_null(Request::$route)) {
         $response = Request::$route->call();
     } else {
         Laravel\Routing\Filter::run(['before'], [], true);
         $response = Laravel\Response::json(['msg' => 'Not found'], 404);
         \Laravel\Routing\Filter::run(['after'], [$response], true);
     }
     ob_start();
     $response->send();
     $output = ob_get_contents();
     ob_end_clean();
     return $output;
 }
开发者ID:jknox12,项目名称:mirror,代码行数:21,代码来源:LaravelTestCase.php

示例10: unset

 */
unset($input[Request::spoofer]);
Input::$input = $input;
//Compatibility hack
set_log4php_env('ls_log_file', \Config::get('env.log_path') . '/content.log');
\Logger::configure(\Config::get('log4php'));
/**
 * Route the request to the proper route in the application. If a
 * route is found, the route will be called with the current request
 * instance. If no route is found, the 404 response will be returned
 * to the browser.
 */
Routing\Filter::register(require APP_PATH . 'filters' . EXT);
$loader = new Routing\Loader(APP_PATH, ROUTE_PATH);
$router = new Routing\Router($loader, CONTROLLER_PATH);
IoC::instance('laravel.routing.router', $router);
Request::$route = $router->route(Request::method(), URI::current());
if (!is_null(Request::$route)) {
    $new_relic->name_transaction(Request::$route->key);
    try {
        $response = Request::$route->call();
    } catch (\Exception $e) {
        $handler($e);
    }
} else {
    $new_relic->name_transaction('404');
    \Laravel\Routing\Filter::run(array('before'), array(), true);
    $response = \Response::json(['msg' => 'Not found'], 404);
    \Laravel\Routing\Filter::run(array('after'), array($response), true);
}
$response->send();
开发者ID:jknox12,项目名称:mirror,代码行数:31,代码来源:laravel.php

示例11: array

 */
if (magic_quotes()) {
    $magics = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
    foreach ($magics as &$magic) {
        $magic = array_strip_slashes($magic);
    }
}
/**
 * Load the session using the session manager. The payload will
 * be registered in the IoC container as an instance so it can
 * be easily access throughout the framework.
 */
if (Config::get('session.driver') !== '') {
    Session::start(Config::get('session.driver'));
    Session::load(Cookie::get(Config::get('session.cookie')));
    IoC::instance('laravel.session', Session::$instance);
}
/**
 * Gather the input to the application based on the global input
 * variables for the current request. The input will be gathered
 * based on the current request method and will be set on the
 * Input manager class' static $input property.
 */
$input = array();
switch (Request::method()) {
    case 'GET':
        $input = $_GET;
        break;
    case 'POST':
        $input = $_POST;
        break;
开发者ID:bamper,项目名称:laravel.com,代码行数:31,代码来源:laravel.php

示例12: spl_autoload_register

    spl_autoload_register(function ($class) {
        if (substr($class, 0, 7) === 'Dropbox') {
            $class = str_replace('\\', '/', $class);
            require_once __DIR__ . '/' . $class . '.php';
        }
    });
    $app_key = Laravel\Config::get('dropbox::config.app_key');
    $app_secret = Laravel\Config::get('dropbox::config.app_secret');
    $encryption_key = Laravel\Config::get('dropbox::config.encryption_key');
    if (empty($app_key) || empty($app_secret)) {
        throw new \Dropbox\Exception('Please set your Dropbox App key & secret.');
    }
    if (strlen($encryption_key) !== 32) {
        throw new \Dropbox\Exception('Expecting a 32 byte Dropbox encryption key, got ' . strlen($encryption_key));
    }
    // Check whether to use HTTPS and set the callback URL
    $protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https' : 'http';
    $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
    $http_host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '127.0.0.1';
    $callback = $protocol . '://' . $http_host . $request_uri;
    // Instantiate the required Dropbox objects
    $encrypter = new \Dropbox\OAuth\Storage\Encrypter($encryption_key);
    $storage = new \Dropbox\OAuth\Storage\Session($encrypter);
    if ($access_token = Config::get('dropbox::config.access_token')) {
        $storage->set((object) $access_token, 'access_token');
    }
    $OAuth = new \Dropbox\OAuth\Consumer\Curl($app_key, $app_secret, $storage, $callback);
    $dropbox = new \Dropbox\API($OAuth, Laravel\Config::get('dropbox::config.root'));
    IoC::instance('dropbox::session', $storage);
    IoC::instance('dropbox::api', $dropbox);
});
开发者ID:SerdarSanri,项目名称:dropbox-laravel,代码行数:31,代码来源:start.php

示例13: testInstancesAreReturnedBySingleton

 /**
  * Test the IoC::instance method.
  *
  * @group laravel
  */
 public function testInstancesAreReturnedBySingleton()
 {
     $object = new StdClass();
     IoC::instance('bar', $object);
     $this->assertTrue($object === IoC::resolve('bar'));
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:11,代码来源:ioc.test.php

示例14:

| Register PSR-0 Autoloading
|--------------------------------------------------------------------------
|
| Basset uses PSR-0 autoloading to lazily load the required files when
| requested. Here we'll provide the namespaces and their corrosponding
| locations.
|
*/
Autoloader::namespaces(array('Assetic' => __DIR__ . '/vendor/assetic/src/Assetic', 'Basset' => __DIR__ . '/classes'));
/*
|--------------------------------------------------------------------------
| Basset Facade Alias
|--------------------------------------------------------------------------
|
| Alias Basset to the Basset Facade so that we can use a terser static
| syntax to access methods. Lovely.
|
*/
Autoloader::alias('Basset\\Facades\\Basset', 'Basset');
/*
|--------------------------------------------------------------------------
| Register Basset with the IoC
|--------------------------------------------------------------------------
|
| Basset is registered within the IoC container so that everything is
| somewhat testable. We'll use a facade to provide a terser static
| interface.
|
*/
IoC::instance('basset', new Basset\Basset());
开发者ID:jvillasante,项目名称:cubanartjb,代码行数:30,代码来源:start.php

示例15: testTextMatchingCaseSensitive

 public function testTextMatchingCaseSensitive()
 {
     // stub out the request class
     $mock = Mockery::mock('ClementiaRequest');
     $test_result = new stdClass();
     $test_result->status_code = 200;
     $test_result->body = '<html><body><h1 class="active hover">Some Text</h1></body></html>';
     $mock->shouldReceive('get')->andReturn($test_result);
     // set the requests object to be our stub
     IoC::instance('requests', $mock);
     $tester = IoC::resolve('tester');
     $result = $tester->test('text', 'http://dhwebco.com', array('text' => 'Some Text', 'case_sensitive' => TRUE));
     $this->assertTrue($result);
 }
开发者ID:netcon-source,项目名称:clementia,代码行数:14,代码来源:tester.test.php


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