コード例 #1
0
 */
if (!IoC::registered('task: migrate')) {
    IoC::register('task: migrate', function () {
        $database = new Tasks\Migrate\Database();
        $resolver = new Tasks\Migrate\Resolver($database);
        return new Tasks\Migrate\Migrator($resolver, $database);
    });
}
/**
 * The bundle task is responsible for the installation of bundles
 * and their dependencies. It utilizes the bundles API to get the
 * meta-data for the available bundles.
 */
if (!IoC::registered('task: bundle')) {
    IoC::register('task: bundle', function () {
        $repository = IoC::resolve('bundle.repository');
        return new Tasks\Bundle\Bundler($repository);
    });
}
/**
 * The key task is responsible for generating a secure, random
 * key for use by the application when encrypting strings or
 * setting the hash values on cookie signatures.
 */
if (!IoC::registered('task: key')) {
    IoC::singleton('task: key', function () {
        return new Tasks\Key();
    });
}
/**
 * The session task is responsible for performing tasks related
 * to the session store of the application. It can do things
コード例 #2
0
ファイル: ioc.test.php プロジェクト: acmadi/diantaksi
 public function testCanUnregisterRegistered()
 {
     $testClass = 'test';
     IoC::register($testClass, function () {
     });
     $this->assertTrue(IoC::registered($testClass));
     IoC::unregister($testClass);
     $this->assertFalse(IoC::registered($testClass));
 }
コード例 #3
0
ファイル: bootstrap.php プロジェクト: laravelbook/framework3
    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');
    // $encryption = Config::get('mail.encryption');
    // $username = Config::get('mail.username');
    // $password = Config::get('mail.password');
    // The Swift SMTP transport instance will allow us to use any SMTP backend
    // for delivering mail such as Sendgrid, Amazon SMS, or a custom server
    // a developer has available. We will just pass this configured host.
    $transport = Swift_SmtpTransport::newInstance($host, $port);
    if (isset($encryption)) {
        $transport->setEncryption($encryption);
    }
    // Once we have the transport we will check for the presence of a username
    // and password. If we have it we will set the credentials on the Swift
    // transporter instance so that we'll properly authenticate delivery.
    if (isset($username)) {
        $transport->setUsername($username);
        $transport->setPassword($password);
    }
    return $transport;
});