Skip to content

Commit 30a94a8

Browse files
committed
Update docs
1 parent 6109772 commit 30a94a8

File tree

3 files changed

+21
-48
lines changed

3 files changed

+21
-48
lines changed

bundle/Resources/doc/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Netgen Open Graph Bundle changelog
22
==================================
33

4+
## 2.0.0 (24.04.2020)
5+
6+
* Added support for eZ Platform 3.x
7+
* Removed support for eZ Platform 1.x & 2.x
8+
* Scalar and return typehints are added to all classes and interfaces
9+
410
## 1.3.2 (09.08.2019)
511

612
* Support `ezrichtext` field type

bundle/Resources/doc/INSTALL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Netgen Open Graph Bundle installation instructions
44
Requirements
55
------------
66

7-
* eZ Platform 1.0+
7+
* eZ Platform 3+
88

99
Installation steps
1010
------------------
@@ -19,7 +19,7 @@ $ composer require netgen/open-graph-bundle
1919

2020
### Activate the bundle
2121

22-
Activate the `Netgen\Bundle\OpenGraphBundle\NetgenOpenGraphBundle` bundle in `app/AppKernel.php` file.
22+
Activate the `Netgen\Bundle\OpenGraphBundle\NetgenOpenGraphBundle` bundle in `config/bundles.php` file.
2323

2424
### Use the bundle
2525

bundle/Resources/doc/USAGE.md

Lines changed: 13 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ The following config:
145145
Will result in following meta tag:
146146

147147
```html
148-
<meta property="og:image" content="http://mysite.com/var/ezdemo_site/storage/images/portfolio/design-and-architecture/503-44-eng-EU/Design-and-Architecture_my_variation.png" />
148+
<meta property="og:image" content="https://mysite.com/var/ezdemo_site/storage/images/portfolio/design-and-architecture/503-44-eng-EU/Design-and-Architecture_my_variation.png" />
149149
```
150150

151151
In cases where `image` field is empty, meta tag will look like this:
152152

153153
```html
154-
<meta property="og:image" content="http://mysite.com/bundles/site/images/opengraph_default_image.png" />
154+
<meta property="og:image" content="https://mysite.com/bundles/site/images/opengraph_default_image.png" />
155155
```
156156

157157
## Implementing your own handlers
@@ -188,19 +188,14 @@ use Netgen\Bundle\OpenGraphBundle\MetaTag\Item;
188188
final class MyCustomHandler extends Handler
189189
{
190190
/**
191-
* Returns the array of meta tags
192-
*
193-
* @param string $tagName
194-
* @param array $params
195-
*
196191
* @return \Netgen\Bundle\OpenGraphBundle\MetaTag\Item[]
197192
*/
198-
public function getMetaTags( $tagName, array $params = array() )
193+
public function getMetaTags(string $tagName, array $params = []): array
199194
{
200195
$tagValue = ....;
201196
202197
return array(
203-
new Item( $tagName, $tagValue )
198+
new Item($tagName, $tagValue)
204199
);
205200
}
206201
}
@@ -221,14 +216,7 @@ In your handler, you need to at least implement `supports()` method, which defin
221216
supports, for example:
222217

223218
```php
224-
/**
225-
* Returns if this field type handler supports current field
226-
*
227-
* @param \eZ\Publish\API\Repository\Values\Content\Field $field
228-
*
229-
* @return bool
230-
*/
231-
protected function supports( Field $field )
219+
protected function supports(Field $field): bool
232220
{
233221
return $field->value instanceof \Vendor\Bundle\MyBundle\MyCustomFieldType\Value;
234222
}
@@ -239,25 +227,13 @@ which will cast the field value to string. If you require something more complic
239227
the method `getFieldValue()`. For example `XmlText` field type handler has the following implementation:
240228

241229
```php
242-
/**
243-
* Returns the field value, converted to string
244-
*
245-
* @param \eZ\Publish\API\Repository\Values\Content\Field $field
246-
* @param string $tagName
247-
* @param array $params
248-
*
249-
* @throws \Netgen\Bundle\OpenGraphBundle\Exception\FieldEmptyException If field is empty
250-
*
251-
* @return string
252-
*/
253-
protected function getFieldValue( Field $field, $tagName, array $params = array() )
230+
protected function getFieldValue(Field $field, string $tagName, array $params = []): string
254231
{
255-
if ( !$this->fieldHelper->isFieldEmpty( $this->content, $params[0] ) )
256-
{
257-
return trim( str_replace( "\n", " ", strip_tags( $field->value->xml->saveXML() ) ) );
232+
if (!$this->fieldHelper->isFieldEmpty($this->content, $params[0])) {
233+
return trim(str_replace("\n", " ", strip_tags($field->value->xml->saveXML())));
258234
}
259235
260-
throw new FieldEmptyException( $field->fieldDefIdentifier );
236+
throw new FieldEmptyException($field->fieldDefIdentifier);
261237
}
262238
```
263239

@@ -270,19 +246,10 @@ implemented `getFieldValue`, the default implementation of this method simply ca
270246
For example, `ezimage` field type handler has the following custom implementation:
271247

272248
```
273-
/**
274-
* Returns fallback value
275-
*
276-
* @param string $tagName
277-
* @param array $params
278-
*
279-
* @return string
280-
*/
281-
protected function getFallbackValue( $tagName, array $params = array() )
249+
protected function getFallbackValue(string $tagName, array $params = []): string
282250
{
283-
if ( !empty( $params[2] ) && ( $request = $this->requestStack->getCurrentRequest() ) !== null )
284-
{
285-
return $request->getUriForPath( '/' . ltrim( $params[2], '/' ) );
251+
if (!empty($params[2]) && ($request = $this->requestStack->getCurrentRequest()) !== null) {
252+
return $request->getUriForPath('/' . ltrim($params[2], '/'));
286253
}
287254
288255
return '';
@@ -305,4 +272,4 @@ Take care to specify the right parent for your handler type. If you're creating
305272
needs to be `netgen_open_graph.handler.abstract`. Alternatively, if you're developing a field type handler, you
306273
need to specify `netgen_open_graph.handler.field_type.abstract` as a parent.
307274

308-
[1]: https://doc.ez.no/display/EZP/How+to+expose+SiteAccess+aware+configuration+for+your+bundle
275+
[1]: https://doc.ezplatform.com/en/latest/guide/siteaccess/#exposing-siteaccess-aware-configuration-for-your-bundle

0 commit comments

Comments
 (0)