Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Merge 18276ef into ee86599
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI authored Feb 12, 2020
2 parents ee86599 + 18276ef commit 8737c07
Show file tree
Hide file tree
Showing 25 changed files with 238 additions and 103 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
on:
push:
paths:
- 'docs/**'

pull_request:
paths:
- 'docs/**'

name: Documentation

jobs:
build:
name: Build

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@v2

- name: "Set up Python 3.7"
uses: actions/setup-python@v1
with:
python-version: '3.7' # Semantic version range syntax or exact version of a Python version

- name: "Display Python version"
run: python -c "import sys; print(sys.version)"

- name: "Install Sphinx dependencies"
run: sudo apt-get install python-dev build-essential

- name: "Install custom requirements via pip"
run: pip install -r docs/requirements.txt

- name: "Build documentation"
run: make docs

doctor-rst:
name: DOCtor-RST

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@master

- name: "Run DOCtor-RST"
uses: docker://oskarstark/doctor-rst
with:
args: --short
env:
DOCS_DIR: 'docs/'
63 changes: 63 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
on: [push, pull_request]

name: Lint

jobs:
php-cs-fixer:
name: PHP-CS-Fixer

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@v2

- name: "Run PHP-CS-Fixer"
uses: docker://oskarstark/php-cs-fixer-ga:2.16.1
with:
args: --ansi --verbose --diff --dry-run

composer-normalize:
name: composer-normalize

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@v2

- name: "Run composer-normalize"
uses: docker://localheinz/composer-normalize-action:0.5.2
with:
args: --dry-run

yaml-files:
name: YAML files

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@v2

- name: "Install Ruby 2.6"
uses: actions/setup-ruby@v1
with:
ruby-version: '2.6'
- run: gem install yaml-lint
- name: "Linting..."
run: make lint-yaml

xml-files:
name: XML files

runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@v2

- run: sudo apt-get install libxml2-utils

- name: "Linting..."
run: make lint-xml
30 changes: 30 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# https://github.com/actions/stale

name: "Stale"

on:
schedule:
- cron: "0 9-18 * * *"

jobs:
stale:
runs-on: "ubuntu-latest"

