Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added parameters to Tag::renderTitle() #13706

Merged
merged 4 commits into from Dec 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG-4.0.md
Expand Up @@ -119,9 +119,11 @@
- the `Phalcon\Session\Adapter\Files` using the name `session`
- the `Phalcon\Session\Bag` using the name `sessionBag` [#12921](https://github.com/phalcon/cphalcon/issues/12921)
[#12921](https://github.com/phalcon/cphalcon/issues/12921)
- Changed the `Phalcon\Session` namespace by refactoring the component. `Phalcon\Session\Manager` is now the single component offering session manipulation by using adapters. Each adapter implements PHP's `SessionHandlerInterface`. Available adapters are `Phalcon\Session\Files`, `Phalcon\Session\Libmemcached`, `Phalcon\Session\Noop` and `Phalcon\Session\Redis`. [#12921](https://github.com/phalcon/cphalcon/issues/12833), [#11341](https://github.com/phalcon/cphalcon/issues/11341), [#13535](https://github.com/phalcon/cphalcon/issues/13535)
- Changed the `Phalcon\Session` namespace by refactoring the component. `Phalcon\Session\Manager` is now the single component offering session manipulation by using adapters. Each adapter implements PHP's `SessionHandlerInterface`. Available adapters are `Phalcon\Session\Files`, `Phalcon\Session\Libmemcached`, `Phalcon\Session\Noop` and `Phalcon\Session\Redis`. [#12921](https://github.com/phalcon/cphalcon/issues/12833), (https://github.com/phalcon/cphalcon/issues/11341), (https://github.com/phalcon/cphalcon/issues/13535)
- Fixed `Phalcon\Mvc\Models` magic method (setter) is fixed for arrays [#13661](https://github.com/phalcon/cphalcon/issues/13661)
- Fixed `Phalcon\Mvc\Model::skipAttributes` and `Phalcon\Mvc\Model::allowEmptyColumns` allowEmptyStrings & skipAttributes repsect the column mapping. [#12975](https://github.com/phalcon/cphalcon/issues/12975), [#13477](https://github.com/phalcon/cphalcon/issues/13477)
- Changed the `Phalcon\Tag::renderTitle()` parameters such as `Phalcon\Tag::getTitle()`
- Changed the `Phalcon\Html\Tag::renderTitle()` parameters such as `Phalcon\Html\Tag::getTitle()`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niden Can you please move these lines to another section, e.g.

# [4.0.0-alpha2](https://github.com/phalcon/cphalcon/releases/tag/v4.0.0-alpha2) (2019-XX-XX)
## Changed
- Changed the `Phalcon\Tag::renderTitle()` parameters such as `Phalcon\Tag::getTitle()
- Changed the `Phalcon\Html\Tag::renderTitle()` parameters such as `Phalcon\Html\Tag::getTitle()`


## Removed
- PHP < 7.2 no longer supported
Expand Down
19 changes: 12 additions & 7 deletions phalcon/html/tag.zep
Expand Up @@ -425,9 +425,10 @@ class Tag implements InjectionAwareInterface
* $tag = new Tag();
*
* $tag
* ->prependTitle('Hello')
* ->setTitleSeparator(' ')
* ->prependTitle(['Hello'])
* ->setTitle('World')
* ->appendTitle('from Phalcon');
* ->appendTitle(['from Phalcon']);
*
* echo $tag->getTitle(); // Hello World from Phalcon
* echo $tag->getTitle(false); // World from Phalcon
Expand Down Expand Up @@ -1084,20 +1085,24 @@ class Tag implements InjectionAwareInterface
* $tag = new Tag();
*
* $tag
* ->prependTitle('Hello')
* ->setTitleSeparator(' ')
* ->prependTitle(['Hello'])
* ->setTitle('World')
* ->appendTitle('from Phalcon');
* ->appendTitle(['from Phalcon']);
*
* echo $tag->renderTitle(); // <title>Hello World From Phalcon</title>
* echo $tag->renderTitle(); // <title>Hello World from Phalcon</title>
* echo $tag->renderTitle(false); // <title>World from Phalcon</title>
* echo $tag->renderTitle(true, false); // <title>Hello World</title>
* echo $tag->renderTitle(false, false); // <title>World</title>
* </code>
*
* <code>
* {{ render_title() }}
* </code>
*/
public function renderTitle() -> string
public function renderTitle(bool prepend = true, bool append = true) -> string
{
return "<title>" . this->getTitle() . "</title>" . PHP_EOL;
return "<title>" . this->getTitle(prepend, append) . "</title>" . PHP_EOL;
}

/**
Expand Down
9 changes: 6 additions & 3 deletions phalcon/tag.zep
Expand Up @@ -1220,16 +1220,19 @@ class Tag
* Tag::setTitle('World');
* Tag::appendTitle('from Phalcon');
*
* echo Tag::renderTitle(); // <title>Hello World From Phalcon</title>
* echo Tag::renderTitle(); // <title>Hello World from Phalcon</title>
* echo Tag::renderTitle(false); // <title>World from Phalcon</title>
* echo Tag::renderTitle(true, false); // <title>Hello World</title>
* echo Tag::renderTitle(false, false); // <title>World</title>
* </code>
*
* <code>
* {{ render_title() }}
* </code>
*/
public static function renderTitle() -> string
public static function renderTitle(bool prepend = true, bool append = true) -> string
{
return "<title>" . self::getTitle() . "</title>" . PHP_EOL;
return "<title>" . self::getTitle(prepend, append) . "</title>" . PHP_EOL;
}

/**
Expand Down
35 changes: 35 additions & 0 deletions tests/unit/Html/Tag/GetTitleCest.php
Expand Up @@ -69,4 +69,39 @@ public function htmlTagGetTitleEscape(UnitTester $I)
$actual = $tag->getTitle();
$I->assertEquals($expected, $actual);
}

/**
* Tests Phalcon\Html\Tag :: getTitle() - parameters
*
* @param UnitTester $I
*
* @since 2018-12-27
*/
public function htmlTagGetTitleParameters(UnitTester $I)
{
$I->wantToTest('Html\Tag - getTitle() - parameters');
$tag = new Tag();
$tag->setDI($this->container);
$tag->setTitleSeparator(' ');

$tag->prependTitle(['Hello'])
->setTitle('World')
->appendTitle(['from Phalcon']);

$expected = 'Hello World from Phalcon';
$actual = $tag->getTitle();
$I->assertEquals($expected, $actual);

$expected = 'World from Phalcon';
$actual = $tag->getTitle(false);
$I->assertEquals($expected, $actual);

$expected = 'Hello World';
$actual = $tag->getTitle(true, false);
$I->assertEquals($expected, $actual);

$expected = 'World';
$actual = $tag->getTitle(false, false);
$I->assertEquals($expected, $actual);
}
}
35 changes: 35 additions & 0 deletions tests/unit/Html/Tag/RenderTitleCest.php
Expand Up @@ -48,4 +48,39 @@ public function htmlTagRenderTitle(UnitTester $I)
$actual = $tag->renderTitle();
$I->assertEquals($expected, $actual);
}

/**
* Tests Phalcon\Html\Tag :: renderTitle() - parameters
*
* @param UnitTester $I
*
* @since 2018-12-27
*/
public function htmlTagRenderTitleParameters(UnitTester $I)
{
$I->wantToTest('Html\Tag - renderTitle() - parameters');
$tag = new Tag();
$tag->setDI($this->container);
$tag->setTitleSeparator(' ');

$tag->prependTitle(['Hello'])
->setTitle('World')
->appendTitle(['from Phalcon']);

$expected = '<title>Hello World from Phalcon</title>' . PHP_EOL;
$actual = $tag->renderTitle();
$I->assertEquals($expected, $actual);

$expected = '<title>World from Phalcon</title>' . PHP_EOL;
$actual = $tag->renderTitle(false);
$I->assertEquals($expected, $actual);

$expected = '<title>Hello World</title>' . PHP_EOL;
$actual = $tag->renderTitle(true, false);
$I->assertEquals($expected, $actual);

$expected = '<title>World</title>' . PHP_EOL;
$actual = $tag->renderTitle(false, false);
$I->assertEquals($expected, $actual);
}
}