本文整理汇总了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();
}