コード例 #1
0
ファイル: ioc.test.php プロジェクト: acmadi/diantaksi
 /**
  * Test that singletons are created once.
  *
  * @group laravel
  */
 public function testSingletonsAreCreatedOnce()
 {
     IoC::singleton('foo', function () {
         return new StdClass();
     });
     $object = IoC::resolve('foo');
     $this->assertTrue($object === IoC::resolve('foo'));
 }
コード例 #2
0
/**
 * The bundle repository is responsible for communicating with
 * the Laravel bundle sources to get information regarding any
 * bundles that are requested for installation.
 */
if (!IoC::registered('bundle.repository')) {
    IoC::singleton('bundle.repository', function () {
        return new Tasks\Bundle\Repository();
    });
}
/**
 * The bundle publisher is responsible for publishing bundle
 * assets to their correct directories within the install,
 * such as the web accessible directory.
 */
if (!IoC::registered('bundle.publisher')) {
    IoC::singleton('bundle.publisher', function () {
        return new Tasks\Bundle\Publisher();
    });
}
/**
 * The Github bundle provider installs bundles that live on
 * Github. This provider will add the bundle as a submodule
 * and will update the submodule so that the bundle is
 * installed into the bundle directory.
 */
if (!IoC::registered('bundle.provider: github')) {
    IoC::singleton('bundle.provider: github', function () {
        return new Tasks\Bundle\Providers\Github();
    });
}
コード例 #3
0
}
/**
 * The bundle publisher is responsible for publishing bundle
 * assets to their correct directories within the install,
 * such as the web accessible directory.
 */
if (!IoC::registered('bundle.publisher')) {
    IoC::singleton('bundle.publisher', function () {
        return new Tasks\Bundle\Publisher();
    });
}
/**
 * The Github bundle provider installs bundles that live on
 * Github. This provider will add the bundle as a submodule
 * and will update the submodule so that the bundle is
 * installed into the bundle directory.
 */
if (!IoC::registered('bundle.provider: github')) {
    IoC::singleton('bundle.provider: github', function () {
        return new Tasks\Bundle\Providers\Github();
    });
}
/**
 * The "help" task provides information about 
 * artisan usage.
 */
if (!IoC::registered('task: help')) {
    IoC::singleton('task: help', function () {
        return new Tasks\Help();
    });
}
コード例 #4
0
ファイル: bootstrap.php プロジェクト: laravelbook/framework3
<?php

use Laravel\IoC;
use Laravel\Config;
use Laravel\Mail\Mailer;
// Register a mailer in the IoC container
IoC::singleton('mailer', function () {
    $swiftMailer = IoC::resolve('swift.mailer');
    $mailer = new Mailer($swiftMailer);
    $from = Config::get('mail.from');
    // If a "from" address is set, we will set it on the mailer so that all mail
    // messages sent by the applications will utilize the same "from" address
    // on each one, which makes the developer's life a lot more convenient.
    if (is_array($from) and isset($from['address'])) {
        $mailer->alwaysFrom($from['address'], $from['name']);
    }
    // toggle email debugging mode
    $pretend = Config::get('mail.pretend', false);
    $mailer->pretend($pretend);
    return $mailer;
});
// Register a swift mailer in the IoC container
IoC::register('swift.mailer', function () {
    $transport = IoC::resolve('swift.mailer.transport');
    return Swift_Mailer::newInstance($transport);
});
// Register a transporter in the IoC container
IoC::register('swift.mailer.transport', function () {
    extract(Config::get('mail'));
    // $host = Config::get('mail.host');
    // $port = Config::get('mail.port');