Skip to content

Commit 7dd7338

Browse files
Douglas Greenshieldsshieldo
authored andcommitted
add locale accessor method to all resources
1 parent 1d98907 commit 7dd7338

File tree

6 files changed

+66
-0
lines changed

6 files changed

+66
-0
lines changed

src/Decorator/AbstractDecoratedAsset.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,14 @@ public function getUpdatedAt()
151151
{
152152
return $this->decorated->getUpdatedAt();
153153
}
154+
155+
/**
156+
* Gets the locale for the asset, if there is one.
157+
*
158+
* @return null|string
159+
*/
160+
public function getLocale()
161+
{
162+
return $this->decorated->getLocale();
163+
}
154164
}

src/DynamicEntry.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ public function getUpdatedAt()
160160
return $this->entry->getUpdatedAt();
161161
}
162162

163+
/**
164+
* Gets the single locale for this entry resource, if there is one.
165+
*
166+
* @return null|string
167+
*/
168+
public function getLocale()
169+
{
170+
return $this->entry->getLocale();
171+
}
172+
163173
private function getCoercedField($key)
164174
{
165175
$contentTypeField = $this->contentType->getField($key);

src/Metadata.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ class Metadata implements MetadataInterface
4444
*/
4545
private $updatedAt;
4646

47+
/**
48+
* @var string
49+
*/
50+
private $locale;
51+
4752
/**
4853
* @param string $id
4954
*/
@@ -174,4 +179,20 @@ public function getUpdatedAt()
174179
{
175180
return $this->updatedAt;
176181
}
182+
183+
/**
184+
* @param string|null $locale
185+
*/
186+
public function setLocale($locale)
187+
{
188+
$this->locale = $locale;
189+
}
190+
191+
/**
192+
* @return string|null
193+
*/
194+
public function getLocale()
195+
{
196+
return $this->locale;
197+
}
177198
}

src/MetadataAccessTrait.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,12 @@ public function getUpdatedAt()
8080
{
8181
return $this->getMetadata()->getUpdatedAt();
8282
}
83+
84+
/**
85+
* @return string|null
86+
*/
87+
public function getLocale()
88+
{
89+
return $this->getMetadata()->getLocale();
90+
}
8391
}

src/MetadataInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,11 @@ public function getCreatedAt();
6262
* @return \DateTime
6363
*/
6464
public function getUpdatedAt();
65+
66+
/**
67+
* The single locale of this resource, if there is one.
68+
*
69+
* @return string|null
70+
*/
71+
public function getLocale();
6572
}

src/Promise/DelegatingMetadataPropertyAccessTrait.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,14 @@ public function getUpdatedAt()
114114
{
115115
return $this->getResolved()->getUpdatedAt();
116116
}
117+
118+
/**
119+
* Gets the single locale for this resource, if there is one.
120+
*
121+
* @return null|string
122+
*/
123+
public function getLocale()
124+
{
125+
return $this->getResolved()->getLocale();
126+
}
117127
}

0 commit comments

Comments
 (0)