私はDoctrine 2を初めて使用し、注釈を使用してデータベースマッピングを行っています。もう少し進んで、いくつかのカスタム注釈を使用したいと思います。アノテーションで設定できるフォームなどを作れるようになることを目指しています。@Table などのクラスのアノテーションでさえ、パーサーから返されません。
Codeigniter 2 と Modular Extensions を使用しています。私のコントローラーには次のものがあります:
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$reader->setDefaultAnnotationNamespace('MyCompany\Annotations');
$reflClass = new ReflectionClass('models\User');
$classAnnotations = $reader->getClassAnnotations($reflClass);
print_r($classAnnotations);
空の配列を返します。
次に、libraries/annotations フォルダー Bar.php にファイルがあります。
namespace MyCompany\Annotations;
class Bar extends \Doctrine\Common\Annotations\Annotation
{
public $foo;
}
そして最後に、私のユーザーモデル:
/**
* @Entity
* @Table(name="user")
* @MyCompany\Annotations\Bar(foo="bar")
* @MyCompany\Annotations\Foo(bar="foo")
*/
class User {
}
私はこの例に従おうとしています: http://www.doctrine-project.org/projects/common/2.0/docs/reference/annotations/en#setup-and-configuration
事前にご協力いただきありがとうございます。
マーク。