本文整理汇总了PHP中Container类的典型用法代码示例。如果您正苦于以下问题:PHP Container类的具体用法?PHP Container怎么用?PHP Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Container类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderFormFieldContent
private function renderFormFieldContent($renderApi, $unit)
{
$this->formSubmit = new \FormSubmit();
$fieldId = 'field' . $unit->getId();
$properties = $unit->getFormValues();
$labelText = $properties["fieldLabel"];
$listType = $properties["listType"];
//select, checkbox, radio
$postRequest = $this->getPostValue($unit);
$choiceBox = new \ChoiceBox();
if ($listType === \ListType::RADIO || $listType === \ListType::CHECKBOX) {
$required = $renderApi->getFormValue($unit, 'enableRequired');
$formField = $choiceBox->getRadioCheckbox($renderApi, $unit, $fieldId, $postRequest, $required);
} elseif ($listType === \ListType::DROP_DOWN) {
$formField = $choiceBox->getSelectField($renderApi, $unit, $fieldId, $postRequest);
}
$label = new \Label();
$labelProperties = $label->getElementProperties();
$labelProperties->addAttribute("for", $fieldId);
$label->add(new \Span($labelText));
if ($formField) {
$elementProperties = $formField->getElementProperties();
$wrapper = new \Container();
$wrapper->add($label);
$wrapper->add($formField);
echo $wrapper->renderElement();
}
$renderApi->renderChildren($unit);
}
示例2: BuildTemplate
public function BuildTemplate($a_template)
{
// Load template
$doc = new Template_Document($a_template);
// Load all static modules
$modules = $doc->getElementsByTag('CMS_MODULE');
foreach ($modules as $module) {
// Build Module
$c_module = new StaticModule($module, $this->m_pageid);
$module_doc = $c_module->Build();
$module->replaceWith($module_doc);
}
// Load all modules
$containers = $doc->getElementsByTag('CMS_CONTAINER');
foreach ($containers as $container) {
$c_container = new Container($container, $this->m_pageid);
$c_container->Build();
}
// Plugin Hook
$data_object = new stdClass();
$data_object->pageid = $this->m_pageid;
$data_object->doc = $doc;
ObjMgr::GetPluginMgr()->ExecuteHook("On_Compiler_BuiltTemplate", $data_object);
return $doc;
}
示例3: getHtml
public function getHtml()
{
$trace = $this->trace->addChild("HodnoteniaCallback");
$hodnotenia = $this->app->getHodnotenia($trace);
$hodnoteniaTable = new Table(TableDefinitions::hodnotenia());
$priemeryCalculator = new PriemeryCalculator();
foreach (Sorter::sort($hodnotenia->getData(), array("semester" => -1, "nazov" => 1)) as $row) {
if ($row['semester'] == 'L') {
$class = 'leto';
$priemeryCalculator->add(PriemeryCalculator::SEMESTER_LETNY, $row['znamka'], $row['kredit']);
} else {
$class = 'zima';
$priemeryCalculator->add(PriemeryCalculator::SEMESTER_ZIMNY, $row['znamka'], $row['kredit']);
}
$hodnoteniaTable->addRow($row, array('class' => $class));
}
$hodnoteniaCollapsible = new Collapsible(new HtmlHeader('Hodnotenia'), $hodnoteniaTable);
$priemery = $this->app->getPriemery($trace);
$priemeryTable = new Table(TableDefinitions::priemery());
$priemeryTable->addRows($priemery->getData());
$priemeryContainer = new Container();
$priemeryContainer->addChild(new Label('Nasledovné priemery sú prebraté z AISu, čiže to (ne)funguje presne rovnako:'));
$priemeryContainer->addChild($priemeryTable);
if ($priemeryCalculator->hasPriemer()) {
$priemeryFajrText = '<p><br />Nasledovné vážené študijné priemery sú počítané Fajrom priebežne z tabuľky Hodnotenia, <strong>preto nemôžu byť považované ako oficiálne</strong>:<br /><br />';
$priemeryFajrText .= $priemeryCalculator->getHtml();
$priemeryFajrText .= '</p>';
$priemeryContainer->addChild(new Label($priemeryFajrText));
}
$priemeryCollapsible = new Collapsible(new HtmlHeader('Priemery'), $priemeryContainer);
return $hodnoteniaCollapsible->getHtml() . $priemeryCollapsible->getHtml();
}
示例4: testCanBindInterfaceUsingWhenNeedsGive
public function testCanBindInterfaceUsingWhenNeedsGive()
{
$this->container->when('NetRivet\\Container\\Test\\Foo')->needs('NetRivet\\Container\\Test\\BarInterface')->give('NetRivet\\Container\\Test\\Bar2');
$foo = $this->container->make('NetRivet\\Container\\Test\\Foo');
$bar = $foo->getBar();
$this->assertInstanceOf('NetRivet\\Container\\Test\\Bar2', $bar);
}
示例5: write
/**
* Write table
*
* @return string
*/
public function write()
{
if (!$this->element instanceof \PhpOffice\PhpWord\Element\Table) {
return '';
}
$content = '';
$rows = $this->element->getRows();
$rowCount = count($rows);
if ($rowCount > 0) {
$content .= '<table>' . PHP_EOL;
foreach ($rows as $row) {
/** @var $row \PhpOffice\PhpWord\Element\Row Type hint */
$rowStyle = $row->getStyle();
// $height = $row->getHeight();
$tblHeader = $rowStyle->isTblHeader();
$content .= '<tr>' . PHP_EOL;
foreach ($row->getCells() as $cell) {
$writer = new Container($this->parentWriter, $cell);
$cellTag = $tblHeader ? 'th' : 'td';
$content .= "<{$cellTag}>" . PHP_EOL;
$content .= $writer->write();
$content .= "</{$cellTag}>" . PHP_EOL;
}
$content .= '</tr>' . PHP_EOL;
}
$content .= '</table>' . PHP_EOL;
}
return $content;
}
示例6: inject
private function inject(Container $model, $arg)
{
$sitemap = '';
foreach ($model->getModels() as $key => $value) {
$sitemap .= $this->visit($value, $arg . '/' . $key, false);
}
return '<div class="sitemap-sub-level"><ul>' . $sitemap . '</ul>';
}
示例7: container
public function container(Container $model, $arg, $bool)
{
$string = '';
foreach ($model->getModels() as $m) {
$string .= $this->visit($m, $arg, $bool);
}
return $string;
}
示例8: container
/**
*
* @param Collection|Container $model
* @param int $arg
* @return string
*/
public function container(Container $model, $arg)
{
$sitemap = '';
foreach ($model->getModels() as $key => $value) {
$sitemap .= $this->visit($value, $arg . '/' . $key);
}
return '<li><p><a href="' . $arg . '">' . $model->config['name'] . '</a></p><div class="sitemap-sub-level"><ul>' . $sitemap . '</ul></div></li>';
}
示例9: testContainerToCallback
public function testContainerToCallback()
{
$c = new Container();
$c->share('service', function (Container $container) {
return $container;
});
$this->assertInstanceOf(Container::class, $c->get('service'));
}
示例10: __construct
/**
* Initialize the router object.
*
* @param Container $container
*/
public function __construct($container)
{
$this->container = $container;
$this->request = new Request($container->get('request'));
$this->response = new Response($this->request->getCallType(), $this->request->isUpload());
$this->defaultAccess = $container->getParameter('direct.api.default_access');
$this->session = $this->container->get('session')->get($container->getParameter('direct.api.session_attribute'));
}
示例11: testGetObjectConstructorArguments
public function testGetObjectConstructorArguments()
{
$container = new Container();
$container->set('foo', new \stdClass());
$container->set('foo_bar', new \stdClass());
$builder = new ObjectBuilder($container);
$object = $builder->getObject('PSX\\Dependency\\FooService', array('foo'), 'PSX\\Dependency\\FooService');
$this->assertEquals('foo', $object->getProperty());
}
示例12: executeCron
public function executeCron(Container $cron, $unqueue = true)
{
$date = $cron->getDate();
if ($date <= time()) {
$_REQUEST = unserialize($cron->getData());
context()->dispatch($cron);
return true === $unqueue ? $this->unqueueCron($cron) : $this;
}
}
示例13: run
public function run()
{
$entityManager = null;
if (is_array($_SERVER['argv'])) {
foreach ($_SERVER['argv'] as $key => $value) {
if (substr($value, 0, 5) === '--em=') {
$entityManager = substr($value, 5);
unset($_SERVER['argv'][$key]);
if (is_int($_SERVER['argc'])) {
$_SERVER['argc']--;
}
break;
}
}
}
$commands = $this->container->getDoctrine()->getCommands();
$helperSet = $this->container->getDoctrine()->getHelperSet($entityManager);
if (!$helperSet instanceof HelperSet) {
foreach ($GLOBALS as $helperSetCandidate) {
if ($helperSetCandidate instanceof HelperSet) {
$helperSet = $helperSetCandidate;
break;
}
}
}
ConsoleRunner::run($helperSet, $commands);
}
示例14: testFactoryExists
public function testFactoryExists()
{
$this->assertFalse($this->container->factoryExists('foo'));
$this->container->factory('foo', function () {
});
$this->assertTrue($this->container->factoryExists('foo'));
}
示例15: _resolveArgs
/**
* Getting required arguments with given parameters
*
* @param \ReflectionParameter[] $required Arguments
* @param array $params Parameters
*
*@return array
*/
private function _resolveArgs($required, $params = array())
{
$args = array();
foreach ($required as $param) {
$name = $param->getName();
$type = $param->getClass();
if (isset($type)) {
$type = $type->getName();
}
if (isset($params[$name])) {
$args[] = $params[$name];
} elseif (is_string($type) && isset($params[$type])) {
$args[] = $params[$type];
} else {
$content = $this->_container->get($name);
if (isset($content)) {
$args[] = $content;
} elseif (is_string($type)) {
$args[] = $this->_container->get($type);
} else {
$args[] = null;
}
}
}
return $args;
}