44
55use Doctrine \Common \Collections \ArrayCollection ;
66use Doctrine \Common \Collections \Collection ;
7- use Tapestry \Modules \Content \FrontMatter as TapestryFrontMatter ;
87
98/**
109 * @Entity
@@ -84,7 +83,7 @@ class File
8483
8584 /**
8685 * @var Collection|FrontMatter[]
87- * @OneToMany(targetEntity="FrontMatter", mappedBy="file_id ")
86+ * @OneToMany(targetEntity="FrontMatter", mappedBy="file ")
8887 */
8988 private $ frontMatter ;
9089
@@ -97,37 +96,6 @@ public function __construct()
9796 $ this ->frontMatter = new ArrayCollection ();
9897 }
9998
100- /**
101- * File Hydration.
102- *
103- * @param \Tapestry\Entities\File $file
104- * @param Environment|null $environment
105- */
106- public function hydrate (\Tapestry \Entities \File $ file , Environment $ environment = null )
107- {
108- $ this ->setUid ($ file ->getUid ());
109- $ this ->setLastModified ($ file ->getLastModified ());
110- $ this ->setFilename ($ file ->getFilename ());
111- $ this ->setExt ($ file ->getExt ());
112- $ this ->setPath ($ file ->getPath ());
113- $ this ->setToCopy ($ file ->isToCopy ());
114-
115- if (! $ file ->isToCopy ()) {
116- $ frontMatter = new TapestryFrontMatter ($ file ->getFileContent ());
117- $ this ->setContent ($ frontMatter ->getContent ());
118- foreach ($ frontMatter ->getData () as $ key => $ value ) {
119- $ fmRecord = new FrontMatter ();
120- $ fmRecord ->setName ($ key );
121- $ fmRecord ->setValue ($ value );
122- $ this ->addFrontMatter ($ fmRecord );
123- }
124- }
125-
126- if (!is_null ($ environment )) {
127- $ this ->setEnvironment ($ environment );
128- }
129- }
130-
13199 //
132100 // Relationships
133101 //
@@ -154,6 +122,7 @@ public function addFrontMatter(FrontMatter $frontMatter) {
154122 }
155123
156124 $ this ->frontMatter ->add ($ frontMatter );
125+ $ frontMatter ->setFile ($ this );
157126 }
158127
159128 /**
0 commit comments