Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed Feb 1, 2020
2 parents 822b64d + fd21592 commit be90180
Show file tree
Hide file tree
Showing 28 changed files with 238 additions and 103 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
on: [push, pull_request]
name: Lint
jobs:
doctor-rst:
name: DOCtor-RST
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: DOCtor-RST
uses: docker://oskarstark/doctor-rst
with:
args: --short
env:
DOCS_DIR: 'docs/'
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: "pending author"
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: "pending author"
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.
30 changes: 30 additions & 0 deletions docs/.doctor-rst.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
rules:
blank_line_after_directive: ~
short_array_syntax: ~
no_app_console: ~
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: ~
yaml_instead_of_yml_suffix: ~
extend_abstract_admin: ~
final_admin_class: ~
final_admin_extension_classes: ~
kernel_instead_of_app_kernel: ~
no_admin_yaml: ~
no_app_bundle: ~
no_bash_prompt: ~
no_composer_phar: ~
no_config_yaml: ~
no_inheritdoc: ~
14 changes: 7 additions & 7 deletions docs/cookbook/recipe_lock_protection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ You can enable it in your ``sonata_admin`` configuration:
sonata_admin:
options:
lock_protection: true
You must also configure each entity that you want to support by adding a
field called ``$version`` on which the Doctrine ``Version`` feature is activated.

Expand All @@ -38,34 +38,34 @@ Using Annotations::
// src/Entity/Car.php

namespace App\Entity\Car;

use Doctrine\ORM\Mapping as ORM;

class Car
{
// ...

/**
* @ORM\Column(type="integer")
* @ORM\Version
*/
protected $version;

// ...
}

Using XML:

.. code-block:: xml
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!-- src/Resources/orm/Car.orm.xml -->
<doctrine-mapping>
<entity name="App\Entity\Car">
<!-- ... -->
<field name="version" type="integer" version="true"/>
<!-- ... -->
</entity>
</doctrine-mapping>
Expand Down
6 changes: 2 additions & 4 deletions docs/cookbook/recipe_sortable_sonata_type_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ We now need to create the join entity configuration, create the following file i

.. code-block:: xml
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
Expand Down Expand Up @@ -288,9 +288,7 @@ Part 3 : Update admin classes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is a very important part, the admin class **should** be created for the join entity. If you don't do that, the field will never display properly.
So we are going to start by creating this ``UserBundle\Admin\UserHasExpectationsAdmin.php`` ...

.. code-block:: php
So we are going to start by creating this ``UserBundle\Admin\UserHasExpectationsAdmin.php``::

namespace UserBundle\Admin;

Expand Down
12 changes: 5 additions & 7 deletions docs/getting_started/the_form_view.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,7 @@ While it's very friendly of the SonataAdminBundle to notify the admin of a
successful creation, the classname and some sort of hash aren't really nice to
read. This is the default string representation of an object in the
SonataAdminBundle. You can change it by defining a ``toString()`` method in the
Admin class. This receives the object to transform to a string as the first parameter:

.. note::

No underscore prefix! ``toString()`` is correct!

.. code-block:: php
Admin class. This receives the object to transform to a string as the first parameter::

// src/Admin/BlogPostAdmin.php

Expand All @@ -255,6 +249,10 @@ Admin class. This receives the object to transform to a string as the first para
}
}

.. note::

No underscore prefix! ``toString()`` is correct!

Round Up
--------

Expand Down
52 changes: 25 additions & 27 deletions docs/reference/action_create_edit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For more information about optional libraries:

.. note::

**TODO**:
**TODO**
* options available when adding fields, inc custom templates

Routes
Expand Down Expand Up @@ -64,32 +64,11 @@ For more detailed information about routes, see :doc:`routing`::
Adding form fields
------------------

Within the configureFormFields method you can define which fields should
be shown when editing or creating entities.
Each field has to be added to a specific form group. And form groups can
optionally be added to a tab. See `FormGroup options`_ for additional
information about configuring form groups.

Using the FormMapper add method, you can add form fields. The add method
has 4 parameters:

- ``name``: The name of your entity.
- ``type``: The type of field to show; by defaults this is ``null`` to let
Sonata decide which type to use. See :doc:`Field Types <field_types>`
for more information on available types.
- ``options``: The form options to be used for the field. These may differ
per type. See :doc:`Field Types <field_types>` for more information on
available options.
- ``fieldDescriptionOptions``: The field description options. Options here
are passed through to the field template. See :ref:`Form Types, FieldDescription
options <form_types_fielddescription_options>` for more information.

.. note::

The property entered in ``name`` should be available in your Entity
through getters/setters or public access.

.. code-block:: php
Within the ``configureFormFields`` method you can define which fields should
be shown when editing or creating entities. Each field has to be added to a
specific form group. And form groups can optionally be added to a tab.
See `FormGroup options`_ for additional information about configuring form
groups::

// src/Admin/PersonAdmin.php

Expand All @@ -110,6 +89,25 @@ has 4 parameters:
}
}

Using the FormMapper add method, you can add form fields. The add method
has 4 parameters:

