本文整理匯總了PHP中Container::factory方法的典型用法代碼示例。如果您正苦於以下問題:PHP Container::factory方法的具體用法?PHP Container::factory怎麽用?PHP Container::factory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Container
的用法示例。
在下文中一共展示了Container::factory方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testFactoryExists
public function testFactoryExists()
{
$this->assertFalse($this->container->factoryExists('foo'));
$this->container->factory('foo', function () {
});
$this->assertTrue($this->container->factoryExists('foo'));
}
示例2: testFactory
public function testFactory()
{
$c = new Container();
$c->factory('service', function () {
return mt_rand() + mt_rand() + mt_rand();
});
$this->assertNotEquals($c->get('service'), $c->get('service'));
}
示例3: before
public function before() {
$session = Container::factory('Session', null, array('name' => 'main'));
$session->set_timeout(5);
$this->template_data['global']['assets']['js'][] = 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js';
$this->template_data['global']['assets']['js'][] = 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js';
$this->template_data['global']['assets']['js'][] = '/js/loopedslider.js';
return parent::before();
}
示例4: action_archive
public function action_archive() {
$this->template_data['global']['title']['description'] = 'Archives';
$this->template_data['posts'] = Container::factory('doctrine')->createQuery("SELECT p FROM Model_News_Post p ORDER BY p.time DESC")->setMaxResults(10)->getArrayResult();
}
示例5: action_newsposts
public function action_newsposts() {
$this->template_data['posts'] = Container::factory('doctrine')->createQuery("SELECT p.name AS post_name, p.id AS post_id, pu.name AS user_name, pu.id AS user_id FROM Model_News_Post p LEFT JOIN p.user pu ORDER BY p.time DESC")->setMaxResults(10)->getArrayResult();
}