File tree Expand file tree Collapse file tree 2 files changed +155
-0
lines changed
Expand file tree Collapse file tree 2 files changed +155
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace Kayue \WordpressBundle \Entity ;
44
5+ use Doctrine \Common \Collections \ArrayCollection ;
56use Doctrine \ORM \Mapping as ORM ;
67use Kayue \WordpressBundle \Annotation as Wordpress ;
78use Symfony \Component \Validator \Constraints as Constraints ;
@@ -52,6 +53,18 @@ class Term
5253 */
5354 protected $ taxonomy ;
5455
56+ /**
57+ * {@inheritdoc}
58+ *
59+ * @ORM\OneToMany(targetEntity="Kayue\WordpressBundle\Entity\TermMeta", mappedBy="term", cascade={"persist"})
60+ */
61+ protected $ metas ;
62+
63+ public function __construct ()
64+ {
65+ $ this ->metas = new ArrayCollection ();
66+ }
67+
5568 /**
5669 * Get id
5770 *
@@ -141,4 +154,25 @@ public function getTaxonomy()
141154 {
142155 return $ this ->taxonomy ;
143156 }
157+
158+ /**
159+ * Add metas
160+ *
161+ * @param TermMeta $meta
162+ */
163+ public function addMeta (TermMeta $ meta )
164+ {
165+ $ meta ->setTerm ($ this );
166+ $ this ->metas [] = $ meta ;
167+ }
168+
169+ /**
170+ * Get metas
171+ *
172+ * @return \Doctrine\Common\Collections\Collection
173+ */
174+ public function getMetas ()
175+ {
176+ return $ this ->metas ;
177+ }
144178}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Kayue \WordpressBundle \Entity ;
4+
5+ use Doctrine \ORM \Mapping as ORM ;
6+ use Kayue \WordpressBundle \Annotation as Wordpress ;
7+ use Symfony \Component \Validator \Constraints as Constraints ;
8+
9+ /**
10+ * TermMeta
11+ *
12+ * @ORM\Table(name="termmeta")
13+ * @ORM\Entity()
14+ * @Wordpress\WordpressTable
15+ */
16+ class TermMeta
17+ {
18+ /**
19+ * {@inheritdoc}
20+ *
21+ * @ORM\Column(name="meta_id", type="bigint", length=20)
22+ * @ORM\Id
23+ * @ORM\GeneratedValue(strategy="IDENTITY")
24+ */
25+ protected $ id ;
26+
27+ /**
28+ * {@inheritdoc}
29+ *
30+ * @ORM\Column(name="meta_key", type="string", length=255, nullable=true)
31+ * @Constraints\NotBlank()
32+ */
33+ protected $ key ;
34+
35+ /**
36+ * {@inheritdoc}
37+ *
38+ * @ORM\Column(name="meta_value", type="wordpressmeta", nullable=true)
39+ */
40+ protected $ value ;
41+
42+ /**
43+ * {@inheritdoc}
44+ *
45+ * @ORM\ManyToOne(targetEntity="Term", inversedBy="metas")
46+ * @ORM\JoinColumns({
47+ * @ORM\JoinColumn(name="term_id", referencedColumnName="term_id")
48+ * })
49+ */
50+ protected $ term ;
51+
52+ /**
53+ * Get post meta ID
54+ *
55+ * @return int
56+ */
57+ public function getId ()
58+ {
59+ return $ this ->id ;
60+ }
61+
62+ /**
63+ * Set key
64+ *
65+ * @param string $key
66+ */
67+ public function setKey ($ key )
68+ {
69+ $ this ->key = $ key ;
70+ }
71+
72+ /**
73+ * Get key
74+ *
75+ * @return string
76+ */
77+ public function getKey ()
78+ {
79+ return $ this ->key ;
80+ }
81+
82+ /**
83+ * Set value
84+ *
85+ * @param string $value
86+ */
87+ public function setValue ($ value )
88+ {
89+ $ this ->value = $ value ;
90+ }
91+
92+ /**
93+ * Get value
94+ *
95+ * @return string
96+ */
97+ public function getValue ()
98+ {
99+ return $ this ->value ;
100+ }
101+
102+ /**
103+ * Set term
104+ *
105+ * @param Term $term
106+ */
107+ public function setTerm (Term $ term )
108+ {
109+ $ this ->term = $ term ;
110+ }
111+
112+ /**
113+ * Get term
114+ *
115+ * @return Term
116+ */
117+ public function getTerm ()
118+ {
119+ return $ this ->term ;
120+ }
121+ }
You can’t perform that action at this time.
0 commit comments