- ``name``: The name of your entity.
- ``type``: The type of field to show; by defaults this is ``null`` to let
Sonata decide which type to use. See :doc:`Field Types <field_types>`
for more information on available types.
- ``options``: The form options to be used for the field. These may differ
per type. See :doc:`Field Types <field_types>` for more information on
available options.
- ``fieldDescriptionOptions``: The field description options. Options here
are passed through to the field template. See :ref:`Form Types, FieldDescription
options <form_types_fielddescription_options>` for more information.

.. note::

The property entered in ``name`` should be available in your Entity
through getters/setters or public access.

FormGroup options
~~~~~~~~~~~~~~~~~

Expand Down
12 changes: 5 additions & 7 deletions docs/reference/batch_actions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,7 @@ The method ``batchAction<MyAction>`` will be executed to process your batch in y
objects are passed to this method through a query argument which can be used to retrieve them.
If for some reason it makes sense to perform your batch action without the default selection
method (for example you defined another way, at template level, to select model at a lower
granularity), the passed query is ``null``.

.. note::

You can check how to declare your own ``CRUDController`` class in the Architecture section.

.. code-block:: php
granularity), the passed query is ``null``::

// src/Controller/CRUDController.php

Expand Down Expand Up @@ -127,6 +121,10 @@ granularity), the passed query is ``null``.
// ...
}

.. note::

You can check how to declare your own ``CRUDController`` class in the Architecture section.

(Optional) Overriding the batch selection template
--------------------------------------------------

Expand Down
4 changes: 1 addition & 3 deletions docs/reference/field_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ Parameter Description
;
}
The ``choice`` field type also supports multiple values that can be separated by a ``delimiter``.

.. code-block:: php
The ``choice`` field type also supports multiple values that can be separated by a ``delimiter``::

protected function configureListFields(ListMapper $listMapper)
{
Expand Down
18 changes: 18 additions & 0 deletions docs/reference/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,24 @@ can use ``hasParentFieldDescription()`` to detect this case and remove the route
}
}
Restoring a single route
^^^^^^^^^^^^^^^^^^^^^^^^
Any previously removed route can be restored by name::
// src/Admin/DeletableMediaAdmin.php
use Sonata\AdminBundle\Route\RouteCollection;
final class DeletableMediaAdmin extends MediaAdmin
{
protected function configureRoutes(RouteCollection $collection)
{
$collection->restore('delete');
}
}
Persistent parameters
---------------------
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ The ``AdminBundle`` comes with different key label generation strategies:

``sonata.admin.label.strategy.underscore`` will be better for i18n applications
and ``sonata.admin.label.strategy.native`` will be better for native (single) language
apps based on the field name. It is reasonable to start with the ``native`` strategy
and then, when the application needs to be translated using generic keys, the
applications based on the field name. It is reasonable to start with the ``native``
strategy and then, when the application needs to be translated using generic keys, the
configuration can be switched to ``underscore``.

The strategy can be quickly configured when the Admin class is registered in
Expand Down
4 changes: 3 additions & 1 deletion src/Command/ExplainAdminCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function configure(): void
$this->addArgument('admin', InputArgument::REQUIRED, 'The admin service id');
}

public function execute(InputInterface $input, OutputInterface $output): void
public function execute(InputInterface $input, OutputInterface $output): int
{
$admin = $this->pool->getInstance($input->getArgument('admin'));

Expand Down Expand Up @@ -160,5 +160,7 @@ public function execute(InputInterface $input, OutputInterface $output): void

$output->writeln('');
$output->writeln('<info>done!</info>');

return 0;
}
}
8 changes: 5 additions & 3 deletions src/Command/GenerateObjectAclCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function configure(): void
;
}

public function execute(InputInterface $input, OutputInterface $output): void
public function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('Welcome to the AdminBundle object ACL generator');
$output->writeln([
Expand All @@ -118,14 +118,14 @@ public function execute(InputInterface $input, OutputInterface $output): void
} catch (\Exception $e) {
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));

return;
return 1;
}
}

if (!$this->aclObjectManipulators) {
$output->writeln('No manipulators are implemented : <info>ignoring</info>');

return;
return 1;
}

foreach ($this->pool->getAdminServiceIds() as $id) {
Expand Down Expand Up @@ -167,6 +167,8 @@ public function execute(InputInterface $input, OutputInterface $output): void
\assert($admin instanceof AdminInterface);
$manipulator->batchConfigureAcls($output, $admin, $securityIdentity);
}

return 0;
}

/**
Expand Down
7 changes: 5 additions & 2 deletions src/Command/ListAdminCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@ public function configure(): void
$this->setDescription('List all admin services available');
}

public function execute(InputInterface $input, OutputInterface $output): void
public function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('<info>Admin services:</info>');
foreach ($this->pool->getAdminServiceIds() as $id) {
$instance = $this->pool->getInstance($id);
$output->writeln(sprintf(' <info>%-40s</info> %-60s',
$output->writeln(sprintf(
' <info>%-40s</info> %-60s',
$id,
$instance->getClass()
));
}

return 0;
}
}
Loading

0 comments on commit be90180

Please sign in to comment.