Details
-
Type:
Improvement
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2.0.0-BETA2
-
Component/s: None
-
Labels:None
Description
1) If our annotation doesn't need any parameters, it stll can accept one ('value').
2) We can intercept set and get of annotation properties via __set and __get methods which is not final, but not for 'value'.
Example of interception
class Annotation extends \Doctrine\Common\Annotations\Annotation
{
private $someProperty;
public function __set($name, $value)
{
$setMethod = 'set' . ucfirst($name);
if (method_exists($this, $setMethod)) {
return $this->{$setMethod}($value);
}
return parent::__set($name, $value);
}
public function __get($name)
{
$getMethod = 'get' . ucfirst($name);
if (method_exists($this, $getMethod)) {
return $this->{$getMethod}();
}
return parent::__get($name);
}
public function getSomeProperty()
{
//some logic
return $this->someProperty;
}
protected function setSomeProperty($someProperty)
{
//some logic
$this->someProperty = $someProperty;
}
}
Activity
Kirill chEbba Chebunin
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Description |
1) If our annotation doesn't need any parameters, it stll can accept one ('value'). 2) We can intercept set and get of annotation properties via __set and __get methods which is not final, but not for 'value'. Example of interception {{ class Annotation extends \Doctrine\Common\Annotations\Annotation { private $someProperty; public function __set($name, $value) { $setMethod = 'set' . ucfirst($name); if (method_exists($this, $setMethod)) { return $this->{$setMethod}($value); } return parent::__set($name, $value); } public function __get($name) { $getMethod = 'get' . ucfirst($name); if (method_exists($this, $getMethod)) { return $this->{$getMethod}(); } return parent::__get($name); } public function getSomeProperty() { //some logic return $this->someProperty; } protected function setSomeProperty($someProperty) { //some logic $this->someProperty = $someProperty; } } }} |
1) If our annotation doesn't need any parameters, it stll can accept one ('value'). 2) We can intercept set and get of annotation properties via __set and __get methods which is not final, but not for 'value'. Example of interception {{class Annotation extends \Doctrine\Common\Annotations\Annotation { private $someProperty; public function __set($name, $value) { $setMethod = 'set' . ucfirst($name); if (method_exists($this, $setMethod)) { return $this->{$setMethod}($value); } return parent::__set($name, $value); } public function __get($name) { $getMethod = 'get' . ucfirst($name); if (method_exists($this, $getMethod)) { return $this->{$getMethod}(); } return parent::__get($name); } public function getSomeProperty() { //some logic return $this->someProperty; } protected function setSomeProperty($someProperty) { //some logic $this->someProperty = $someProperty; } } }} |
Kirill chEbba Chebunin
made changes -
| Description |
1) If our annotation doesn't need any parameters, it stll can accept one ('value'). 2) We can intercept set and get of annotation properties via __set and __get methods which is not final, but not for 'value'. Example of interception {{class Annotation extends \Doctrine\Common\Annotations\Annotation { private $someProperty; public function __set($name, $value) { $setMethod = 'set' . ucfirst($name); if (method_exists($this, $setMethod)) { return $this->{$setMethod}($value); } return parent::__set($name, $value); } public function __get($name) { $getMethod = 'get' . ucfirst($name); if (method_exists($this, $getMethod)) { return $this->{$getMethod}(); } return parent::__get($name); } public function getSomeProperty() { //some logic return $this->someProperty; } protected function setSomeProperty($someProperty) { //some logic $this->someProperty = $someProperty; } } }} |
1) If our annotation doesn't need any parameters, it stll can accept one ('value'). 2) We can intercept set and get of annotation properties via __set and __get methods which is not final, but not for 'value'. Example of interception {noformat} class Annotation extends \Doctrine\Common\Annotations\Annotation { private $someProperty; public function __set($name, $value) { $setMethod = 'set' . ucfirst($name); if (method_exists($this, $setMethod)) { return $this->{$setMethod}($value); } return parent::__set($name, $value); } public function __get($name) { $getMethod = 'get' . ucfirst($name); if (method_exists($this, $getMethod)) { return $this->{$getMethod}(); } return parent::__get($name); } public function getSomeProperty() { //some logic return $this->someProperty; } protected function setSomeProperty($someProperty) { //some logic $this->someProperty = $someProperty; } } {noformat} |
Roman S. Borschel
made changes -
| Project | Doctrine 2 - ORM [ 10032 ] | Doctrine Common [ 10043 ] |
| Key | DDC-535 |
|
| Affects Version/s | 2.0-ALPHA4 [ 10036 ] | |
| Component/s | Common [ 10010 ] |
Roman S. Borschel
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 2.0.0-BETA2 [ 10061 ] | |
| Resolution | Fixed [ 1 ] |
Benjamin Eberlei
made changes -
| Workflow | jira [ 11255 ] | jira-feedback2 [ 17867 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback2 [ 17867 ] | jira-feedback3 [ 19830 ] |