@@ -145,13 +145,13 @@ The following config:
145145Will 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
151151In 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;
188188final 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 \N etgen\B undle\O penGraphBundle\M etaTag\I tem[]
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
221216supports, for example :
222217
223218` ` ` php
224- /**
225- * Returns if this field type handler supports current field
226- *
227- * @param \e Z\P ublish\A PI\R epository\V alues\C ontent\F ield $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 \V endor\B undle\M yBundle\M yCustomFieldType\V alue;
234222}
@@ -239,25 +227,13 @@ which will cast the field value to string. If you require something more complic
239227the 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 \e Z\P ublish\A PI\R epository\V alues\C ontent\F ield $field
246- * @param string $tagName
247- * @param array $params
248- *
249- * @throws \N etgen\B undle\O penGraphBundle\E xception\F ieldEmptyException 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
270246For 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
305272needs to be `netgen_open_graph.handler.abstract`. Alternatively, if you're developing a field type handler, you
306273need 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