本文整理汇总了PHP中Nette\Application\UI\Control类的典型用法代码示例。如果您正苦于以下问题:PHP Control类的具体用法?PHP Control怎么用?PHP Control使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Control类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTemplate
/**
* @return Template
*/
public function createTemplate(UI\Control $control = NULL)
{
$latte = $this->latteFactory->create();
$template = new Template($latte);
$presenter = $control ? $control->getPresenter(FALSE) : NULL;
if ($control instanceof UI\Presenter) {
$latte->setLoader(new Loader($control));
}
if ($latte->onCompile instanceof \Traversable) {
$latte->onCompile = iterator_to_array($latte->onCompile);
}
array_unshift($latte->onCompile, function ($latte) use($control, $template) {
$latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
UIMacros::install($latte->getCompiler());
if (class_exists(Nette\Bridges\FormsLatte\FormMacros::class)) {
Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
}
if ($control) {
$control->templatePrepareFilters($template);
}
});
$latte->addFilter('url', 'rawurlencode');
// back compatiblity
foreach (['normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse'] as $name) {
$latte->addFilter($name, 'Nette\\Utils\\Strings::' . $name);
}
$latte->addFilter('null', function () {
});
$latte->addFilter('modifyDate', function ($time, $delta, $unit = NULL) {
return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit);
// intentionally ==
});
if (!isset($latte->getFilters()['translate'])) {
$latte->addFilter('translate', function (Latte\Runtime\FilterInfo $fi) {
throw new Nette\InvalidStateException('Translator has not been set. Set translator using $template->setTranslator().');
});
}
// default parameters
$template->user = $this->user;
$template->baseUri = $template->baseUrl = $this->httpRequest ? rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/') : NULL;
$template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
$template->flashes = [];
if ($control) {
$template->control = $control;
$template->presenter = $presenter;
$latte->addProvider('uiControl', $control);
$latte->addProvider('uiPresenter', $presenter);
$latte->addProvider('snippetBridge', new Nette\Bridges\ApplicationLatte\SnippetBridge($control));
}
$latte->addProvider('cacheStorage', $this->cacheStorage);
// back compatibility
$template->_control = $control;
$template->_presenter = $presenter;
$template->netteCacheStorage = $this->cacheStorage;
if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
$id = $control->getParameterId('flash');
$template->flashes = (array) $presenter->getFlashSession()->{$id};
}
return $template;
}
示例2: matchItem
/**
* Checks whether an item is current.
*
* If the voter is not able to determine a result,
* it should return null to let other voters do the job.
*
* @param ItemInterface $item
*
* @return boolean|null
*/
public function matchItem(ItemInterface $item)
{
if ($item->getExtra('link', false) && $this->parentControl) {
$presenter = $this->parentControl->getPresenter(true);
$item->setCurrent(call_user_func_array(array($presenter, 'isLinkCurrent'), $item->getExtra('link')));
return $item->isCurrent();
}
return null;
}
示例3: createTemplate
/**
* @return Template
*/
public function createTemplate(UI\Control $control)
{
$latte = $this->latteFactory->create();
$template = new Template($latte);
$presenter = $control->getPresenter(FALSE);
if ($control instanceof UI\Presenter) {
$latte->setLoader(new Loader($control));
}
if ($latte->onCompile instanceof \Traversable) {
$latte->onCompile = iterator_to_array($latte->onCompile);
}
array_unshift($latte->onCompile, function ($latte) use ($control, $template) {
$latte->getParser()->shortNoEscape = TRUE;
$latte->getCompiler()->addMacro('cache', new Nette\Bridges\CacheLatte\CacheMacro($latte->getCompiler()));
UIMacros::install($latte->getCompiler());
if (class_exists('Nette\Bridges\FormsLatte\FormMacros')) {
Nette\Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
}
$control->templatePrepareFilters($template);
});
$latte->addFilter('url', 'rawurlencode'); // back compatiblity
foreach (array('normalize', 'toAscii', 'webalize', 'padLeft', 'padRight', 'reverse') as $name) {
$latte->addFilter($name, 'Nette\Utils\Strings::' . $name);
}
$latte->addFilter('null', function () {});
$latte->addFilter('length', function ($var) {
return is_string($var) ? Nette\Utils\Strings::length($var) : count($var);
});
$latte->addFilter('modifyDate', function ($time, $delta, $unit = NULL) {
return $time == NULL ? NULL : Nette\Utils\DateTime::from($time)->modify($delta . $unit); // intentionally ==
});
// default parameters
$template->control = $template->_control = $control;
$template->presenter = $template->_presenter = $presenter;
$template->user = $this->user;
$template->netteHttpResponse = $this->httpResponse;
$template->netteCacheStorage = $this->cacheStorage;
$template->baseUri = $template->baseUrl = $this->httpRequest ? rtrim($this->httpRequest->getUrl()->getBaseUrl(), '/') : NULL;
$template->basePath = preg_replace('#https?://[^/]+#A', '', $template->baseUrl);
$template->flashes = array();
if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
$id = $control->getParameterId('flash');
$template->flashes = (array) $presenter->getFlashSession()->$id;
}
return $template;
}
示例4: attached
public function attached($presenter)
{
parent::attached($presenter);
$this->wdata = $this->WDataModel->get($this->presenter->getParameter('destination'));
$this->template->village = $this->village = $this->villageService->getVillage($this->presenter->getParameter('id'));
$this->units = $this->unitService->getUnits($this->village);
$this->template->units = $this->units;
$this->template->names = $this->unitService->getNames();
$unitData = [];
switch ($this->village->getOwner()->tribe) {
case App\FrontModule\Model\User\UserService::TRIBE_ROMANS:
foreach (App\GameModule\Model\Units\UnitService::ROMANS as $unit) {
$unitData[] = $this->unitFactory->getUnit($unit);
}
break;
case App\FrontModule\Model\User\UserService::TRIBE_TEUTONS:
foreach (App\GameModule\Model\Units\UnitService::TEUTONS as $unit) {
$unitData[] = $this->unitFactory->getUnit($unit);
}
break;
case App\FrontModule\Model\User\UserService::TRIBE_GAULS:
foreach (App\GameModule\Model\Units\UnitService::GAULS as $unit) {
$unitData[] = $this->unitFactory->getUnit($unit);
}
break;
}
$this->template->unitData = $unitData;
$this->template->setFile(__DIR__ . '/SendUnitsControl.latte');
}
示例5: addSnippet
public function addSnippet($name, $content)
{
if ($this->payload === NULL) {
$this->payload = $this->control->getPresenter()->getPayload();
}
$this->payload->snippets[$this->control->getSnippetId($name)] = $content;
}
示例6: __construct
public function __construct(User $user, CustomerService $cus, CountriesService $cs)
{
parent::__construct();
$this->user = $user;
$this->cus = $cus;
$this->cs = $cs;
}
示例7: attached
/**
* @param \Nette\ComponentModel\Container $obj
*/
protected function attached($obj)
{
parent::attached($obj);
if ($obj instanceof Nette\Application\UI\Presenter) {
$this->payPal->setReturnAddress($this->link('//return!'), $this->link('//cancel!'));
}
}
示例8: createTemplate
/**
* Automatically registers template file.
*
* @author Jan Tvrdík
* @param string
* @return Nette\Templating\FileTemplate
*/
protected function createTemplate($class = NULL)
{
$template = parent::createTemplate($class);
if ($this->autoSetupTemplateFile) $template->setFile($this->getTemplateFilePath());
return $template;
}
示例9: __construct
/**
* Editrouble constructor.
* @param IContainer $parent
* @param string $name
* @param Connector $connector
*/
public function __construct(IContainer $parent, $name, Connector $connector, Request $request)
{
parent::__construct($parent, $name);
$this->connector = $connector;
$this->storage = $connector->getStorage();
$this->request = $request;
}
示例10: __construct
public function __construct(States $states, Colors $colors)
{
parent::__construct();
$this->states = $states;
$this->ordered = $this->states->findBy([], ['sequence' => 'ASC']);
$this->colors = $colors;
}
示例11: __construct
public function __construct($default_render = self::TYPE_MINI, IPictureViewFactory $picture_view_factory, IGlobalSettings $settings)
{
parent::__construct();
$this->default_render = $default_render;
$this->picture_view_factory = $picture_view_factory;
$this->settings = $settings;
}
示例12: __construct
public function __construct($parent, $name)
{
parent::__construct($parent, $name);
$this->templatesDir = __DIR__ . "/templates/";
$this->templateFile = $this->templatesDir . "default.latte";
$this->homepageTemplateFile = $this->templatesDir . "homepage.latte";
}
示例13: createTemplate
/**
* @return ITemplate
*/
public function createTemplate()
{
$template = parent::createTemplate();
/** @noinspection PhpUndefinedMethodInspection */
$template->setTranslator($this->translator);
return $template;
}
示例14: createTemplate
protected function createTemplate($class = NULL)
{
if (!is_null($this->templateFactory)) {
return $this->templateFactory->createTemplate($this->getPresenter());
}
return parent::createTemplate($class);
}
示例15:
function __construct($templateFile = NULL, IFilterFactory $filterFactory, Trejjam\Utils\Helpers\IBaseList $list = NULL)
{
parent::__construct();
$this->setTemplate($templateFile);
$this->filterFactory = $filterFactory;
$this->list = $list;
}