Skip to content

Commit

Permalink
better deprecation handling for methods in SeoExtension (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarStark authored and greg0ire committed Jan 20, 2017
1 parent c288f7f commit 150f223
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
48 changes: 42 additions & 6 deletions Twig/Extension/SeoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ public function getName()
/**
* NEXT_MAJOR: remove this method.
*
* @deprecated Deprecated as of 1.2, echo the return value of getTitle() instead
* @deprecated since 2.0, to be removed in 3.0
*/
public function renderTitle()
{
@trigger_error(
'The '.__METHOD__.' method is deprecated since 2.0, to be removed in 3.0. '.
'Use '.__NAMESPACE__.'::getTitle() instead.',
E_USER_DEPRECATED
);

echo $this->getTitle();
}

Expand All @@ -80,10 +86,16 @@ public function getTitle()
/**
* NEXT_MAJOR: remove this method.
*
* @deprecated Deprecated as of 1.2, echo the return value of getMetadatas() instead
* @deprecated since 2.0, to be removed in 3.0
*/
public function renderMetadatas()
{
@trigger_error(
'The '.__METHOD__.' method is deprecated since 2.0, to be removed in 3.0. '.
'Use '.__NAMESPACE__.'::getMetadatas() instead.',
E_USER_DEPRECATED
);

echo $this->getMetadatas();
}

Expand Down Expand Up @@ -118,10 +130,16 @@ public function getMetadatas()
/**
* NEXT_MAJOR: remove this method.
*
* @deprecated Deprecated as of 1.2, echo the return value of getHtmlAttributes() instead
* @deprecated since 2.0, to be removed in 3.0
*/
public function renderHtmlAttributes()
{
@trigger_error(
'The '.__METHOD__.' method is deprecated since 2.0, to be removed in 3.0. '.
'Use '.__NAMESPACE__.'::getHtmlAttributes() instead.',
E_USER_DEPRECATED
);

echo $this->getHtmlAttributes();
}

Expand All @@ -141,10 +159,16 @@ public function getHtmlAttributes()
/**
* NEXT_MAJOR: remove this method.
*
* @deprecated Deprecated as of 1.2, echo the return value of getHeadAttributes() instead
* @deprecated since 2.0, to be removed in 3.0
*/
public function renderHeadAttributes()
{
@trigger_error(
'The '.__METHOD__.' method is deprecated since 2.0, to be removed in 3.0. '.
'Use '.__NAMESPACE__.'::getHeadAttributes() instead.',
E_USER_DEPRECATED
);

echo $this->getHeadAttributes();
}

Expand All @@ -164,10 +188,16 @@ public function getHeadAttributes()
/**
* NEXT_MAJOR: remove this method.
*
* @deprecated Deprecated as of 1.2, echo the return value of getLinkCanonical() instead
* @deprecated since 2.0, to be removed in 3.0
*/
public function renderLinkCanonical()
{
@trigger_error(
'The '.__METHOD__.' method is deprecated since 2.0, to be removed in 3.0. '.
'Use '.__NAMESPACE__.'::getLinkCanonical() instead.',
E_USER_DEPRECATED
);

echo $this->getLinkCanonical();
}

Expand All @@ -184,10 +214,16 @@ public function getLinkCanonical()
/**
* NEXT_MAJOR: remove this method.
*
* @deprecated Deprecated as of 1.2, echo the return value of getLangAlternates() instead
* @deprecated since 2.0, to be removed in 3.0
*/
public function renderLangAlternates()
{
@trigger_error(
'The '.__METHOD__.' method is deprecated since 2.0, to be removed in 3.0. '.
'Use '.__NAMESPACE__.'::getLangAlternates() instead.',
E_USER_DEPRECATED
);

echo $this->getLangAlternates();
}

Expand Down
11 changes: 11 additions & 0 deletions UPGRADE-2.x.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
UPGRADE 2.x
===========

### Deprecated methods in `Sonata\SeoBundle\Twig\Extension`

| deprecated method | recommended method |
|-------------------------|-----------------------------|
| `renderTitle()` | `getTitle()` |
| `renderMetadatas()` | `getMetadatas()` |
| `renderHtmlAttributes()` | `getHtmlAttributes()` |
| `renderHeadAttributes()` | `getHeadAttributes()` |
| `renderLinkCanonical()` | `getLinkCanonical()` |
| `renderLangAlternates()` | `getLangAlternates()` |

### Tests

All files under the ``Tests`` directory are now correctly handled as internal test classes.
Expand Down

0 comments on commit 150f223

Please sign in to comment.