2024-05-06 20:40:05 +00:00
|
|
|
---
|
2024-10-30 17:34:11 +00:00
|
|
|
date: 2020-11-16
|
2024-05-06 20:40:05 +00:00
|
|
|
id: 74ad0664-3103-429c-b9b7-15b1ea8e0c2c
|
|
|
|
title: "@Ignore"
|
|
|
|
---
|
|
|
|
|
|
|
|
# Description
|
|
|
|
|
|
|
|
Ignore values when serializing
|
|
|
|
|
|
|
|
# Syntax
|
|
|
|
|
|
|
|
``` php
|
|
|
|
use Symfony\Component\Serializer\Annotation\Ignore;
|
|
|
|
|
|
|
|
class SomeClass
|
|
|
|
{
|
|
|
|
public $someProperty;
|
|
|
|
/**
|
|
|
|
* @Ignore()
|
|
|
|
*/
|
|
|
|
public $anotherProperty;
|
|
|
|
private $lastProperty;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Ignore()
|
|
|
|
*/
|
|
|
|
public function getLastProperty()
|
|
|
|
{
|
|
|
|
return $this->lastProperty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
``` yaml
|
|
|
|
App\SomePath\SomeClas:
|
|
|
|
attributes:
|
|
|
|
# ...
|
|
|
|
anotherProperty:
|
|
|
|
ignore: true
|
|
|
|
lastProperty:
|
|
|
|
ignore: true
|
|
|
|
```
|
|
|
|
|
|
|
|
``` xml
|
|
|
|
<class name="App\SomePath\SomeClass">
|
|
|
|
<!-- ... -->
|
|
|
|
<attribute name="anotherProperty" ignore="true" />
|
|
|
|
<attribute name="lastProperty" ignore="true" />
|
|
|
|
</class>
|
|
|
|
```
|