Dcotrine custom annotation
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- awsickness
- Člen | 98
Zdravim rad bych se zeptal zda nekdo pouziva u doctrine custom
annotation.
Presneji receno potrebuji neco podobneho udelat
/** @Id @Column(type="integer")
* @GeneratedValue(strategy="IDENTITY")
*
*/
private $id;
/**
* @Column(length=50,unique="true")
* @rf:fooType
* @rf:barType
**/
private $title_cs;
jde mi proste o to ze potrebuji do annotace pridat vlastni polozky ktere pak
budu pres metadataclass kontrolovat.
zatim jsem ve stadiu kdy mam
class AnnotationsEntity extends Annotation{
}
pri vytvareni entity manageru pouzivam
\Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . '/../../libs/doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
foreach (Environment::getConfig('annotations')->mapping as $key => $value) {
\Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace($key,Environment::getVariable('appDir'));
}
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
$reader->setIgnoreNotImportedAnnotations(true);
$reader->setEnableParsePhpImports(false);
$reader = new \Doctrine\Common\Annotations\CachedReader(
new \Doctrine\Common\Annotations\IndexedReader($reader), new \Doctrine\Common\Cache\ArrayCache());
return $reader;
a driver
$reader = Environment::getService("Doctrine\Common\Annotations\AnnotationsReader");
$paths = array(
Environment::getVariable('appDir')."/Annotation/Forms",
Environment::getVariable('appDir')."/Annotation/Entity"
);
return new \refresh\Annotation\RefreshDriver($reader, $paths);
a ve vlastnim driveru mam zatim toto.
namespace Annotation;
use \Doctrine\ORM\Mapping\ClassMetadataInfo;
use \Doctrine\ORM\Mapping\Driver;
class RefreshDriver extends \Doctrine\ORM\Mapping\Driver\AnnotationDriver{
public function __construct($reader, $paths = null) {
parent::__construct($reader, $paths);
}
public function loadMetadataForClass($className, ClassMetadataInfo $metadata) {
parent::loadMetadataForClass($className, $metadata);
\Nette\Diagnostics\Debugger::dump($className);
if($metadata InstanceOf \Doctrine\ORM\Mapping\ClassMetadata){
}
}
a ted popravde receno moc netusim jak zjistit zda se mi opravdu nactou ty me
custom annotace.
proto zda mate nekdo zkusenosti prosim dejte radu jan na tohle.
Editoval awsickness (19. 8. 2011 10:49)