Skip to content

Instantly share code, notes, and snippets.

@albe
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albe/77937e10cd2a86c12d09 to your computer and use it in GitHub Desktop.
Save albe/77937e10cd2a86c12d09 to your computer and use it in GitHub Desktop.
<?php
namespace Db\Benchmark\Domain\Model\Eav;
/* *
* This script belongs to the TYPO3 Flow package "Db.Benchmark". *
* *
* */
use Doctrine\Common\Collections;
use TYPO3\Flow\Annotations as Flow;
use Doctrine\ORM\Mapping as ORM;
/**
* An Entity which contains dynamic attributes via the EAV pattern.
*
* @ORM\MappedSuperclass
*/
abstract class AbstractEntity {
/**
* @var \Doctrine\Common\Collections\Collection<EntityAttribute>
* @ORM\ManyToMany(orphanRemoval=true, cascade={"ALL"}, indexBy="name")
* @ORM\JoinTable(inverseJoinColumns={@ORM\JoinColumn(unique=true)})
*/
protected $additionalAttributes;
public function __construct() {
$this->additionalAttributes = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Magic setter and getter implementation for Eav Entity Attributes
*
* @param string $method
* @param array $arguments
* @throws \InvalidArgumentException
* @return mixed
*/
public function __call($method, $arguments) {
...
}
}
?>
<?php
namespace Db\Benchmark\Domain\Model\Eav;
/* *
* This script belongs to the TYPO3 Flow package "Db.Benchmark". *
* *
* */
use TYPO3\Flow\Annotations as Flow;
use Doctrine\ORM\Mapping as ORM;
/**
* An entity attribute that can contain dynamic datatype values
*
* TODO: This should be an abstract mapped superclass instead
* @Flow\Entity
*/
class EntityAttribute {
/**
* The name
* @var string
* @ORM\Id
*/
protected $name;
/**
* The type
* @var string
* @ORM\Column(length=16)
*/
protected $type;
/**
* The value
* @var string
* @ORM\Column(type="text")
*/
protected $value;
/**
* @param string $name
* @param mixed $value
* @param string $type
* @throws \InvalidArgumentException
*/
public function __construct($name, $value, $type = NULL) {
..
}
..
}
?>
<?php
namespace Db\Benchmark\Domain\Model;
/* *
* This script belongs to the TYPO3 Flow package "Db.Benchmark". *
* *
* */
use TYPO3\Flow\Annotations as Flow;
use Doctrine\ORM\Mapping as ORM;
/**
* @Flow\Entity
*/
class EavEntity extends Eav\AbstractEntity {
.. some standard properties
}
@albe
Copy link
Author

albe commented Jun 5, 2014

With these annotations:
#1295973082: No class schema found for "Db\Benchmark\Domain\Model\Eav\AbstractEntity"

With @flow\Entity in Eav\AbstractEntity:
#1367592354: Method "Flow_Aop_Proxy_buildMethodsAndAdvicesArray" on class "Db\Benchmark\Domain\Model\EavEntity" is not defined.

@albe
Copy link
Author

albe commented Jun 5, 2014

@flow\Proxy(false) all classes (no AOP/DI needed):
Entity 'Db\Benchmark\Domain\Model\Eav\AbstractEntity' has no method 'Flow_Aop_Proxy_fixMethodsAndAdvicesArrayForDoctrineProxies' to be registered as lifecycle callback.

-> FlowAnnotationDriver always registers fix* lifecycle callbacks even when entity is unproxied, which is not needed, as the fixes only deal with AOP/DI behaviour, which is not expected to work on unproxied classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment