Permalink
Browse files

fixes

  • Loading branch information...
dg committed Oct 5, 2018
1 parent c0ac99a commit 5cc609c84a25aa8c02f59fdca88bb632d0ce4410
@@ -144,7 +144,7 @@ class ArticleFactory

function create()
{
$article = new Article($this->database, $this->cacheStorage, ...);
return new Article($this->database, $this->cacheStorage, ...);
}
}

@@ -54,9 +54,9 @@ Můžeme si také přidat vlastní validátory. Metody `addRule()` a `addConditi
/--php
// uživatelský validátor: testuje, zda je hodnota dělitelná argumentem
// poznámka: toto je skutečná funkce, nikoliv metoda v presenteru
function divisibilityValidator($item, $arg)
function divisibilityValidator(BaseControl $item, $arg)
{
return $item->value % $arg === 0;
return $item->getValue() % $arg === 0;
}

$form->addInteger('number', 'Číslo:')
@@ -12,8 +12,8 @@ class MyTranslator implements Nette\Localization\ITranslator
{
/**
* Translates the given string.
* @param string message
* @param int plural count
* @param mixed message
* @param int plural count
* @return string
*/
public function translate($message, $count = null)
@@ -317,7 +317,7 @@ $function->addBody('return $a \? 10 : ?;', [$num]);
echo $function;
\--

Result:
Výsledek:

/--php
function foo($a)
@@ -24,7 +24,7 @@ Najdete v tomto příkladu chybu?
/--php
class Circle
{
public $radius;
public $radius = 0.0;

public function getArea()
{
@@ -90,7 +90,7 @@ class Circle
{
use Nette\SmartObject;

private $radius; // už není public!
private $radius = 0.0; // už není public!

protected function getRadius()
{
@@ -143,7 +143,7 @@ class ArticleFactory

function create()
{
$article = new Article($this->database, $this->cacheStorage, ...);
return new Article($this->database, $this->cacheStorage, ...);
}
}

@@ -54,9 +54,9 @@ We can add own validators. Methods `addRule()` and `addCondition()` do accept ca
/--php
// user validation: checks if $item is divisible by $arg
// note: this is a real function, not a method in the presenter
function divisibilityValidator($item, $arg)
function divisibilityValidator(BaseControl $item, $arg)
{
return $item->value % $arg === 0;
return $item->getValue() % $arg === 0;
}

$form->addInteger('number', 'Number:')
@@ -12,8 +12,8 @@ class MyTranslator implements Nette\Localization\ITranslator
{
/**
* Translates the given string.
* @param string message
* @param int plural count
* @param mixed message
* @param int plural count
* @return string
*/
public function translate($message, $count = null)
@@ -24,7 +24,7 @@ Can you find an error in this example?
/--php
class Circle
{
public $radius;
public $radius = 0.0;

public function getArea()
{
@@ -90,7 +90,7 @@ class Circle
{
use Nette\SmartObject;

private $radius; // not public anymore!
private $radius = 0.0; // not public anymore!

protected function getRadius()
{

0 comments on commit 5cc609c

Please sign in to comment.