Skip to content

Commit

Permalink
Add visibility filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy LIMOUZIN committed Oct 14, 2020
1 parent 8d67b3c commit f8d34bf
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/bundle/Entity/RssFeedItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ class RssFeedItems
*/
private $category;

/**
* @var bool
*
* @ORM\Column(name="only_visible", type="boolean")
*/
private $onlyVisible;

/**
* @var string
*
Expand Down Expand Up @@ -168,6 +175,7 @@ public function toArray()
'locationId' => $this->getSubtreePath(),
'includeSubtreePath' => $this->getIncludeSubtree(),
'contentTypeId' => $this->getContentTypeId(),
'onlyVisible' => $this->getOnlyVisible(),
'fieldTypesIdentifier' => [
'title' => $this->getTitle(),
'description' => $this->getDescription(),
Expand Down Expand Up @@ -344,4 +352,20 @@ public function setMedia($media = null)

return $this;
}

/**
* @return bool
*/
public function getOnlyVisible(): bool
{
return $this->onlyVisible;
}

/**
* @param bool $onlyVisible
*/
public function setOnlyVisible(bool $onlyVisible): void
{
$this->onlyVisible = $onlyVisible;
}
}
8 changes: 8 additions & 0 deletions src/bundle/Form/RssFeedItemsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'required' => false,
]
)
->add(
'only_visible',
CheckboxType::class,
[
'label' => 'ez_rss_feed.form.only_visible',
'required' => false,
]
)
->add(
'contenttype_id',
ChoiceType::class,
Expand Down
1 change: 1 addition & 0 deletions src/bundle/Resources/translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ez_rss_feed.form.url_slug: URL
ez_rss_feed.form.sources: Sources
ez_rss_feed.form.subtree_path: Select location path
ez_rss_feed.form.include_subtree: Include sub node
ez_rss_feed.form.only_visible: Only visible node
ez_rss_feed.form.number_of_object: Number of objects
ez_rss_feed.form.contenttype: Select content type
ez_rss_feed.form.field.title: Title field
Expand Down
1 change: 1 addition & 0 deletions src/bundle/Resources/translations/messages.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ez_rss_feed.form.url_slug: URL
ez_rss_feed.form.sources: Sources
ez_rss_feed.form.subtree_path: Sélectionner un emplacement
ez_rss_feed.form.include_subtree: Inclure les sous noeuds
ez_rss_feed.form.only_visible: Afficher uniquement les noeuds visibles
ez_rss_feed.form.number_of_object: Nombre d'objet
ez_rss_feed.form.contenttype: Sélectionner le type de contenu
ez_rss_feed.form.field.title: Champ Titre
Expand Down
11 changes: 11 additions & 0 deletions src/bundle/Resources/views/Form/form_fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@
</div>
</div>
{% endblock _rss_feeds_feed_items_entry_include_subtree_row %}
{% block _rss_feeds_feed_items_entry_only_visible_row %}
<div class="form-group col-md-12 col-sm-12 col-xs-12 pull-left">
<label class="form-label">
{{- form_label(form) -}}
</label>
<div class="controls">
{{- form_errors(form) -}}
{{- form_widget(form) -}}
</div>
</div>
{% endblock _rss_feeds_feed_items_entry_only_visible_row %}
{% block _rss_feeds_feed_items_entry_contenttype_id_row %}
<div class="form-group col-md-12 col-sm-12 col-xs-12 pull-left">
<label class="form-label">
Expand Down
4 changes: 4 additions & 0 deletions src/bundle/Services/RssFeedsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public function fetchContent(RssFeeds $rssFeed)

$criterion[] = new Query\Criterion\ContentTypeId($filter['contentTypeId']);

if ($filter['onlyVisible']) {
$criterion[] = new Query\Criterion\Visibility(Query\Criterion\Visibility::VISIBLE);
}

$queryFilter[] = new Query\Criterion\LogicalAnd($criterion);
}

Expand Down

0 comments on commit f8d34bf

Please sign in to comment.