Skip to content

Commit c24a80f

Browse files
authored
Merge pull request #13 from mooore-digital/feature/CON-226
CON-226 - Add settings for blog
2 parents 88e95c9 + f716a42 commit c24a80f

File tree

6 files changed

+208
-5
lines changed

6 files changed

+208
-5
lines changed

Api/Data/SiteInterface.php

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ interface SiteInterface extends ExtensibleDataInterface
1616
const API_USERNAME = 'api_username';
1717
const API_PASSWORD = 'api_password';
1818
const REPLACE_MEDIA_URLS = 'replace_media_urls';
19+
const ENABLE_BLOG = 'enable_blog';
20+
const BLOG_PREFIX = 'blog_prefix';
21+
const BLOG_STORES = 'blog_stores';
1922

2023
/**
2124
* Get site_id
@@ -109,15 +112,54 @@ public function getApiPassword(): ?string;
109112
public function setApiPassword(?string $apiPassword);
110113

111114
/**
112-
* Get replace_media_urls
115+
* Get replace_media_urls
116+
* @return bool
117+
*/
118+
public function getReplaceMediaUrls(): ?bool;
119+
120+
/**
121+
* Set replace_media_urls
122+
* @param bool $replaceMediaUrls
123+
* @return SiteInterface
124+
*/
125+
public function setReplaceMediaUrls(?bool $replaceMediaUrls);
126+
127+
/**
128+
* Get enable_blog
113129
* @return bool
114130
*/
115-
public function getReplaceMediaUrls(): ?bool;
131+
public function getEnableBlog(): ?bool;
116132

117133
/**
118-
* Set replace_media_urls
119-
* @param bool $replaceMediaUrls
134+
* Set enable_blog
135+
* @param bool $enableBlog
120136
* @return SiteInterface
121137
*/
122-
public function setReplaceMediaUrls(?bool $replaceMediaUrls);
138+
public function setEnableBlog(?bool $enableBlog);
139+
140+
/**
141+
* Get blog_prefix
142+
* @return string
143+
*/
144+
public function getBlogPrefix(): ?string;
145+
146+
/**
147+
* Set blog_prefix
148+
* @param string $blogPrefix
149+
* @return SiteInterface
150+
*/
151+
public function setBlogPrefix(?string $blogPrefix);
152+
153+
/**
154+
* Get blog_stores
155+
* @return string
156+
*/
157+
public function getBlogStores(): string;
158+
159+
/**
160+
* Set blog_stores
161+
* @param string $blogStores
162+
* @return SiteInterface
163+
*/
164+
public function setBlogStores(string $blogStores);
123165
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Added
99
- Added site settings to enable the media URL replace option
10+
- Add basic blog functionality
1011

1112
## [0.3.0] - 2021-02-10
1213
### Added

Controller/Adminhtml/Site/Save.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public function execute()
5353
return $resultRedirect->setPath('*/*/');
5454
}
5555

56+
$data['blog_stores'] = is_array($data['blog_stores']) ? join(',', $data['blog_stores']) : $data['blog_stores'];
57+
5658
$model->setData($data);
5759

5860
try {

Model/Data/Site.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,61 @@ public function setReplaceMediaUrls($replaceMediaUrls)
161161
{
162162
return $this->setData(self::REPLACE_MEDIA_URLS, $replaceMediaUrls);
163163
}
164+
165+
/**
166+
* Get enable_blog
167+
* @return bool|null
168+
*/
169+
public function getEnableBlog(): bool
170+
{
171+
return (bool) $this->_get(self::ENABLE_BLOG);
172+
}
173+
174+
/**
175+
* Set enable_blog
176+
* @param bool $enableBlog
177+
* @return SiteInterface
178+
*/
179+
public function setEnableBlog($enableBlog)
180+
{
181+
return $this->setData(self::ENABLE_BLOG, $enableBlog);
182+
}
183+
184+
/**
185+
* Get blog_prefix
186+
* @return string
187+
*/
188+
public function getBlogPrefix(): ?string
189+
{
190+
return $this->_get(self::BLOG_PREFIX);
191+
}
192+
193+
/**
194+
* Set blog_prefix
195+
* @param string $apiPassword
196+
* @return SiteInterface
197+
*/
198+
public function setBlogPrefix(?string $blogPrefix)
199+
{
200+
return $this->setData(self::BLOG_PREFIX, $blogPrefix);
201+
}
202+
203+
/**
204+
* Get blog_stores
205+
* @return string
206+
*/
207+
public function getBlogStores(): string
208+
{
209+
return $this->_get(self::BLOG_STORES);
210+
}
211+
212+
/**
213+
* Set blog_stores
214+
* @param string $blogStores
215+
* @return SiteInterface
216+
*/
217+
public function setBlogStores(string $blogStores)
218+
{
219+
return $this->setData(self::BLOG_STORES, $blogStores);
220+
}
164221
}

