1459 lines
87 KiB
HTML
1459 lines
87 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|||
|
|
|||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|||
|
<head>
|
|||
|
|
|||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|||
|
|
|||
|
<title>Annotations Reference — Doctrine MongoDB ODM 1.1.5 documentation</title>
|
|||
|
<link rel="stylesheet" href="../_static/bootstrap/css/bootstrap.min.css" type="text/css" />
|
|||
|
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
|
|||
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|||
|
<link rel="stylesheet" href="../_static/layout.css" type="text/css" />
|
|||
|
<link rel="stylesheet" href="../_static/configurationblock.css" type="text/css" />
|
|||
|
<script type="text/javascript">
|
|||
|
var DOCUMENTATION_OPTIONS = {
|
|||
|
URL_ROOT: '../',
|
|||
|
VERSION: '1.1.5',
|
|||
|
COLLAPSE_MODINDEX: false,
|
|||
|
FILE_SUFFIX: '.html',
|
|||
|
HAS_SOURCE: true
|
|||
|
};
|
|||
|
</script>
|
|||
|
|
|||
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|||
|
<script type="text/javascript" src="../_static/configurationblock.js"></script>
|
|||
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|||
|
<script type="text/javascript" src="../_static/configurationblock.js"></script>
|
|||
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|||
|
<script type="text/javascript" src="../_static/configurationblock.js"></script>
|
|||
|
<script src="../_static/bootstrap/js/bootstrap.min.js"></script>
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
<!--
|
|||
|
$(document).ready(function() {
|
|||
|
$("#versions").change(function() {
|
|||
|
var docsUrl = $(this).val();
|
|||
|
window.location.href = docsUrl;
|
|||
|
});
|
|||
|
});
|
|||
|
-->
|
|||
|
</script>
|
|||
|
<link rel="shortcut icon" href="../_static/doctrine.ico"/>
|
|||
|
<link rel="search" title="Search" href="../search.html" />
|
|||
|
<link rel="top" title="Doctrine MongoDB ODM 1.1.5 documentation" href="../index.html" />
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<div id="wrapper">
|
|||
|
<div id="header">
|
|||
|
<h1 id="h1title"></h1>
|
|||
|
<div id="logo">
|
|||
|
<a href="http://www.doctrine-project.org/">Doctrine - PHP Database Libraries</a>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div id="nav" class="cls">
|
|||
|
<div class="tl cls">
|
|||
|
<ul>
|
|||
|
<li><a target="_top" href="http://www.doctrine-project.org/">Home</a></li>
|
|||
|
<li><a target="_top" href="http://www.doctrine-project.org/about.html">About</a></li>
|
|||
|
<li><a target="_top" href="http://www.doctrine-project.org/projects.html">Projects</a></li>
|
|||
|
<li><a target="_top" href="http://www.doctrine-project.org/contribute.html">Contribute</a></li>
|
|||
|
<li><a target="_top" href="http://www.doctrine-project.org/community.html">Community</a></li>
|
|||
|
<li><a target="_top" href="http://www.doctrine-project.org/archive.html">Blog</a></li>
|
|||
|
<li><a target="_top" href="http://www.doctrine-project.org/jira">Development</a></li>
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div id="content" class="cls">
|
|||
|
<div class="related">
|
|||
|
<h3>Navigation</h3>
|
|||
|
<ul>
|
|||
|
<li><a href="/">Doctrine Homepage</a> »</li>
|
|||
|
<li><a href="../index.html">Doctrine MongoDB ODM 1.1.5 documentation</a> »</li>
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="document">
|
|||
|
<div class="documentwrapper">
|
|||
|
<div class="bodywrapper">
|
|||
|
|
|||
|
<div class="body" >
|
|||
|
|
|||
|
<div class="section" id="annotations-reference">
|
|||
|
<h1>Annotations Reference<a class="headerlink" href="#annotations-reference" title="Permalink to this headline">¶</a></h1>
|
|||
|
<p>In this chapter a reference of every Doctrine 2 ODM Annotation is
|
|||
|
given with short explanations on their context and usage.</p>
|
|||
|
<div class="section" id="alsoload">
|
|||
|
<h2>@AlsoLoad<a class="headerlink" href="#alsoload" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Specify one or more MongoDB fields to use for loading data if the original field
|
|||
|
does not exist.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Field(type="string") @AlsoLoad("name") */</span>
|
|||
|
<span class="k">public</span> <span class="nv">$fullName</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>The <code class="docutils literal"><span class="pre">$fullName</span></code> property will be loaded from <code class="docutils literal"><span class="pre">fullName</span></code> if it exists, but
|
|||
|
fall back to <code class="docutils literal"><span class="pre">name</span></code> if it does not exist. If multiple fall back fields are
|
|||
|
specified, ODM will consider them in order until the first is found.</p>
|
|||
|
<p>Additionally, <a class="reference internal" href="#alsoload">@AlsoLoad</a> may annotate a method with one or more field names.
|
|||
|
Before normal hydration, the field(s) will be considered in order and the method
|
|||
|
will be invoked with the first value found as its single argument.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @AlsoLoad({"name", "fullName"}) */</span>
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">populateFirstAndLastName</span><span class="p">(</span><span class="nv">$name</span><span class="p">)</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="k">list</span><span class="p">(</span><span class="nv">$this</span><span class="o">-></span><span class="na">firstName</span><span class="p">,</span> <span class="nv">$this</span><span class="o">-></span><span class="na">lastName</span><span class="p">)</span> <span class="o">=</span> <span class="nb">explode</span><span class="p">(</span><span class="s1">' '</span><span class="p">,</span> <span class="nv">$name</span><span class="p">);</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>For additional information on using <a class="reference internal" href="#alsoload">@AlsoLoad</a>, see
|
|||
|
<a class="reference internal" href="migrating-schemas.html"><span class="doc">Migrations</span></a>.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="bin">
|
|||
|
<h2>@Bin<a class="headerlink" href="#bin" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "bin". Converts value to
|
|||
|
<a class="reference external" href="http://php.net/manual/en/class.mongobindata.php">MongoBinData</a> with <code class="docutils literal"><span class="pre">MongoBinData::GENERIC</span></code> sub-type.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Bin */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$data</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "bin".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="bincustom">
|
|||
|
<h2>@BinCustom<a class="headerlink" href="#bincustom" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "bin_custom". Converts
|
|||
|
value to <a class="reference external" href="http://php.net/manual/en/class.mongobindata.php">MongoBinData</a> with <code class="docutils literal"><span class="pre">MongoBinData::CUSTOM</span></code> sub-type.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @BinCustom */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$data</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "bin_custom".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="binfunc">
|
|||
|
<h2>@BinFunc<a class="headerlink" href="#binfunc" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "bin_func". Converts value to
|
|||
|
<a class="reference external" href="http://php.net/manual/en/class.mongobindata.php">MongoBinData</a> with <code class="docutils literal"><span class="pre">MongoBinData::FUNC</span></code> sub-type.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @BinFunc */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$data</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "bin_func".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="binmd5">
|
|||
|
<h2>@BinMD5<a class="headerlink" href="#binmd5" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "bin_md5". Converts value to
|
|||
|
<a class="reference external" href="http://php.net/manual/en/class.mongobindata.php">MongoBinData</a> with <code class="docutils literal"><span class="pre">MongoBinData::MD5</span></code> sub-type.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @BinMD5 */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$password</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "bin_md5".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="binuuid">
|
|||
|
<h2>@BinUUID<a class="headerlink" href="#binuuid" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "bin_uuid". Converts value to
|
|||
|
<a class="reference external" href="http://php.net/manual/en/class.mongobindata.php">MongoBinData</a> with <code class="docutils literal"><span class="pre">MongoBinData::UUID</span></code> sub-type.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @BinUUID */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$uuid</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">Per the <a class="reference external" href="http://bsonspec.org/spec.html">BSON specification</a>, this sub-type is deprecated in favor of the
|
|||
|
RFC 4122 UUID sub-type. Consider using <a class="reference internal" href="#binuuidrfc4122">@BinUUIDRFC4122</a> instead.</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="binuuidrfc4122">
|
|||
|
<h2>@BinUUIDRFC4122<a class="headerlink" href="#binuuidrfc4122" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "bin_uuid_rfc4122". Converts
|
|||
|
value to <a class="reference external" href="http://php.net/manual/en/class.mongobindata.php">MongoBinData</a> with <code class="docutils literal"><span class="pre">MongoBinData::UUID_RFC4122</span></code> sub-type.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @BinUUIDRFC4122 */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$uuid</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">RFC 4122 UUIDs must be 16 bytes. The PHP driver will throw an exception if
|
|||
|
the binary data's size is invalid.</p>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "bin_uuid_rfc4122".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="bool">
|
|||
|
<h2>@Bool<a class="headerlink" href="#bool" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "bool". Internally it uses
|
|||
|
exactly same logic as <a class="reference internal" href="#boolean">@Boolean</a> annotation and "boolean" type.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Bool */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$active</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated because it uses a keyword that was reserved in
|
|||
|
PHP 7. It will be removed in ODM 2.0. Please use the <a class="reference internal" href="#field">@Field</a> annotation
|
|||
|
with type "bool".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="boolean">
|
|||
|
<h2>@Boolean<a class="headerlink" href="#boolean" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "boolean".</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Boolean */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$active</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "bool".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="changetrackingpolicy">
|
|||
|
<h2>@ChangeTrackingPolicy<a class="headerlink" href="#changetrackingpolicy" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>This annotation is used to change the change tracking policy for a document:</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Document</span>
|
|||
|
<span class="sd"> * @ChangeTrackingPolicy("DEFERRED_EXPLICIT")</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Person</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>For a list of available policies, read the section on <a class="reference internal" href="change-tracking-policies.html#change-tracking-policies"><span class="std std-ref">change tracking policies</span></a>.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="collection">
|
|||
|
<h2>@Collection<a class="headerlink" href="#collection" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "collection". Stores and
|
|||
|
retrieves the value as a numerically indexed array.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Collection */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$tags</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "collection".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="date">
|
|||
|
<h2>@Date<a class="headerlink" href="#date" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "date". Values of any type
|
|||
|
(e.g. integer, string, DateTime) will be converted to <a class="reference external" href="http://php.net/manual/en/class.mongodate.php">MongoDate</a> for storage
|
|||
|
in MongoDB. The property will be a DateTime when loaded from the database.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Date */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$createdAt</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "date".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="defaultdiscriminatorvalue">
|
|||
|
<h2>@DefaultDiscriminatorValue<a class="headerlink" href="#defaultdiscriminatorvalue" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>This annotation can be used when using <a class="reference internal" href="#discriminatorfield">@DiscriminatorField</a>. It will be used
|
|||
|
as a fallback value if a document has no discriminator field set. This must
|
|||
|
correspond to a value from the configured discriminator map.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Document</span>
|
|||
|
<span class="sd"> * @InheritanceType("SINGLE_COLLECTION")</span>
|
|||
|
<span class="sd"> * @DiscriminatorField("type")</span>
|
|||
|
<span class="sd"> * @DiscriminatorMap({"person" = "Person", "employee" = "Employee"})</span>
|
|||
|
<span class="sd"> * @DefaultDiscriminatorValue("person")</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Person</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="discriminatorfield">
|
|||
|
<h2>@DiscriminatorField<a class="headerlink" href="#discriminatorfield" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>This annotation is required for the top-most class in a
|
|||
|
<a class="reference internal" href="inheritance-mapping.html#single-collection-inheritance"><span class="std std-ref">single collection inheritance</span></a> hierarchy.
|
|||
|
It takes a string as its only argument, which specifies the database field to
|
|||
|
store a class name or key (if a discriminator map is used). ODM uses this field
|
|||
|
during hydration to select the instantiation class.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Document</span>
|
|||
|
<span class="sd"> * @InheritanceType("SINGLE_COLLECTION")</span>
|
|||
|
<span class="sd"> * @DiscriminatorField("type")</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">class</span> <span class="nc">SuperUser</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">For backwards compatibility, the discriminator field may also be specified
|
|||
|
via either the <code class="docutils literal"><span class="pre">name</span></code> or <code class="docutils literal"><span class="pre">fieldName</span></code> annotation attributes.</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="discriminatormap">
|
|||
|
<h2>@DiscriminatorMap<a class="headerlink" href="#discriminatormap" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>This annotation is required for the top-most class in a
|
|||
|
<a class="reference internal" href="inheritance-mapping.html#single-collection-inheritance"><span class="std std-ref">single collection inheritance</span></a> hierarchy.
|
|||
|
It takes an array as its only argument, which maps keys to class names. The
|
|||
|
class names may be fully qualified or relative to the current namespace. When
|
|||
|
a document is persisted to the database, its class name key will be stored in
|
|||
|
the discriminator field instead of the <a href="#id2"><span class="problematic" id="id3">|FQCN|</span></a>.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Document</span>
|
|||
|
<span class="sd"> * @InheritanceType("SINGLE_COLLECTION")</span>
|
|||
|
<span class="sd"> * @DiscriminatorField("type")</span>
|
|||
|
<span class="sd"> * @DiscriminatorMap({"person" = "Person", "employee" = "Employee"})</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Person</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="distance">
|
|||
|
<span id="annotation-distance"></span><h2>@Distance<a class="headerlink" href="#distance" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>This annotation can be used in combination with geospatial indexes and the
|
|||
|
<a class="reference internal" href="geospatial-queries.html#geonear"><span class="std std-ref">geoNear()</span></a> query method to populate the property with the
|
|||
|
calculated distance value.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Document</span>
|
|||
|
<span class="sd"> * @Index(keys={"coordinates"="2d"})</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Place</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="sd">/** @Id */</span>
|
|||
|
<span class="k">public</span> <span class="nv">$id</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="sd">/** @EmbedOne(targetDocument="Coordinates") */</span>
|
|||
|
<span class="k">public</span> <span class="nv">$coordinates</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="sd">/** @Distance */</span>
|
|||
|
<span class="k">public</span> <span class="nv">$distance</span><span class="p">;</span>
|
|||
|
<span class="p">}</span>
|
|||
|
|
|||
|
<span class="sd">/** @EmbeddedDocument */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Coordinates</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="sd">/** @Field(type="float") */</span>
|
|||
|
<span class="k">public</span> <span class="nv">$latitude</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="sd">/** @Field(type="float") */</span>
|
|||
|
<span class="k">public</span> <span class="nv">$longitude</span><span class="p">;</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>Now you can run a <a class="reference external" href="https://docs.mongodb.com/manual/reference/command/geoNear/">geoNear command</a> and access the computed distance. The
|
|||
|
following example would return the distance of the city nearest the query
|
|||
|
coordinates:</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="nv">$city</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">dm</span><span class="o">-></span><span class="na">createQuery</span><span class="p">(</span><span class="s1">'City'</span><span class="p">)</span>
|
|||
|
<span class="o">-></span><span class="na">geoNear</span><span class="p">(</span><span class="mi">50</span><span class="p">,</span> <span class="mi">60</span><span class="p">)</span>
|
|||
|
<span class="o">-></span><span class="na">limit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
|||
|
<span class="o">-></span><span class="na">getQuery</span><span class="p">()</span>
|
|||
|
<span class="o">-></span><span class="na">getSingleResult</span><span class="p">();</span>
|
|||
|
<span class="k">echo</span> <span class="nv">$city</span><span class="o">-></span><span class="na">distance</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="document">
|
|||
|
<h2>@Document<a class="headerlink" href="#document" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Required annotation to mark a PHP class as a document, whose peristence will be
|
|||
|
managed by ODM.</p>
|
|||
|
<p>Optional attributes:</p>
|
|||
|
<ul class="simple">
|
|||
|
<li>db - By default, the document manager will use the MongoDB database defined
|
|||
|
in the configuration, but this option may be used to override the database
|
|||
|
for a particular document class.</li>
|
|||
|
<li>collection - By default, the collection name is derived from the document's
|
|||
|
class name, but this option may be used to override that behavior.</li>
|
|||
|
<li>repositoryClass - Specifies a custom repository class to use.</li>
|
|||
|
<li>indexes - Specifies an array of indexes for this document.</li>
|
|||
|
<li>readOnly - Prevents document from being updated: it can only be inserted,
|
|||
|
upserted or removed.</li>
|
|||
|
<li>requireIndexes - Specifies whether or not queries for this document should
|
|||
|
require indexes by default. This may also be specified per query.</li>
|
|||
|
<li>writeConcern - Specifies the write concern for this document that overwrites
|
|||
|
the default write concern specified in the configuration. It does not overwrite
|
|||
|
a write concern given as <a class="reference internal" href="working-with-objects.html#flush-options"><span class="std std-ref">option</span></a> to the <code class="docutils literal"><span class="pre">flush</span></code>
|
|||
|
method when committing your documents.</li>
|
|||
|
</ul>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Document(</span>
|
|||
|
<span class="sd"> * db="documents",</span>
|
|||
|
<span class="sd"> * collection="users",</span>
|
|||
|
<span class="sd"> * repositoryClass="MyProject\UserRepository",</span>
|
|||
|
<span class="sd"> * indexes={</span>
|
|||
|
<span class="sd"> * @Index(keys={"username"="desc"}, options={"unique"=true})</span>
|
|||
|
<span class="sd"> * },</span>
|
|||
|
<span class="sd"> * readOnly=true,</span>
|
|||
|
<span class="sd"> * requireIndexes=true</span>
|
|||
|
<span class="sd"> * )</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">class</span> <span class="nc">User</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">//...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">Requiring Indexes was deprecated in 1.2 and will be removed in 2.0.</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="embedmany">
|
|||
|
<h2>@EmbedMany<a class="headerlink" href="#embedmany" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>This annotation is similar to <a class="reference internal" href="#embedone">@EmbedOne</a>, but instead of embedding one
|
|||
|
document, it embeds a collection of documents.</p>
|
|||
|
<p>Optional attributes:</p>
|
|||
|
<ul class="simple">
|
|||
|
<li>targetDocument - A <a href="#id4"><span class="problematic" id="id5">|FQCN|</span></a> of the target document.</li>
|
|||
|
<li>discriminatorField - The database field name to store the discriminator
|
|||
|
value within the embedded document.</li>
|
|||
|
<li>discriminatorMap - Map of discriminator values to class names.</li>
|
|||
|
<li>defaultDiscriminatorValue - A default value for discriminatorField if no value
|
|||
|
has been set in the embedded document.</li>
|
|||
|
<li>strategy - The strategy used to persist changes to the collection. Possible
|
|||
|
values are <code class="docutils literal"><span class="pre">addToSet</span></code>, <code class="docutils literal"><span class="pre">pushAll</span></code>, <code class="docutils literal"><span class="pre">set</span></code>, and <code class="docutils literal"><span class="pre">setArray</span></code>. <code class="docutils literal"><span class="pre">pushAll</span></code>
|
|||
|
is the default. See <a class="reference internal" href="storage-strategies.html#storage-strategies"><span class="std std-ref">Storage Strategies</span></a> for more information.</li>
|
|||
|
<li>collectionClass - A <a href="#id6"><span class="problematic" id="id7">|FQCN|</span></a> of class that implements <code class="docutils literal"><span class="pre">Collection</span></code> interface
|
|||
|
and is used to hold documents. Doctrine's <code class="docutils literal"><span class="pre">ArrayCollection</span></code> is used by default.</li>
|
|||
|
</ul>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @EmbedMany(</span>
|
|||
|
<span class="sd"> * strategy="set",</span>
|
|||
|
<span class="sd"> * discriminatorField="type",</span>
|
|||
|
<span class="sd"> * discriminatorMap={</span>
|
|||
|
<span class="sd"> * "book"="Documents\BookTag",</span>
|
|||
|
<span class="sd"> * "song"="Documents\SongTag"</span>
|
|||
|
<span class="sd"> * },</span>
|
|||
|
<span class="sd"> * defaultDiscriminatorValue="book"</span>
|
|||
|
<span class="sd"> * )</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$tags</span> <span class="o">=</span> <span class="k">array</span><span class="p">();</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>Depending on the embedded document's class, a value of <code class="docutils literal"><span class="pre">user</span></code> or <code class="docutils literal"><span class="pre">author</span></code>
|
|||
|
will be stored in the <code class="docutils literal"><span class="pre">type</span></code> field and used to reconstruct the proper class
|
|||
|
during hydration. The <code class="docutils literal"><span class="pre">type</span></code> field need not be mapped on the embedded
|
|||
|
document classes.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="embedone">
|
|||
|
<h2>@EmbedOne<a class="headerlink" href="#embedone" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>The <a class="reference internal" href="#embedone">@EmbedOne</a> annotation works similarly to <a class="reference internal" href="#referenceone">@ReferenceOne</a>, except that
|
|||
|
that document will be embedded within the parent document. Consider the
|
|||
|
following excerpt from the MongoDB documentation:</p>
|
|||
|
<blockquote>
|
|||
|
<div>The key question in MongoDB schema design is "does this object merit its own
|
|||
|
collection, or rather should it be embedded within objects in other
|
|||
|
collections?" In relational databases, each sub-item of interest typically
|
|||
|
becomes a separate table (unless you are denormalizing for performance). In
|
|||
|
MongoDB, this is not recommended – embedding objects is much more efficient.
|
|||
|
Data is then collocated on disk; client-server turnarounds to the database
|
|||
|
are eliminated. So in general, the question to ask is, "why would I not want
|
|||
|
to embed this object?"</div></blockquote>
|
|||
|
<p>Optional attributes:</p>
|
|||
|
<ul class="simple">
|
|||
|
<li>targetDocument - A <a href="#id8"><span class="problematic" id="id9">|FQCN|</span></a> of the target document.</li>
|
|||
|
<li>discriminatorField - The database field name to store the discriminator
|
|||
|
value within the embedded document.</li>
|
|||
|
<li>discriminatorMap - Map of discriminator values to class names.</li>
|
|||
|
<li>defaultDiscriminatorValue - A default value for discriminatorField if no value
|
|||
|
has been set in the embedded document.</li>
|
|||
|
</ul>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @EmbedOne(</span>
|
|||
|
<span class="sd"> * discriminatorField="type",</span>
|
|||
|
<span class="sd"> * discriminatorMap={</span>
|
|||
|
<span class="sd"> * "user"="Documents\User",</span>
|
|||
|
<span class="sd"> * "author"="Documents\Author"</span>
|
|||
|
<span class="sd"> * },</span>
|
|||
|
<span class="sd"> * defaultDiscriminatorValue="user"</span>
|
|||
|
<span class="sd"> * )</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$creator</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>Depending on the embedded document's class, a value of <code class="docutils literal"><span class="pre">user</span></code> or <code class="docutils literal"><span class="pre">author</span></code>
|
|||
|
will be stored in the <code class="docutils literal"><span class="pre">type</span></code> field and used to reconstruct the proper class
|
|||
|
during hydration. The <code class="docutils literal"><span class="pre">type</span></code> field need not be mapped on the embedded
|
|||
|
document classes.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="embeddeddocument">
|
|||
|
<h2>@EmbeddedDocument<a class="headerlink" href="#embeddeddocument" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Marks the document as embeddable. This annotation is required for any documents
|
|||
|
to be stored within an <a class="reference internal" href="#embedone">@EmbedOne</a> or <a class="reference internal" href="#embedmany">@EmbedMany</a> relationship.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @EmbeddedDocument */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Money</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="sd">/** @Field(type="float") */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$amount</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">__construct</span><span class="p">(</span><span class="nv">$amount</span><span class="p">)</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="nv">$this</span><span class="o">-></span><span class="na">amount</span> <span class="o">=</span> <span class="p">(</span><span class="nx">float</span><span class="p">)</span> <span class="nv">$amount</span><span class="p">;</span>
|
|||
|
<span class="p">}</span>
|
|||
|
<span class="c1">//...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
|
|||
|
<span class="sd">/** @Document(db="finance", collection="wallets") */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Wallet</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="sd">/** @EmbedOne(targetDocument="Money") */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$money</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">setMoney</span><span class="p">(</span><span class="nx">Money</span> <span class="nv">$money</span><span class="p">)</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="nv">$this</span><span class="o">-></span><span class="na">money</span> <span class="o">=</span> <span class="nv">$money</span><span class="p">;</span>
|
|||
|
<span class="p">}</span>
|
|||
|
<span class="c1">//...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
<span class="c1">//...</span>
|
|||
|
<span class="nv">$wallet</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Wallet</span><span class="p">();</span>
|
|||
|
<span class="nv">$wallet</span><span class="o">-></span><span class="na">setMoney</span><span class="p">(</span><span class="k">new</span> <span class="nx">Money</span><span class="p">(</span><span class="mf">34.39</span><span class="p">));</span>
|
|||
|
<span class="nv">$dm</span><span class="o">-></span><span class="na">persist</span><span class="p">(</span><span class="nv">$wallet</span><span class="p">);</span>
|
|||
|
<span class="nv">$dm</span><span class="o">-></span><span class="na">flush</span><span class="p">();</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>Unlike normal documents, embedded documents cannot specify their own database or
|
|||
|
collection. That said, a single embedded document class may be used with
|
|||
|
multiple document classes, and even other embedded documents!</p>
|
|||
|
<p>Optional attributes:</p>
|
|||
|
<ul class="simple">
|
|||
|
<li>indexes - Specifies an array of indexes for this embedded document, to be
|
|||
|
included in the schemas of any embedding documents.</li>
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
<div class="section" id="field">
|
|||
|
<h2>@Field<a class="headerlink" href="#field" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Marks an annotated instance variable for persistence. Values for this field will
|
|||
|
be saved to and loaded from the document store as part of the document class'
|
|||
|
lifecycle.</p>
|
|||
|
<p>Optional attributes:</p>
|
|||
|
<ul class="simple">
|
|||
|
<li>type - Name of the ODM type, which will determine the value's representation
|
|||
|
in PHP and BSON (i.e. MongoDB). See <a class="reference internal" href="basic-mapping.html#doctrine-mapping-types"><span class="std std-ref">Doctrine Mapping Types</span></a> for a list
|
|||
|
of types. Defaults to "string".</li>
|
|||
|
<li>name - By default, the property name is used for the field name in MongoDB;
|
|||
|
however, this option may be used to specify a database field name.</li>
|
|||
|
<li>nullable - By default, ODM will <code class="docutils literal"><span class="pre">$unset</span></code> fields in MongoDB if the PHP value
|
|||
|
is null. Specify true for this option to force ODM to store a null value in
|
|||
|
the database instead of unsetting the field.</li>
|
|||
|
</ul>
|
|||
|
<p>Examples:</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Field(type="string")</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">protected</span> <span class="nv">$username</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Field(type="string", name="co")</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">protected</span> <span class="nv">$country</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Field(type="float")</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">protected</span> <span class="nv">$height</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="file">
|
|||
|
<h2>@File<a class="headerlink" href="#file" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Marks an annotated instance variable as a file. Additionally, this instructs ODM
|
|||
|
to store the entire document in <a class="reference external" href="https://docs.mongodb.com/manual/core/gridfs/">GridFS</a>. Only a single field in a document may
|
|||
|
be mapped as a file.</p>
|
|||
|
<p>The instance variable will be an <code class="docutils literal"><span class="pre">Doctrine\MongoDB\GridFSFile</span></code> object, which
|
|||
|
is a wrapper class for <a class="reference external" href="http://php.net/manual/en/class.mongogridfsfile.php">MongoGridFSFile</a> and facilitates access to the file
|
|||
|
data in GridFS. If the variable is a file path string when the document is first
|
|||
|
persisted, ODM will convert it to GridFSFile object automatically.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @File */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$file</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>Additional fields can be mapped in GridFS documents like any other, but metadata
|
|||
|
fields set by the driver (e.g. <code class="docutils literal"><span class="pre">length</span></code>) should be mapped with <a class="reference internal" href="#notsaved">@NotSaved</a> so
|
|||
|
as not to inadvertently overwrite them. Some metadata fields, such as
|
|||
|
<code class="docutils literal"><span class="pre">filename</span></code> may be modified and do not require <a class="reference internal" href="#notsaved">@NotSaved</a>. In the following
|
|||
|
example, we also add a custom field to refer to the corresponding User document
|
|||
|
that created the file.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Field(type="string") */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$filename</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="sd">/** @NotSaved(type="int") */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$length</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="sd">/** @NotSaved(type="string") */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$md5</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="sd">/** @NotSaved(type="date") */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$uploadDate</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="sd">/** @ReferenceOne(targetDocument="Documents\User") */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$uploadedBy</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="float">
|
|||
|
<h2>@Float<a class="headerlink" href="#float" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "float".</p>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated because it uses a keyword that was reserved in
|
|||
|
PHP 7. It will be removed in ODM 2.0. Please use the <a class="reference internal" href="#field">@Field</a> annotation
|
|||
|
with type "float".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="haslifecyclecallbacks">
|
|||
|
<span id="id1"></span><h2>@HasLifecycleCallbacks<a class="headerlink" href="#haslifecyclecallbacks" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>This annotation must be set on the document class to instruct Doctrine to check
|
|||
|
for lifecycle callback annotations on public methods. Using <a class="reference internal" href="#preflush">@PreFlush</a>,
|
|||
|
<a class="reference internal" href="#preload">@PreLoad</a>, <a class="reference internal" href="#postload">@PostLoad</a>, <a class="reference internal" href="#prepersist">@PrePersist</a>, <a class="reference internal" href="#postpersist">@PostPersist</a>, <a class="reference internal" href="#preremove">@PreRemove</a>,
|
|||
|
<a class="reference internal" href="#postremove">@PostRemove</a>, <a class="reference internal" href="#preupdate">@PreUpdate</a>, or <a class="reference internal" href="#postupdate">@PostUpdate</a> on methods without this
|
|||
|
annotation will cause Doctrine to ignore the callbacks.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Document @HasLifecycleCallbacks */</span>
|
|||
|
<span class="k">class</span> <span class="nc">User</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="sd">/** @PostPersist */</span>
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">sendWelcomeEmail</span><span class="p">()</span> <span class="p">{}</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="hash">
|
|||
|
<h2>@Hash<a class="headerlink" href="#hash" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "hash". Stores and retrieves
|
|||
|
the value as an associative array.</p>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "hash".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="id">
|
|||
|
<h2>@Id<a class="headerlink" href="#id" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>The annotated instance variable will be marked as the document identifier. The
|
|||
|
default behavior is to store a <a class="reference external" href="http://php.net/manual/en/class.mongoid.php">MongoId</a> instance, but you may customize this
|
|||
|
via the <a class="reference internal" href="basic-mapping.html#basic-mapping-identifiers"><span class="std std-ref">strategy</span></a> attribute.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Document */</span>
|
|||
|
<span class="k">class</span> <span class="nc">User</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="sd">/** @Id */</span>
|
|||
|
<span class="k">protected</span> <span class="nv">$id</span><span class="p">;</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="increment">
|
|||
|
<h2>@Increment<a class="headerlink" href="#increment" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>The increment type is just like an integer field, except that it will be updated
|
|||
|
using the <code class="docutils literal"><span class="pre">$inc</span></code> operator instead of <code class="docutils literal"><span class="pre">$set</span></code>:</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="k">class</span> <span class="nc">Package</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="sd">/** @Increment */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$downloads</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">incrementDownloads</span><span class="p">()</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="nv">$this</span><span class="o">-></span><span class="na">downloads</span><span class="o">++</span><span class="p">;</span>
|
|||
|
<span class="p">}</span>
|
|||
|
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>Now, update a Package instance like so:</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="nv">$package</span><span class="o">-></span><span class="na">incrementDownloads</span><span class="p">();</span>
|
|||
|
<span class="nv">$dm</span><span class="o">-></span><span class="na">flush</span><span class="p">();</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>The query sent to Mongo would resemble the following:</p>
|
|||
|
<div class="highlight-json"><div class="highlight"><pre><span class="p">{</span> <span class="nt">"$inc"</span><span class="p">:</span> <span class="p">{</span> <span class="nt">"downloads"</span><span class="p">:</span> <span class="mi">1</span> <span class="p">}</span> <span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>The field will be incremented by the difference between the new and old values.
|
|||
|
This is useful if many requests are attempting to update the field concurrently.</p>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "int" or "float" and use the "increment"
|
|||
|
strategy.</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="index">
|
|||
|
<h2>@Index<a class="headerlink" href="#index" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>This annotation is used inside of the class-level <a class="reference internal" href="#document">@Document</a> or
|
|||
|
<a class="reference internal" href="#embeddeddocument">@EmbeddedDocument</a> annotations to specify indexes to be created on the
|
|||
|
collection (or embedding document's collection in the case of
|
|||
|
<a class="reference internal" href="#embeddeddocument">@EmbeddedDocument</a>). It may also be used at the property-level to define
|
|||
|
single-field indexes.</p>
|
|||
|
<p>Optional attributes:</p>
|
|||
|
<ul class="simple">
|
|||
|
<li>keys - Mapping of indexed fields to their ordering or index type. ODM will
|
|||
|
allow "asc" and "desc" to be used in place of <code class="docutils literal"><span class="pre">1</span></code> and <code class="docutils literal"><span class="pre">-1</span></code>,
|
|||
|
respectively. Special index types (e.g. "2dsphere") should be specified as
|
|||
|
strings. This is required when <a class="reference internal" href="#index">@Index</a> is used at the class level.</li>
|
|||
|
<li>options - Options for creating the index</li>
|
|||
|
</ul>
|
|||
|
<p>The <code class="docutils literal"><span class="pre">keys</span></code> and <code class="docutils literal"><span class="pre">options</span></code> attributes correspond to the arguments for
|
|||
|
<a class="reference external" href="http://php.net/manual/en/mongocollection.createindex.php">MongoCollection::createIndex()</a>.
|
|||
|
ODM allows mapped field names (i.e. PHP property names) to be used when defining
|
|||
|
<code class="docutils literal"><span class="pre">keys</span></code>.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Document(</span>
|
|||
|
<span class="sd"> * indexes={</span>
|
|||
|
<span class="sd"> * @Index(keys={"username"="desc"}, options={"unique"=true})</span>
|
|||
|
<span class="sd"> * }</span>
|
|||
|
<span class="sd"> * )</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">class</span> <span class="nc">User</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">//...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>If you are creating a single-field index, you can simply specify an <a class="reference internal" href="#index">@Index</a> or
|
|||
|
<a class="reference internal" href="#uniqueindex">@UniqueIndex</a> on a mapped property:</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Field(type="string") @UniqueIndex */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$username</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="indexes">
|
|||
|
<h2>@Indexes<a class="headerlink" href="#indexes" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>This annotation may be used at the class level to specify an array of <a class="reference internal" href="#index">@Index</a>
|
|||
|
annotations. It is functionally equivalent to using the <code class="docutils literal"><span class="pre">indexes</span></code> option for
|
|||
|
the <a class="reference internal" href="#document">@Document</a> or <a class="reference internal" href="#embeddeddocument">@EmbeddedDocument</a> annotations.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Document</span>
|
|||
|
<span class="sd"> * @Indexes({</span>
|
|||
|
<span class="sd"> * @Index(keys={"username"="desc"}, options={"unique"=true})</span>
|
|||
|
<span class="sd"> * })</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">class</span> <span class="nc">User</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">//...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="inheritancetype">
|
|||
|
<h2>@InheritanceType<a class="headerlink" href="#inheritancetype" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>This annotation must appear on the top-most class in an
|
|||
|
<a class="reference internal" href="inheritance-mapping.html#inheritance-mapping"><span class="std std-ref">inheritance hierarchy</span></a>. <code class="docutils literal"><span class="pre">SINGLE_COLLECTION</span></code> and
|
|||
|
<code class="docutils literal"><span class="pre">COLLECTION_PER_CLASS</span></code> are currently supported.</p>
|
|||
|
<p>Examples:</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Document</span>
|
|||
|
<span class="sd"> * @InheritanceType("COLLECTION_PER_CLASS")</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Person</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Document</span>
|
|||
|
<span class="sd"> * @InheritanceType("SINGLE_COLLECTION")</span>
|
|||
|
<span class="sd"> * @DiscriminatorField("type")</span>
|
|||
|
<span class="sd"> * @DiscriminatorMap({"person"="Person", "employee"="Employee"})</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Person</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="int">
|
|||
|
<h2>@Int<a class="headerlink" href="#int" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "int".</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Int */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$columns</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated because it uses a keyword that was reserved in
|
|||
|
PHP 7. It will be removed in ODM 2.0. Please use the <a class="reference internal" href="#field">@Field</a> annotation
|
|||
|
with type "int".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="integer">
|
|||
|
<h2>@Integer<a class="headerlink" href="#integer" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "integer". Internally it uses
|
|||
|
exactly same logic as <a class="reference internal" href="#int">@Int</a> annotation and "int" type.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Integer */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$columns</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "int".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="key">
|
|||
|
<h2>@Key<a class="headerlink" href="#key" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "key". The value will be
|
|||
|
converted to <a class="reference external" href="http://php.net/manual/en/class.mongomaxkey.php">MongoMaxKey</a> or <a class="reference external" href="http://php.net/manual/en/class.mongominkey.php">MongoMinKey</a> if it is true or false,
|
|||
|
respectively.</p>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">The BSON MaxKey and MinKey types are internally used by MongoDB for indexing
|
|||
|
and sharding. There is generally no reason to use these in an application.</p>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "key".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="lock">
|
|||
|
<span id="annotations-reference-lock"></span><h2>@Lock<a class="headerlink" href="#lock" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>The annotated instance variable will be used to store lock information for <a class="reference internal" href="transactions-and-concurrency.html#transactions-and-concurrency-pessimistic-locking"><span class="std std-ref">pessimistic locking</span></a>.
|
|||
|
This is only compatible with the <code class="docutils literal"><span class="pre">int</span></code> type, and cannot be combined with <a class="reference internal" href="#id">@Id</a>.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Field(type="int") @Lock */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$lock</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="mappedsuperclass">
|
|||
|
<h2>@MappedSuperclass<a class="headerlink" href="#mappedsuperclass" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>The annotation is used to specify classes that are parents of document classes
|
|||
|
and should not be managed directly. See
|
|||
|
<a class="reference internal" href="inheritance-mapping.html#inheritance-mapping"><span class="std std-ref">inheritance mapping</span></a> for additional information.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @MappedSuperclass */</span>
|
|||
|
<span class="k">class</span> <span class="nc">BaseDocument</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="notsaved">
|
|||
|
<h2>@NotSaved<a class="headerlink" href="#notsaved" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>The annotation is used to specify properties that are loaded if they exist in
|
|||
|
MongoDB; however, ODM will not save the property value back to the database.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @NotSaved */</span>
|
|||
|
<span class="k">public</span> <span class="nv">$field</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="postload">
|
|||
|
<h2>@PostLoad<a class="headerlink" href="#postload" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Marks a method on the document class to be called on the <code class="docutils literal"><span class="pre">postLoad</span></code> event. The
|
|||
|
<a class="reference internal" href="#id1">@HasLifecycleCallbacks</a> annotation must be present on the same class for the
|
|||
|
method to be registered.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Document @HasLifecycleCallbacks */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Article</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
|
|||
|
<span class="sd">/** @PostLoad */</span>
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">postLoad</span><span class="p">()</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>See <a class="reference internal" href="events.html#lifecycle-events"><span class="std std-ref">Lifecycle Events</span></a> for more information.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="postpersist">
|
|||
|
<h2>@PostPersist<a class="headerlink" href="#postpersist" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Marks a method on the document class to be called on the <code class="docutils literal"><span class="pre">postPersist</span></code> event.
|
|||
|
The <a class="reference internal" href="#id1">@HasLifecycleCallbacks</a> annotation must be present on the same class for
|
|||
|
the method to be registered.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Document @HasLifecycleCallbacks */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Article</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
|
|||
|
<span class="sd">/** @PostPersist */</span>
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">postPersist</span><span class="p">()</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>See <a class="reference internal" href="events.html#lifecycle-events"><span class="std std-ref">Lifecycle Events</span></a> for more information.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="postremove">
|
|||
|
<h2>@PostRemove<a class="headerlink" href="#postremove" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Marks a method on the document class to be called on the <code class="docutils literal"><span class="pre">postRemove</span></code> event.
|
|||
|
The <a class="reference internal" href="#id1">@HasLifecycleCallbacks</a> annotation must be present on the same class for
|
|||
|
the method to be registered.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Document @HasLifecycleCallbacks */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Article</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
|
|||
|
<span class="sd">/** @PostRemove */</span>
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">postRemove</span><span class="p">()</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>See <a class="reference internal" href="events.html#lifecycle-events"><span class="std std-ref">Lifecycle Events</span></a> for more information.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="postupdate">
|
|||
|
<h2>@PostUpdate<a class="headerlink" href="#postupdate" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Marks a method on the document class to be called on the <code class="docutils literal"><span class="pre">postUpdate</span></code> event.
|
|||
|
The <a class="reference internal" href="#id1">@HasLifecycleCallbacks</a> annotation must be present on the same class for
|
|||
|
the method to be registered.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Document @HasLifecycleCallbacks */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Article</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
|
|||
|
<span class="sd">/** @PostUpdate */</span>
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">postUpdate</span><span class="p">()</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>See <a class="reference internal" href="events.html#lifecycle-events"><span class="std std-ref">Lifecycle Events</span></a> for more information.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="preflush">
|
|||
|
<h2>@PreFlush<a class="headerlink" href="#preflush" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Marks a method on the document class to be called on the <code class="docutils literal"><span class="pre">preFlush</span></code> event. The
|
|||
|
<a class="reference internal" href="#id1">@HasLifecycleCallbacks</a> annotation must be present on the same class for the
|
|||
|
method to be registered.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Document @HasLifecycleCallbacks */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Article</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
|
|||
|
<span class="sd">/** @PreFlush */</span>
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">preFlush</span><span class="p">()</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>See <a class="reference internal" href="events.html#lifecycle-events"><span class="std std-ref">Lifecycle Events</span></a> for more information.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="preload">
|
|||
|
<h2>@PreLoad<a class="headerlink" href="#preload" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Marks a method on the document class to be called on the <code class="docutils literal"><span class="pre">preLoad</span></code> event. The
|
|||
|
<a class="reference internal" href="#id1">@HasLifecycleCallbacks</a> annotation must be present on the same class for the
|
|||
|
method to be registered.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="k">use</span> <span class="nx">Doctrine\ODM\MongoDB\Event\PreLoadEventArgs</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="sd">/** @Document @HasLifecycleCallbacks */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Article</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
|
|||
|
<span class="sd">/** @PreLoad */</span>
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">preLoad</span><span class="p">(</span><span class="nx">PreLoadEventArgs</span> <span class="nv">$eventArgs</span><span class="p">)</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>See <a class="reference internal" href="events.html#lifecycle-events"><span class="std std-ref">Lifecycle Events</span></a> for more information.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="prepersist">
|
|||
|
<h2>@PrePersist<a class="headerlink" href="#prepersist" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Marks a method on the document class to be called on the <code class="docutils literal"><span class="pre">prePersist</span></code> event.
|
|||
|
The <a class="reference internal" href="#id1">@HasLifecycleCallbacks</a> annotation must be present on the same class for
|
|||
|
the method to be registered.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Document @HasLifecycleCallbacks */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Article</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
|
|||
|
<span class="sd">/** @PrePersist */</span>
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">prePersist</span><span class="p">()</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>See <a class="reference internal" href="events.html#lifecycle-events"><span class="std std-ref">Lifecycle Events</span></a> for more information.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="preremove">
|
|||
|
<h2>@PreRemove<a class="headerlink" href="#preremove" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Marks a method on the document class to be called on the <code class="docutils literal"><span class="pre">preRemove</span></code> event.
|
|||
|
The <a class="reference internal" href="#id1">@HasLifecycleCallbacks</a> annotation must be present on the same class for
|
|||
|
the method to be registered.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Document @HasLifecycleCallbacks */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Article</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
|
|||
|
<span class="sd">/** @PreRemove */</span>
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">preRemove</span><span class="p">()</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>See <a class="reference internal" href="events.html#lifecycle-events"><span class="std std-ref">Lifecycle Events</span></a> for more information.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="preupdate">
|
|||
|
<h2>@PreUpdate<a class="headerlink" href="#preupdate" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Marks a method on the document class to be called on the <code class="docutils literal"><span class="pre">preUpdate</span></code> event.
|
|||
|
The <a class="reference internal" href="#id1">@HasLifecycleCallbacks</a> annotation must be present on the same class for
|
|||
|
the method to be registered.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Document @HasLifecycleCallbacks */</span>
|
|||
|
<span class="k">class</span> <span class="nc">Article</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
|
|||
|
<span class="sd">/** @PreUpdate */</span>
|
|||
|
<span class="k">public</span> <span class="k">function</span> <span class="nf">preUpdated</span><span class="p">()</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">// ...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>See <a class="reference internal" href="events.html#lifecycle-events"><span class="std std-ref">Lifecycle Events</span></a> for more information.</p>
|
|||
|
</div>
|
|||
|
<div class="section" id="readpreference">
|
|||
|
<h2>@ReadPreference<a class="headerlink" href="#readpreference" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Specifies <cite>Read Preference <https://docs.mongodb.com/manual/core/read-preference/>_</cite>
|
|||
|
that will be applied when querying for the annotated document.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="k">namespace</span> <span class="nx">Documents</span><span class="p">;</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Document</span>
|
|||
|
<span class="sd"> * @ODM\ReadPreference("primaryPreferred", tags={</span>
|
|||
|
<span class="sd"> * { "dc"="east" },</span>
|
|||
|
<span class="sd"> * { "dc"="west" },</span>
|
|||
|
<span class="sd"> * { }</span>
|
|||
|
<span class="sd"> * })</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">class</span> <span class="nc">User</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation can not be combined with <code class="docutils literal"><span class="pre">slaveOkay</span></code>, such combination will
|
|||
|
produce a <code class="docutils literal"><span class="pre">MappingException</span></code> error.</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="referencemany">
|
|||
|
<span id="annotations-reference-reference-many"></span><h2>@ReferenceMany<a class="headerlink" href="#referencemany" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Defines that the annotated instance variable holds a collection of referenced
|
|||
|
documents.</p>
|
|||
|
<p>Optional attributes:</p>
|
|||
|
<ul class="simple">
|
|||
|
<li>targetDocument - A <a href="#id10"><span class="problematic" id="id11">|FQCN|</span></a> of the target document. A <code class="docutils literal"><span class="pre">targetDocument</span></code> is
|
|||
|
required when using <code class="docutils literal"><span class="pre">storeAs:</span> <span class="pre">id</span></code>.</li>
|
|||
|
<li>simple - deprecated (use <code class="docutils literal"><span class="pre">storeAs:</span> <span class="pre">id</span></code>)</li>
|
|||
|
<li>storeAs - Indicates how to store the reference. <code class="docutils literal"><span class="pre">id</span></code> stores the identifier,
|
|||
|
<code class="docutils literal"><span class="pre">ref</span></code> an embedded object containing the <code class="docutils literal"><span class="pre">id</span></code> field and (optionally) a
|
|||
|
discriminator. <code class="docutils literal"><span class="pre">dbRef</span></code> and <code class="docutils literal"><span class="pre">dbRefWithDb</span></code> store a <a class="reference external" href="https://docs.mongodb.com/manual/reference/database-references/#dbrefs">DBRef</a> object and
|
|||
|
are deprecated in favor of <code class="docutils literal"><span class="pre">ref</span></code>. Note that <code class="docutils literal"><span class="pre">id</span></code> references are not
|
|||
|
compatible with the discriminators.</li>
|
|||
|
<li>cascade - Cascade Option</li>
|
|||
|
<li>discriminatorField - The field name to store the discriminator value within
|
|||
|
the reference object.</li>
|
|||
|
<li>discriminatorMap - Map of discriminator values to class names.</li>
|
|||
|
<li>defaultDiscriminatorValue - A default value for discriminatorField if no value
|
|||
|
has been set in the referenced document.</li>
|
|||
|
<li>inversedBy - The field name of the inverse side. Only allowed on owning side.</li>
|
|||
|
<li>mappedBy - The field name of the owning side. Only allowed on the inverse side.</li>
|
|||
|
<li>repositoryMethod - The name of the repository method to call to populate this reference.</li>
|
|||
|
<li>sort - The default sort for the query that loads the reference.</li>
|
|||
|
<li>criteria - Array of default criteria for the query that loads the reference.</li>
|
|||
|
<li>limit - Limit for the query that loads the reference.</li>
|
|||
|
<li>skip - Skip for the query that loads the reference.</li>
|
|||
|
<li>strategy - The strategy used to persist changes to the collection. Possible
|
|||
|
values are <code class="docutils literal"><span class="pre">addToSet</span></code>, <code class="docutils literal"><span class="pre">pushAll</span></code>, <code class="docutils literal"><span class="pre">set</span></code>, and <code class="docutils literal"><span class="pre">setArray</span></code>. <code class="docutils literal"><span class="pre">pushAll</span></code>
|
|||
|
is the default. See <a class="reference internal" href="storage-strategies.html#storage-strategies"><span class="std std-ref">Storage Strategies</span></a> for more information.</li>
|
|||
|
<li>collectionClass - A <a href="#id12"><span class="problematic" id="id13">|FQCN|</span></a> of class that implements <code class="docutils literal"><span class="pre">Collection</span></code> interface
|
|||
|
and is used to hold documents. Doctrine's <code class="docutils literal"><span class="pre">ArrayCollection</span></code> is used by default</li>
|
|||
|
<li>prime - A list of references contained in the target document that will be
|
|||
|
initialized when the collection is loaded. Only allowed for inverse
|
|||
|
references.</li>
|
|||
|
</ul>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @ReferenceMany(</span>
|
|||
|
<span class="sd"> * strategy="set",</span>
|
|||
|
<span class="sd"> * targetDocument="Documents\Item",</span>
|
|||
|
<span class="sd"> * cascade="all",</span>
|
|||
|
<span class="sd"> * sort={"sort_field": "asc"}</span>
|
|||
|
<span class="sd"> * discriminatorField="type",</span>
|
|||
|
<span class="sd"> * discriminatorMap={</span>
|
|||
|
<span class="sd"> * "book"="Documents\BookItem",</span>
|
|||
|
<span class="sd"> * "song"="Documents\SongItem"</span>
|
|||
|
<span class="sd"> * },</span>
|
|||
|
<span class="sd"> * defaultDiscriminatorValue="book"</span>
|
|||
|
<span class="sd"> * )</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$cart</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="referenceone">
|
|||
|
<span id="annotations-reference-reference-one"></span><h2>@ReferenceOne<a class="headerlink" href="#referenceone" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Defines an instance variable holds a related document instance.</p>
|
|||
|
<p>Optional attributes:</p>
|
|||
|
<ul class="simple">
|
|||
|
<li>targetDocument - A <a href="#id14"><span class="problematic" id="id15">|FQCN|</span></a> of the target document. A <code class="docutils literal"><span class="pre">targetDocument</span></code> is
|
|||
|
required when using <code class="docutils literal"><span class="pre">storeAs:</span> <span class="pre">id</span></code>.</li>
|
|||
|
<li>simple - deprecated (use <code class="docutils literal"><span class="pre">storeAs:</span> <span class="pre">id</span></code>)</li>
|
|||
|
<li>storeAs - Indicates how to store the reference. <code class="docutils literal"><span class="pre">id</span></code> stores the identifier,
|
|||
|
<code class="docutils literal"><span class="pre">ref</span></code> an embedded object containing the <code class="docutils literal"><span class="pre">id</span></code> field and (optionally) a
|
|||
|
discriminator. <code class="docutils literal"><span class="pre">dbRef</span></code> and <code class="docutils literal"><span class="pre">dbRefWithDb</span></code> store a <a class="reference external" href="https://docs.mongodb.com/manual/reference/database-references/#dbrefs">DBRef</a> object and
|
|||
|
are deprecated in favor of <code class="docutils literal"><span class="pre">ref</span></code>. Note that <code class="docutils literal"><span class="pre">id</span></code> references are not
|
|||
|
compatible with the discriminators.</li>
|
|||
|
<li>cascade - Cascade Option</li>
|
|||
|
<li>discriminatorField - The field name to store the discriminator value within
|
|||
|
the reference object.</li>
|
|||
|
<li>discriminatorMap - Map of discriminator values to class names.</li>
|
|||
|
<li>defaultDiscriminatorValue - A default value for discriminatorField if no value
|
|||
|
has been set in the referenced document.</li>
|
|||
|
<li>inversedBy - The field name of the inverse side. Only allowed on owning side.</li>
|
|||
|
<li>mappedBy - The field name of the owning side. Only allowed on the inverse side.</li>
|
|||
|
<li>repositoryMethod - The name of the repository method to call to populate this reference.</li>
|
|||
|
<li>sort - The default sort for the query that loads the reference.</li>
|
|||
|
<li>criteria - Array of default criteria for the query that loads the reference.</li>
|
|||
|
<li>limit - Limit for the query that loads the reference.</li>
|
|||
|
<li>skip - Skip for the query that loads the reference.</li>
|
|||
|
</ul>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @ReferenceOne(</span>
|
|||
|
<span class="sd"> * targetDocument="Documents\Item",</span>
|
|||
|
<span class="sd"> * cascade="all",</span>
|
|||
|
<span class="sd"> * discriminatorField="type",</span>
|
|||
|
<span class="sd"> * discriminatorMap={</span>
|
|||
|
<span class="sd"> * "book"="Documents\BookItem",</span>
|
|||
|
<span class="sd"> * "song"="Documents\SongItem"</span>
|
|||
|
<span class="sd"> * },</span>
|
|||
|
<span class="sd"> * defaultDiscriminatorValue="book"</span>
|
|||
|
<span class="sd"> * )</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$cart</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="shardkey">
|
|||
|
<h2>@ShardKey<a class="headerlink" href="#shardkey" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>This annotation may be used at the class level to specify a shard key to be used
|
|||
|
for sharding the document collection.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/**</span>
|
|||
|
<span class="sd"> * @Document</span>
|
|||
|
<span class="sd"> * @ShardKey(keys={"username"="asc"})</span>
|
|||
|
<span class="sd"> */</span>
|
|||
|
<span class="k">class</span> <span class="nc">User</span>
|
|||
|
<span class="p">{</span>
|
|||
|
<span class="c1">//...</span>
|
|||
|
<span class="p">}</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="string">
|
|||
|
<h2>@String<a class="headerlink" href="#string" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "string".</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @String */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$username</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated because it uses a keyword that was reserved in
|
|||
|
PHP 7. It will be removed in ODM 2.0. Please use the <a class="reference internal" href="#field">@Field</a> annotation
|
|||
|
with type "string".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="timestamp">
|
|||
|
<h2>@Timestamp<a class="headerlink" href="#timestamp" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#field">@Field</a>, with "type" attribute set to "timestamp". The value will be
|
|||
|
converted to <a class="reference external" href="http://php.net/manual/en/class.mongotimestamp.php">MongoTimestamp</a> for storage in MongoDB.</p>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">The BSON timestamp type is an internal type used for MongoDB's replication
|
|||
|
and sharding. If you need to store dates in your application, you should use
|
|||
|
the "date" type instead.</p>
|
|||
|
</div>
|
|||
|
<div class="admonition note">
|
|||
|
<p class="first admonition-title">Note</p>
|
|||
|
<p class="last">This annotation is deprecated and will be removed in ODM 2.0. Please use the
|
|||
|
<a class="reference internal" href="#field">@Field</a> annotation with type "timestamp".</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="uniqueindex">
|
|||
|
<h2>@UniqueIndex<a class="headerlink" href="#uniqueindex" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>Alias of <a class="reference internal" href="#index">@Index</a>, with the <code class="docutils literal"><span class="pre">unique</span></code> option set by default.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Field(type="string") @UniqueIndex */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$email</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="section" id="version">
|
|||
|
<span id="annotations-reference-version"></span><h2>@Version<a class="headerlink" href="#version" title="Permalink to this headline">¶</a></h2>
|
|||
|
<p>The annotated instance variable will be used to store version information for <a class="reference internal" href="transactions-and-concurrency.html#transactions-and-concurrency-optimistic-locking"><span class="std std-ref">optimistic locking</span></a>.
|
|||
|
This is only compatible with <code class="docutils literal"><span class="pre">int</span></code> and <code class="docutils literal"><span class="pre">date</span></code> field types, and cannot be combined with <a class="reference internal" href="#id">@Id</a>.</p>
|
|||
|
<div class="highlight-php"><div class="highlight"><pre><span class="cp"><?php</span>
|
|||
|
|
|||
|
<span class="sd">/** @Field(type="int") @Version */</span>
|
|||
|
<span class="k">private</span> <span class="nv">$version</span><span class="p">;</span>
|
|||
|
</pre></div>
|
|||
|
</div>
|
|||
|
<p>By default, Doctrine ODM updates <a class="reference internal" href="embedded-mapping.html#embed-many"><span class="std std-ref">embed-many</span></a> and
|
|||
|
<a class="reference internal" href="reference-mapping.html#reference-many"><span class="std std-ref">reference-many</span></a> collections in separate write operations,
|
|||
|
which do not bump the document version. Users employing document versioning are
|
|||
|
encouraged to use the <a class="reference internal" href="storage-strategies.html#atomic-set"><span class="std std-ref">atomicSet</span></a> or
|
|||
|
<a class="reference internal" href="storage-strategies.html#atomic-set-array"><span class="std std-ref">atomicSetArray</span></a> strategies for such collections, which
|
|||
|
will ensure that collections are updated in the same write operation as the
|
|||
|
versioned parent document.</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
<div class="sphinxsidebar">
|
|||
|
<div class="sphinxsidebarwrapper">
|
|||
|
|
|||
|
<div id="searchbox" style="">
|
|||
|
<h3>Search</h3>
|
|||
|
<form class="search" action="http://readthedocs.org/search/project/" method="get">
|
|||
|
<input type="text" name="q" size="18">
|
|||
|
<input type="submit" value="Go">
|
|||
|
<input type="hidden" name="selected_facets" value="project:">
|
|||
|
</form>
|
|||
|
</div>
|
|||
|
<h3><a href="../index.html">Table Of Contents</a></h3>
|
|||
|
<ul>
|
|||
|
<li><a class="reference internal" href="#">Annotations Reference</a><ul>
|
|||
|
<li><a class="reference internal" href="#alsoload">@AlsoLoad</a></li>
|
|||
|
<li><a class="reference internal" href="#bin">@Bin</a></li>
|
|||
|
<li><a class="reference internal" href="#bincustom">@BinCustom</a></li>
|
|||
|
<li><a class="reference internal" href="#binfunc">@BinFunc</a></li>
|
|||
|
<li><a class="reference internal" href="#binmd5">@BinMD5</a></li>
|
|||
|
<li><a class="reference internal" href="#binuuid">@BinUUID</a></li>
|
|||
|
<li><a class="reference internal" href="#binuuidrfc4122">@BinUUIDRFC4122</a></li>
|
|||
|
<li><a class="reference internal" href="#bool">@Bool</a></li>
|
|||
|
<li><a class="reference internal" href="#boolean">@Boolean</a></li>
|
|||
|
<li><a class="reference internal" href="#changetrackingpolicy">@ChangeTrackingPolicy</a></li>
|
|||
|
<li><a class="reference internal" href="#collection">@Collection</a></li>
|
|||
|
<li><a class="reference internal" href="#date">@Date</a></li>
|
|||
|
<li><a class="reference internal" href="#defaultdiscriminatorvalue">@DefaultDiscriminatorValue</a></li>
|
|||
|
<li><a class="reference internal" href="#discriminatorfield">@DiscriminatorField</a></li>
|
|||
|
<li><a class="reference internal" href="#discriminatormap">@DiscriminatorMap</a></li>
|
|||
|
<li><a class="reference internal" href="#distance">@Distance</a></li>
|
|||
|
<li><a class="reference internal" href="#document">@Document</a></li>
|
|||
|
<li><a class="reference internal" href="#embedmany">@EmbedMany</a></li>
|
|||
|
<li><a class="reference internal" href="#embedone">@EmbedOne</a></li>
|
|||
|
<li><a class="reference internal" href="#embeddeddocument">@EmbeddedDocument</a></li>
|
|||
|
<li><a class="reference internal" href="#field">@Field</a></li>
|
|||
|
<li><a class="reference internal" href="#file">@File</a></li>
|
|||
|
<li><a class="reference internal" href="#float">@Float</a></li>
|
|||
|
<li><a class="reference internal" href="#haslifecyclecallbacks">@HasLifecycleCallbacks</a></li>
|
|||
|
<li><a class="reference internal" href="#hash">@Hash</a></li>
|
|||
|
<li><a class="reference internal" href="#id">@Id</a></li>
|
|||
|
<li><a class="reference internal" href="#increment">@Increment</a></li>
|
|||
|
<li><a class="reference internal" href="#index">@Index</a></li>
|
|||
|
<li><a class="reference internal" href="#indexes">@Indexes</a></li>
|
|||
|
<li><a class="reference internal" href="#inheritancetype">@InheritanceType</a></li>
|
|||
|
<li><a class="reference internal" href="#int">@Int</a></li>
|
|||
|
<li><a class="reference internal" href="#integer">@Integer</a></li>
|
|||
|
<li><a class="reference internal" href="#key">@Key</a></li>
|
|||
|
<li><a class="reference internal" href="#lock">@Lock</a></li>
|
|||
|
<li><a class="reference internal" href="#mappedsuperclass">@MappedSuperclass</a></li>
|
|||
|
<li><a class="reference internal" href="#notsaved">@NotSaved</a></li>
|
|||
|
<li><a class="reference internal" href="#postload">@PostLoad</a></li>
|
|||
|
<li><a class="reference internal" href="#postpersist">@PostPersist</a></li>
|
|||
|
<li><a class="reference internal" href="#postremove">@PostRemove</a></li>
|
|||
|
<li><a class="reference internal" href="#postupdate">@PostUpdate</a></li>
|
|||
|
<li><a class="reference internal" href="#preflush">@PreFlush</a></li>
|
|||
|
<li><a class="reference internal" href="#preload">@PreLoad</a></li>
|
|||
|
<li><a class="reference internal" href="#prepersist">@PrePersist</a></li>
|
|||
|
<li><a class="reference internal" href="#preremove">@PreRemove</a></li>
|
|||
|
<li><a class="reference internal" href="#preupdate">@PreUpdate</a></li>
|
|||
|
<li><a class="reference internal" href="#readpreference">@ReadPreference</a></li>
|
|||
|
<li><a class="reference internal" href="#referencemany">@ReferenceMany</a></li>
|
|||
|
<li><a class="reference internal" href="#referenceone">@ReferenceOne</a></li>
|
|||
|
<li><a class="reference internal" href="#shardkey">@ShardKey</a></li>
|
|||
|
<li><a class="reference internal" href="#string">@String</a></li>
|
|||
|
<li><a class="reference internal" href="#timestamp">@Timestamp</a></li>
|
|||
|
<li><a class="reference internal" href="#uniqueindex">@UniqueIndex</a></li>
|
|||
|
<li><a class="reference internal" href="#version">@Version</a></li>
|
|||
|
</ul>
|
|||
|
</li>
|
|||
|
</ul>
|
|||
|
|
|||
|
<h3>This Page</h3>
|
|||
|
<ul class="this-page-menu">
|
|||
|
<li><a href="../_sources/reference/annotations-reference.rst.txt"
|
|||
|
rel="nofollow">Show Source</a></li>
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div class="clearer"></div>
|
|||
|
</div>
|
|||
|
<div class="footer">
|
|||
|
© Copyright 2013, Doctrine Project Team.
|
|||
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.6.2.
|
|||
|
<br/>
|
|||
|
<a target="_BLANK" href="http://www.servergrove.com"><img src="http://www.doctrine-project.org/_static/servergrove.jpg" /></a> <br/><br/>
|
|||
|
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
|||
|
<input type="hidden" name="cmd" value="_s-xclick" />
|
|||
|
<input type="hidden" name="hosted_button_id" value="BAE2E3XANQ77Y" />
|
|||
|
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" />
|
|||
|
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
|
|||
|
</form>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
<div id="bot-rcnr">
|
|||
|
<div class="tl"><!-- corner --></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
|
|||
|
</script>
|
|||
|
<script type="text/javascript">
|
|||
|
_uacct = "UA-288343-7";
|
|||
|
urchinTracker();
|
|||
|
</script>
|
|||
|
<a class="githublink" href="http://github.com/doctrine"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" alt="Fork me on GitHub"></a>
|
|||
|
</body>
|
|||
|
</html>
|