steps:
- name: "Close stale issues and pull requests"
uses: "actions/stale@v1.1.0"
with:
days-before-close: 7
days-before-stale: 180
repo-token: "${{ secrets.GITHUB_TOKEN }}"
exempt-issue-label: "keep"
stale-issue-label: "stale"
stale-issue-message: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
stale-pr-label: "stale"
stale-pr-message: >
This PR has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ $rules = [
'header_comment' => [
'header' => $header,
],
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'no_extra_blank_lines' => true,
'no_php4_constructor' => true,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
Expand Down
17 changes: 4 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ php:

dist: xenial

addons:
apt:
packages:
- libxml2-utils

cache:
pip: true
directories:
Expand All @@ -33,21 +28,17 @@ env:
- SYMFONY_DEPRECATIONS_HELPER=max[self]=0
- TARGET=test
- UPSTREAM_URL=https://github.com/sonata-project/SonataAdminSearchBundle.git
- PHPUNIT_VERSION=7
- PHPUNIT_VERSION=8

matrix:
fast_finish: true
include:
- php: '7.3'
env: TARGET=docs
- php: '7.3'
env: TARGET=lint
- php: '7.2'
env: COMPOSER_FLAGS="--prefer-lowest"
- php: '7.3'
env: SYMFONY=3.4.*
env: SYMFONY=4.4.*
- php: '7.3'
env: SYMFONY='dev-master as 3.4.x-dev'
env: SYMFONY='dev-master as 4.4.x-dev'
- php: '7.3'
env: SONATA_ADMIN=3.*
- php: '7.3'
Expand All @@ -62,7 +53,7 @@ matrix:
- php: 7.4snapshot
- php: nightly
- env: SYMFONY_DEPRECATIONS_HELPER=0
- env: SYMFONY='dev-master as 3.4.x-dev'
- env: SYMFONY='dev-master as 4.4.x-dev'
- env: SONATA_ADMIN='dev-master as 3.x-dev'
- env: RUFLIN_ELASTICA='dev-master as 2.x-dev'

Expand Down
6 changes: 0 additions & 6 deletions .travis/check_relevant_docs.sh

This file was deleted.

6 changes: 0 additions & 6 deletions .travis/check_relevant_lint.sh

This file was deleted.

4 changes: 0 additions & 4 deletions .travis/install_docs.sh

This file was deleted.

11 changes: 0 additions & 11 deletions .travis/install_lint.sh

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ all:
@echo "Please choose a task."
.PHONY: all

lint: lint-composer lint-yaml lint-composer lint-xml lint-php
lint: lint-composer lint-yaml lint-xml lint-php
.PHONY: lint

lint-composer:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
},
"require-dev": {
"matthiasnoback/symfony-config-test": "^4.0",
"matthiasnoback/symfony-dependency-injection-test": "^3.1",
"symfony/phpunit-bridge": "^4.2"
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
"symfony/phpunit-bridge": "^5.0"
},
"config": {
"sort-packages": true
Expand Down
32 changes: 32 additions & 0 deletions docs/.doctor-rst.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
rules:
blank_line_after_directive: ~
short_array_syntax: ~
typo: ~
replacement: ~
composer_dev_option_at_the_end: ~
yarn_dev_option_at_the_end: ~
versionadded_directive_should_have_version: ~
no_composer_req: ~
no_php_open_tag_in_code_block_php_directive: ~
blank_line_after_filepath_in_code_block: ~
no_php_prefix_before_bin_console: ~
use_deprecated_directive_instead_of_versionadded: ~
no_space_before_self_xml_closing_tag: ~
no_explicit_use_of_code_block_php: ~
ensure_order_of_code_blocks_in_configuration_block: ~
american_english: ~
valid_use_statements: ~
extend_abstract_admin: ~
final_admin_class: ~
final_admin_extension_classes: ~
no_admin_yaml: ~
no_bash_prompt: ~
no_composer_phar: ~
no_inheritdoc: ~

# can be enabled when no Symfony 3.4 support anymore
#yaml_instead_of_yml_suffix: ~
#no_app_bundle: ~
#no_config_yaml: ~
#kernel_instead_of_app_kernel: ~
#no_app_console: ~
7 changes: 1 addition & 6 deletions docs/reference/createquery.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
Customizing the query used to generate the list
===============================================


You can customize the list query thanks to the ``createQuery`` method.

.. code-block:: php
<?php
You can customize the list query thanks to the ``createQuery`` method::

public function createQuery($context = 'list')
{
Expand Down
30 changes: 13 additions & 17 deletions docs/reference/filter_field_definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,21 @@ Callback
To create a custom callback filter, you just need to set the "callback" filter option
to a valid callback function. First argument of this function will be
``Sonata\AdminSearchBundle\ProxyQuery\ElasticaProxyQuery`` instance which could be
modified according to your needs.
modified according to your needs::

.. code-block:: php
<?php
namespace Sonata\NewsBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminSearchBundle\ProxyQuery\ElasticaProxyQuery;

class PostAdmin extends Admin
final class PostAdmin extends AbstractAdmin
{
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('title')
->add('name', Sonata\AdminSearchBundle\Filter\CallbackFilter::class, array(
->add('name', Sonata\AdminSearchBundle\Filter\CallbackFilter::class, [
'callback' => function (ElasticaProxyQuery $query, $alias, $field, $data) {
if (!$data || !is_array($data) || !array_key_exists('value', $data)) {
return;
Expand All @@ -54,29 +51,28 @@ modified according to your needs.

$query->addMust($queryBuilder);
}
))
])
;
}
}

Date
^^^^

To make query on date/datetime type, you can use one of the `sonata_search_elastica_date` filter types.
For example if you have a date in the ISO 8601 date format :
To make query on date/datetime type, you can use one of the `sonata_search_elastica_date`
filter types. For example if you have a date in the ISO 8601 date format::

.. code-block:: php
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('date', Sonata\AdminSearchBundle\Filter\DateTimeFilter::class, null, 'datetime', array(
'format' => 'c'
))
->add('date', Sonata\AdminSearchBundle\Filter\DateTimeFilter::class, null, 'datetime', [
'format' => 'c',
])
;
}

The format must be a string formatted according to the `php format date`_ and be the one used to map the data in elasticsearch. If it is not the same, ElasticSearch will raise an exception ``failed to parse date field [15/05/28] Invalid format``
The format must be a string formatted according to the `php format date`_ and be the one used
to map the data in elasticsearch. If it is not the same, ElasticSearch will raise an exception
``failed to parse date field [15/05/28] Invalid format``.

.. _php format date: http://php.net/manual/en/function.date.php
Loading

0 comments on commit 8737c07

Please sign in to comment.