<?php
class OrderAction extends FrontControl
{
public function __construct(,
Order $order,
Model\OrderAction $orderAction,
Container $container
)
{
parent::__construct();
$this->order = $order;
$this->orderAction = $orderAction;
$this->actions = $this->orderAction->getActions($this->pageByState);
}
public function render(array $config = [])
{
$config = $this->getCurrentConfig($config);
$this->template->order = $this->order;
$this->template->actions = $this->actions;
$this->vueRender($config);
}
public function createComponent(string $name): ?Nette\ComponentModel\IComponent
{
if (!Strings::startsWith($name, 'action')) {
return parent::createComponent($name);
}
return $this->container->createInstance('App\\FrontModule\\Components\\' . $this->actions[Strings::after($name, 'action')]->action, [
'orderAction' => $this->actions[Strings::after($name, 'action')],
'order' => $this->order
]);
}
}
<?php
public function createComponentOrderReview()
{
return $this->getPresenter()->getControlFactory()->create($this, 'orderReview', [
'order' => $this->getOrder()
]);
}
// from same category
public function createComponentSameCategoryProducts()
{
$config = $this->getCurrentConfig();
$product = $this->getProduct();
$component = parent::createComponent($config['category_list_component']);
$component->setConfig([
'except_ids' => [
$product::INHERITED ? $product->product_id : $product->id,
$product->item__product_id,
$product->inherit__product_id
],
'navigation_id' => $product->getMainCat()->id,
'default_filter' => []
]);
return $component;
}
{var $mailData = $control->lookup('App\FrontModule\Components\MailTemplateWrapper')->template}
{var $settings = $presenter->getContext()->getByType(App\EshopModule\Model\Settings::class)->getSetting()}
<?php
/* https://forum.nette.org/cs/35218-muze-checkboxlist-vracet-associativni-pole-misto-indexoveho#p220072 */
0 => 'po'
1 => 'st'
2 => 'ct'
po => true
ut => false
st => true
ct => true
pa => false
array_walk($arr, fn(&$item, $key, $values) => $item = in_array($key, $values), $values);
<?php
try
{
// ...
$this->redirect('PresenterWhatEver:default');
}
catch (\Exception $e)
{
// posle se to dal kdyz premserujeme - redirect vyhazuje abortException ...
if ($e instanceof Nette\Application\AbortException)
{
throw $e;
}
}
<?php
public function actionDefault($back = null)
{
if ($back)
$this->restoreRequest($back);
if ($this->presenter->navigation->navItem['alias'] == 'allOpenCalls')
{
$parentId = $this->presenter->navigation->navItem['parent__navigation_id'];
$nav = $this->navigation->getById($parentId);
$children = $nav->getChildren();
$this->config['navigation_id'] = array_keys($children);
}
$this->template->back = $this->storeRequest();
}
<?php
// https://forum.nette.org/cs/34290-prihlaseni-admina-jako-uzivatel
// bez přepisování $user proměné
public function handleKlientLogin($hash)
{
overim hash a nactu data klienta
$user = $this->getUser();
$user->getStorage()->setNamespace('frontend');
$user->login(new Identity($user->id, $user->role, ['username' => $user->username]));
$this->redirect(....);
}
services:
- Config
reCaptcha:
siteKey: @Config::getSiteKey()
secretKey: @Config::getSecretKey()
methodName: 'addReCaptcha' # optional
<?php
if ($form['submit']->isSubmittedBy()) {
// ...
}
or
if ($form->isSubmitted() === $form['submit']) {
// ...
}
or
public function validate($form)
{
if ($form->isSubmitted()->getName() == 'reloadSelect')
return;
}