etc/db_schema.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@
1414
<column length="255" name="api_username" nullable="true" xsi:type="varchar"/>
1515
<column length="255" name="api_password" nullable="true" xsi:type="varchar"/>
1616
<column default="0" name="replace_media_urls" nullable="false" xsi:type="boolean"/>
17+
<column default="0" name="enable_blog" nullable="false" xsi:type="boolean"/>
18+
<column length="255" name="blog_prefix" nullable="true" xsi:type="varchar"/>
19+
<column length="255" name="blog_stores" nullable="false" xsi:type="varchar"/>
1720
</table>
1821
</schema>

view/adminhtml/ui_component/mooore_wordpressintegration_site_form.xml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,102 @@
158158
</formElements>
159159
</field>
160160
</fieldset>
161+
<fieldset name="blog">
162+
<settings>
163+
<label>Blog</label>
164+
</settings>
165+
<field formElement="checkbox" name="enable_blog" sortOrder="10">
166+
<argument name="data" xsi:type="array">
167+
<item name="config" xsi:type="array">
168+
<item name="source" xsi:type="string">Site</item>
169+
<item name="default" xsi:type="number">0</item>
170+
</item>
171+
</argument>
172+
<settings>
173+
<dataType>boolean</dataType>
174+
<label translate="true">Enable Blog</label>
175+
<dataScope>enable_blog</dataScope>
176+
<validation>
177+
<rule name="required-entry" xsi:type="boolean">false</rule>
178+
</validation>
179+
<switcherConfig>
180+
<enabled>true</enabled>
181+
<rules>
182+
<rule name="0">
183+
<value>0</value>
184+
<actions>
185+
<action name="0">
186+
<target>mooore_wordpressintegration_site_form.mooore_wordpressintegration_site_form.blog.blog_prefix</target>
187+
<callback>hide</callback>
188+
</action>
189+
<action name="1">
190+
<target>mooore_wordpressintegration_site_form.mooore_wordpressintegration_site_form.blog.blog_stores</target>
191+
<callback>hide</callback>
192+
</action>
193+
</actions>
194+
</rule>
195+
<rule name="1">
196+
<value>1</value>
197+
<actions>
198+
<action name="0">
199+
<target>mooore_wordpressintegration_site_form.mooore_wordpressintegration_site_form.blog.blog_prefix</target>
200+
<callback>show</callback>
201+
</action>
202+
<action name="1">
203+
<target>mooore_wordpressintegration_site_form.mooore_wordpressintegration_site_form.blog.blog_stores</target>
204+
<callback>show</callback>
205+
</action>
206+
</actions>
207+
</rule>
208+
</rules>
209+
</switcherConfig>
210+
</settings>
211+
<formElements>
212+
<checkbox>
213+
<settings>
214+
<valueMap>
215+
<map name="false" xsi:type="number">0</map>
216+
<map name="true" xsi:type="number">1</map>
217+
</valueMap>
218+
<prefer>toggle</prefer>
219+
</settings>
220+
</checkbox>
221+
</formElements>
222+
</field>
223+
<field formElement="input" name="blog_prefix" sortOrder="20">
224+
<argument name="data" xsi:type="array">
225+
<item name="config" xsi:type="array">
226+
<item name="source" xsi:type="string">Site</item>
227+
</item>
228+
</argument>
229+
<settings>
230+
<dataType>text</dataType>
231+
<label translate="true">Blog Route Prefix</label>
232+
<dataScope>blog_prefix</dataScope>
233+
<notice translate="true">Allows you to set a default blog prefix, for example "/blog", leave this field empty to disable this feature.</notice>
234+
<validation>
235+
<rule name="required-entry" xsi:type="boolean">false</rule>
236+
</validation>
237+
</settings>
238+
</field>
239+
<field name="blog_stores" sortOrder="30">
240+
<argument name="data" xsi:type="array">
241+
<item name="options" xsi:type="object">Magento\Cms\Ui\Component\Listing\Column\Cms\Options</item>
242+
<item name="config" xsi:type="array">
243+
<item name="dataType" xsi:type="string">int</item>
244+
<item name="label" xsi:type="string" translate="true">Store View</item>
245+
<item name="formElement" xsi:type="string">multiselect</item>
246+
<item name="source" xsi:type="string">page</item>
247+
<item name="dataScope" xsi:type="string">blog_stores</item>
248+
<item name="default" xsi:type="string">0</item>
249+
<item name="validation" xsi:type="array">
250+
<item name="required-entry" xsi:type="boolean">true</item>
251+
</item>
252+
</item>
253+
</argument>
254+
<settings>
255+
<notice translate="true">Select which stores you want this blog site to be enabled.</notice>
256+
</settings>
257+
</field>
258+
</fieldset>
161259
</form>

0 commit comments

Comments
 (0)