Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #1

Draft
wants to merge 216 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
216 commits
Select commit Hold shift + click to select a range
7ef041f
Init project structure; Start ContentUsage tab
adriendupuis May 29, 2020
b7c8d9c
Remove forgotten debug dump
adriendupuis May 29, 2020
dd2889c
Fix grammar in content_usage.html.twig
adriendupuis May 29, 2020
95ba036
content_type_group.name → content_type_group.identifier
adriendupuis May 29, 2020
4fde2cc
(minor) Change case (same case than “All scheduled”)
adriendupuis May 29, 2020
78091bf
Coding standards
adriendupuis May 30, 2020
da1d359
content_usage.html.twig: Enh. content type usage list
adriendupuis May 30, 2020
a5efe36
Coding Standards: There is no tests yet
adriendupuis May 30, 2020
40ff7d7
Coding Standards: There is no composer.lock
adriendupuis May 30, 2020
1079bdc
require php-cs-fixer
adriendupuis May 30, 2020
9bbcccc
README.md: TODO list
adriendupuis May 30, 2020
cd51b86
README.md + “Install” section
adriendupuis Jun 1, 2020
ec0f4af
Start Content menu sub-item structure
adriendupuis Jun 1, 2020
c1ecb0a
Start Content Usage inner Tab Group; Translations
adriendupuis Jun 1, 2020
145572d
Continue a bit the Example Finder
adriendupuis Jun 1, 2020
dfc8bb6
Continue Example Finder: Add field table
adriendupuis Jun 2, 2020
8cf792b
README.md + “Install” section
adriendupuis Jun 1, 2020
ca212c1
parameters.yaml with ideas
adriendupuis Jun 2, 2020
be7e58c
Merge branch 'develop' into feature/stats
adriendupuis Jun 2, 2020
3e9031a
Continue Example Finder UI
adriendupuis Jun 2, 2020
d26d0ce
Implement Example Finder's search
adriendupuis Jun 2, 2020
2e7270b
Example Finder's search JS: Fix best example overriding
adriendupuis Jun 2, 2020
fb5a8a7
Example Finder's HTML: Fix irrelevant bad example cell
adriendupuis Jun 2, 2020
eb29f35
GitHub Action: Do not install dependencies from composer.json
adriendupuis Jun 2, 2020
7de96eb
GitHub Action: Do not install dependencies from composer.json
adriendupuis Jun 2, 2020
0a5bcb9
GitHub Action: Do not install dependencies from composer.json
adriendupuis Jun 2, 2020
eb79bc0
GitHub Action: Replace Admin UI dependency with PHP CS Fixer
adriendupuis Jun 2, 2020
204bb06
GitHub Action: Replace Admin UI dependency with PHP CS Fixer (split)
adriendupuis Jun 2, 2020
38a3732
Merge pull request #3 from adriendupuis/fix/github
adriendupuis Jun 2, 2020
177d174
Merge branch 'develop' into feature/stats
adriendupuis Jun 2, 2020
3725db8
Move JS and CSS to files; set ez.config.js
adriendupuis Jun 2, 2020
e04382f
Move JS and CSS to files: Fix URLs and ExampleFinder class availability
adriendupuis Jun 2, 2020
f67a5bc
Move JS and CSS to files: Move event handler
adriendupuis Jun 2, 2020
58ae639
Move JS to files: Move construction to content_usage.js
adriendupuis Jun 2, 2020
85f18ca
Refacto: ContentUsage → ContentTypeUsage
adriendupuis Jun 2, 2020
2abc07c
exampleFinderSearchAction: Remove unused variables
adriendupuis Jun 2, 2020
963edc4
example_finder.html.twig: Update definition term according to column …
adriendupuis Jun 2, 2020
021dd47
Continue translation
adriendupuis Jun 3, 2020
7eb888a
Finish example_finder_table.html.twig translation
adriendupuis Jun 3, 2020
e2bf211
example_finder_table.html.twig: Column swap; Fixes
adriendupuis Jun 3, 2020
238da21
(minor) Seems like routing will never be loaded by the bundle
adriendupuis Jun 3, 2020
3708943
ContentUsageMenuListener: Translate
adriendupuis Jun 3, 2020
4c31ead
ContentUsageMenuListener: Translate (simplification and clean-up)
adriendupuis Jun 3, 2020
739b26d
Translate content_type_usage.html.twig
adriendupuis Jun 3, 2020
ed267c9
Continue example_finder.html.twig translation
adriendupuis Jun 3, 2020
02836ea
Continue example_finder.html.twig translation
adriendupuis Jun 3, 2020
d9626cc
Continue example_finder.html.twig translation
adriendupuis Jun 3, 2020
e9544aa
Continue example_finder.html.twig translation
adriendupuis Jun 3, 2020
9edc9bd
*.xliff: <file> tag attributes clean-up
adriendupuis Jun 3, 2020
e49fac9
example_finder.html.twig: Clean-up URL making
adriendupuis Jun 3, 2020
46edd51
Content URL computed on controller side
adriendupuis Jun 3, 2020
b3d466c
(minor) php-cs-fixer fix --rules=@Symfony src/;
adriendupuis Jun 3, 2020
13c4a96
*.xliff: <file>: `original` attribute is required
adriendupuis Jun 3, 2020
4382761
ContentUsageController: Fix translation Ignore annotation usage
adriendupuis Jun 8, 2020
8042ebe
ContentUsageController: Avoid Ignore annotation VS standards
adriendupuis Jun 8, 2020
ae1ae3b
ContentUsageController: Avoid Ignore annotation VS standards: rm use
adriendupuis Jun 8, 2020
3d18262
ContentUsageController: Avoid Ignore annotation VS standards: details
adriendupuis Jun 8, 2020
4af77cf
ContentUsageMenuListener implements TranslationContainerInterface
adriendupuis Jun 8, 2020
de3f1c6
ContentUsageMenuListener → ContentUsageMenuSubscriber
adriendupuis Jun 8, 2020
7618acf
Auto-load services (like ContentUsageMenuSubscriber)
adriendupuis Jun 8, 2020
5b564bd
standards.yml: Just remove ezplatform-admin-ui w/out updating
adriendupuis Jun 8, 2020
d676623
Style Example Finder's content type select
adriendupuis Jun 8, 2020
edb7b18
Move ExampleFinder dynamic config to a JS object
adriendupuis Jun 8, 2020
2a988fa
Add desc to content_type_usage.html.twig to few translations
adriendupuis Jun 8, 2020
6698fd3
Use willdurand/js-translation-bundle in ExampleFinder.js
adriendupuis Jun 8, 2020
f416d3c
ExampleFinder.js: Rewrote translations for translation:extract cmd
adriendupuis Jun 8, 2020
34f758e
Open a tab from URL hash (anchor)
adriendupuis Jun 9, 2020
8a90fc9
Open a tab from URL hash: Enable for main nav's tabs
adriendupuis Jun 9, 2020
e187852
Merge pull request #4 from adriendupuis/feature/tab
adriendupuis Jun 9, 2020
5cca695
Merge branch 'develop' into feature/stats
adriendupuis Jun 9, 2020
391d9ff
Update README.md
adriendupuis Jun 9, 2020
c22ef08
Revert "Auto-load services (like ContentUsageMenuSubscriber)"
adriendupuis Jun 9, 2020
2fed56e
ContentTypeUsage: Use a QueryBuilder
adriendupuis Jun 9, 2020
8001531
ContentTypeUsage: Move to a service
adriendupuis Jun 9, 2020
4761a5e
ContentUsageController: Move to a service
adriendupuis Jun 9, 2020
baa9e5a
ContentUsage: Fix content url building
adriendupuis Jun 9, 2020
87ec21e
ContentUsage: Fix neverEmptyFieldTypeIdentifierList & URLs
adriendupuis Jun 9, 2020
5dd0798
ContentUsageService::getContentTypeUsage: Do not exclude drafts
adriendupuis Jun 10, 2020
5af1626
The ExampleFinder only search in published contents.
adriendupuis Jun 10, 2020
005238c
(minor) Format services.yaml
adriendupuis Jun 10, 2020
790143d
ContentTypeUsage.php: minor adjustments
adriendupuis Jun 11, 2020
a27e309
Start language usage tab w/ “database VS config” check
adriendupuis Jun 11, 2020
40bbe30
Tab Opener: Enh. redirect w/ a modal information to wait
adriendupuis Jun 11, 2020
fc3bc59
LanguageUsage: content counts
adriendupuis Jun 11, 2020
c186999
LanguageUsage: a lang in config but not in repo also causes fatal errors
adriendupuis Jun 11, 2020
1da0c4e
LanguageUsage: continue translation
adriendupuis Jun 11, 2020
5a3b922
main.html.twig: Fix breadcrumb translation
adriendupuis Jun 11, 2020
3205868
Language Usage: continue translation
adriendupuis Jun 11, 2020
3ced779
ContentUsageService::getLanguageUsage: Use QueryBuilder
adriendupuis Jun 11, 2020
03f690c
README.md: Update feature list
adriendupuis Jun 11, 2020
84de8b0
LanguageUsage: a lang only in config won't cause fatal error
adriendupuis Jun 12, 2020
dccc570
Switch to SCSS
adriendupuis Jun 12, 2020
d117c1a
Switch to SCSS
adriendupuis Jun 12, 2020
e977e82
(minor) Adjust CSS
adriendupuis Jun 12, 2020
33b509d
(minor) Adjust CSS: Fix space under tabs
adriendupuis Jun 12, 2020
18376c4
Move missing language study from tab to a service
adriendupuis Jun 12, 2020
1d195ac
PHP CS Fixer w/ Symfony rules
adriendupuis Jun 12, 2020
b66a9b1
Tab Opener: Enh. redirect w/ a modal information to wait
adriendupuis Jun 11, 2020
fd31d32
ContentUsageService::findExamples: Add language filtering
adriendupuis Jun 12, 2020
da92d17
ExampleFinder: Add language filtering
adriendupuis Jun 12, 2020
e5a4c7e
Update ExampleFinder's translations
adriendupuis Jun 12, 2020
35fb3f6
ExampleFinder.js: Factorize a bit
adriendupuis Jun 12, 2020
f865edf
TabOpener: Reopen tab on page reload
adriendupuis Jun 12, 2020
5c8f19f
ContentUsageMenuSubscriber.php: As 0 is the default priority, skip it
adriendupuis Jun 15, 2020
7a8ea5f
Example Finder: Move inline style to CSS file
adriendupuis Jun 16, 2020
df58d13
Example Finder: Use a Form Type
adriendupuis Jun 16, 2020
34e5bf5
(minor) Format ends of files
adriendupuis Jun 16, 2020
cb7eedf
ExampleFinder.js: Handle search error
adriendupuis Jun 16, 2020
d472aca
ExampleFinder: Enh. layout
adriendupuis Jun 16, 2020
1d5cbc1
Format translation files w/ extractor
adriendupuis Jun 16, 2020
17ff6e5
Sort translations w/ prefixes
adriendupuis Jun 16, 2020
d961d7c
Sort translations w/ prefixes (fix an id and a key)
adriendupuis Jun 16, 2020
c277f62
Merge branch 'develop' into feature/stats
adriendupuis Jun 16, 2020
ee77647
tab_opener.js' translations
adriendupuis Jun 16, 2020
01609dd
tab_opener.js' translations (not new anymore)
adriendupuis Jun 16, 2020
7170a3c
Merge pull request #2 from adriendupuis/feature/stats
adriendupuis Jun 16, 2020
4367404
Merge branch 'develop' into feature/nav
adriendupuis Jun 16, 2020
b5c3bb8
Simplify reopen on reload: Re-use hash instead of introducing cookies
adriendupuis Jun 18, 2020
068d6b2
(minor) tab_opener.js: clean-up modal's CSS classes a bit
adriendupuis Jun 18, 2020
4bc8bdb
tab_opener.js: Use template literal for modal's HTML
adriendupuis Jun 18, 2020
212e4c2
(minor) tab_opener.js: Enh. comment
adriendupuis Jun 19, 2020
94553a3
README.md: one more Tab Opener example
adriendupuis Jun 19, 2020
7f307fa
Merge pull request #6 from adriendupuis/feature/nav
adriendupuis Jun 19, 2020
cc6d7f4
Add CreateUserCommand
adriendupuis Jun 19, 2020
05bcf74
CreateUserCommand: Add sudo capability
adriendupuis Jun 19, 2020
589cf17
CreateUserCommand: Rework arg/opt; Simplify dependency injection.
adriendupuis Jun 19, 2020
de74511
CreateUserCommand: Do not load an admin user when using --sudo
adriendupuis Jun 19, 2020
f4ce282
Add ChangePasswordCommand
adriendupuis Jun 19, 2020
8f4e08e
ChangePasswordCommand: Enh. error handling and output
adriendupuis Jun 21, 2020
4c5738c
README.md: Remove done task from TODO list
adriendupuis Jun 21, 2020
95dd07a
parameters.yaml: Add notice
adriendupuis Jun 21, 2020
0bbe0df
(minor) language_usage.html.twig: enh. language code display
adriendupuis Jun 21, 2020
f9d7f0f
services.yaml: Simplify with autoconfigure
adriendupuis Jun 22, 2020
84d2fbd
Merge branch 'develop' into feature/user
adriendupuis Jun 22, 2020
4b75c17
services.yaml: Simplify with autoconfigure
adriendupuis Jun 22, 2020
281af22
ContentUsageController: Declare $translator property
adriendupuis Jun 30, 2020
a2b6383
Add identification feature
adriendupuis Jun 30, 2020
0e8c7f0
Identification: continue translation
adriendupuis Jun 30, 2020
5f5de9a
README.md + identification feature
adriendupuis Jun 30, 2020
fd56109
README.md + identification feature
adriendupuis Jun 30, 2020
c3a2c12
Identification: style
adriendupuis Jun 30, 2020
9880df7
content_usage.scss: Nest rules
adriendupuis Jun 30, 2020
f5e5276
Merge branch 'develop' into feature/identification
adriendupuis Jun 30, 2020
8926a3c
Example Finder: Add field usage ratio
adriendupuis Jun 30, 2020
07855d1
Example Finder: field usage translations
adriendupuis Jun 30, 2020
6a2b5e4
content_usage.scss: Fix (bad examples) list style
adriendupuis Jun 30, 2020
f84f39e
README.md: Add field usage stats to Example Finder desc
adriendupuis Jun 30, 2020
3e5b8e2
(minor) Format src/bundle/Controller/IdentificationController.php
adriendupuis Jul 1, 2020
0966623
(minor) French translation rephrase
adriendupuis Jul 1, 2020
217d754
identification.html.twig styling
adriendupuis Jul 1, 2020
ec853b9
orderNumber actually only works on User Menu
adriendupuis Jul 1, 2020
2afa308
Merge pull request #8 from adriendupuis/feature/identification
adriendupuis Jul 1, 2020
768c95d
Merge branch 'develop' into feature/field_usage
adriendupuis Jul 1, 2020
7f031da
ExampleFinder: Hide language select when there is only one
adriendupuis Jul 1, 2020
d731012
ExampleFinder: Rename tab
adriendupuis Jul 1, 2020
c90e424
Tabs: Fix @Desc annotation usage
adriendupuis Jul 1, 2020
82b79ff
Tabs: Fix @Desc annotation usage
adriendupuis Jul 1, 2020
63ce23a
ExampleFinder.js: Simplify displayFieldUsage
adriendupuis Jul 1, 2020
d5d077c
ExampleFinder.js: Simplify displayFieldUsage
adriendupuis Jul 1, 2020
facc6ab
ExampleFinder.js: More method chaining
adriendupuis Jul 1, 2020
a461de7
ExampleFinder.js: More chained methods
adriendupuis Jul 1, 2020
4aa9c32
Merge pull request #9 from adriendupuis/feature/field_usage
adriendupuis Jul 1, 2020
b0ed10d
Language Usage: Display language without content, add link to language
adriendupuis Jul 1, 2020
fe86f26
(minor) Format IdentificationType.php: typehint
adriendupuis Jul 2, 2020
e7236cf
Update for ezplatform-admin-ui 2.1
adriendupuis Jul 20, 2020
f267f93
Still compatible w/ 2.0
adriendupuis Jul 20, 2020
450a6f8
Merge pull request #10 from adriendupuis/v3.1.0
adriendupuis Jul 20, 2020
c662431
composer.json: Add a homepage
adriendupuis Jul 29, 2020
cf9b93f
Add landing page usage tab
adriendupuis Jul 30, 2020
d1a385f
landing_page_usage.html.twig: Display unused layouts and unused blocks
adriendupuis Jul 31, 2020
367aee2
landing_page_usage.html.twig: Display unused layouts and unused blocks
adriendupuis Jul 31, 2020
a4ee95e
Landing Page Usage: Start translation
adriendupuis Jul 31, 2020
1cc6dd0
Format ContentUsageService.php
adriendupuis Jul 31, 2020
2893a5d
Standardize ContentUsageService.php
adriendupuis Jul 31, 2020
a2b5202
Remove Landing Page tab if there is no ezplatform-page-fieldtype
adriendupuis Aug 3, 2020
9288792
Format src/bundle/EventSubscriber/ContentUsageTabGroupSubscriber.php
adriendupuis Aug 3, 2020
b5ab0c0
landing_page_usage.html.twig: Continue translation
adriendupuis Aug 4, 2020
b02845b
Enh. ezlandingpage admin preview
adriendupuis Aug 12, 2020
2980abb
Use ConditionalTabInterface instead of TabEvents::TAB_GROUP_PRE_RENDER
adriendupuis Jan 22, 2021
30d9295
Add ezuser:enable command; Factorize user updating commands
adriendupuis Jan 26, 2021
78a1be5
Update ezuser:create to harmonize w/ other ezuser: commands
adriendupuis Jan 26, 2021
bf951e9
standards.yml: Use PHP 7.4
adriendupuis Jan 26, 2021
67a5624
Fix ChangePasswordCommand.php code standard
adriendupuis Jan 26, 2021
0decdec
Merge pull request #7 from adriendupuis/feature/user
adriendupuis Jan 26, 2021
d888244
Merge branch 'develop' into feature/ezlandingpage
adriendupuis Jan 26, 2021
fc86266
Merge pull request #11 from adriendupuis/feature/ezlandingpage
adriendupuis Jan 26, 2021
f1f54fc
Create sub-namespace `Command\User`
adriendupuis Jan 28, 2021
02cd144
Update README.md
adriendupuis Jan 28, 2021
fde9e68
standards.yml: Update JMSTranslationBundle annotations clearing
adriendupuis Jan 28, 2021
ac9ade8
README.md: Deduplicate --bundle option
adriendupuis Feb 23, 2021
9958842
Merge remote-tracking branch 'origin/develop' into develop
adriendupuis Feb 23, 2021
792efd6
README.md: Format translation example
adriendupuis Feb 25, 2021
9b553d6
README.md: Fix grammar
adriendupuis Feb 25, 2021
eefe54b
README.md: Format
adriendupuis Feb 25, 2021
511db24
content_type_usage.html.twig: Link to content type search result
adriendupuis Feb 25, 2021
8a79019
content_type_usage.html.twig: Link to content type search result
adriendupuis Feb 25, 2021
43e1c4c
ContentUsageService::getContentTypeUsage counts only STATUS_PUBLISHED
adriendupuis Feb 25, 2021
edc75d5
Update standards.yml: disable phpdoc_to_comment rule fixer
adriendupuis Mar 2, 2021
f2321e7
UpdateUserCommandAbstract.php: Add missing `self::`; Adjust a typehint
adriendupuis Mar 15, 2021
5218cd1
Create an AdminCommandAbstract to factorize admin commands
adriendupuis Mar 15, 2021
58e70aa
Add ezplatform:language:add command
adriendupuis Mar 15, 2021
cca8e69
Menu: Avoid error when there is no Admin Menu
adriendupuis Apr 1, 2021
22fc85c
Split services.yaml
adriendupuis Apr 9, 2021
06b92e7
Split services.yaml
adriendupuis Apr 9, 2021
114009b
Code Standard in src/bundle/EventSubscriber/
adriendupuis May 27, 2021
66cc809
AddLanguageToRepository → AddLanguageToRepositoryCommand
adriendupuis Jul 1, 2021
b4c0d95
Add `ezplatform:slug:test` command
adriendupuis Jul 1, 2021
712d38d
services.yaml: load whole services/* directory using joker
adriendupuis Jul 2, 2021
4b80438
`e:slug:test`: Use service injected conf instead of PHP class default
adriendupuis Jul 2, 2021
89f1460
README.md: Add two commands
adriendupuis Jul 2, 2021
34e7f1a
Protect TestSlugConverterConfigCommand::getSlugConverterConfiguration
adriendupuis Jul 13, 2021
258fef2
(minor) `ezplatform:language:add` more detailed code arg desc
adriendupuis Jul 30, 2021
a484a1f
ezuser:anonymous:siteaccess: Add a siteaccess to Anonymous's user/login
adriendupuis Jul 30, 2021
c608111
ezuser:anonymous:siteaccess: Add a siteaccess to Anonymous's user/login
adriendupuis Aug 2, 2021
a5e3c6b
OutputStyleTrait to add `warning` and `notice` style
adriendupuis Aug 2, 2021
670027e
Allow routes only to siteaccess_group_whitelist
adriendupuis Aug 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Coding Standards

on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer, php-cs-fixer

- name: Validate composer.json
run: composer validate

- name: Remove eZ Platform Admin UI's dependency
run: composer remove ezsystems/ezplatform-admin-ui --no-interaction --no-update

- name: Validate coding standards in source
run: php-cs-fixer fix --dry-run --rules=@Symfony,-phpdoc_to_comment src/

# - name: Validate coding standards in test suite
# run: vendor/bin/php-cs-fixer fix --dry-run --rules=@Symfony tests/
59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,61 @@ Adrien Dupuis' eZ Platform Admin Extension Bundle

Bundle to
- extended eZ Platform Admin UI
- add command line administration tools
- add command line administration tools


Install
-------

1. Add to [composer.json `repositories`](https://getcomposer.org/doc/04-schema.md#repositories): `{ "type": "vcs", "url": "https://github.com/adriendupuis/ezplatform-admin.git" }`
1. Execute `composer require adriendupuis/ezplatform-admin;`
1. Add to config/bundles.php: `AdrienDupuis\EzPlatformAdminBundle\AdrienDupuisEzPlatformAdminBundle::class => ['all' => true],`
1. Execute `cp vendor/adriendupuis/ezplatform-admin/src/bundle/Resources/config/routes/adriendupuis_admin.yaml config/routes/adriendupuis_admin.yaml;`
1. Pick ideas from [parameters.yaml](src/bundle/Resources/config/parameters.yaml) or fully import it; from, for example, config/services.yaml:
```yaml
imports:
- { resource: ../vendor/adriendupuis/ezplatform-admin/src/bundle/Resources/config/parameters.yaml }
```


Features
--------

* Content Usage
- Content Type Usage: Content count per content type.
- Field Usage (Example Finder): Find best and bad content examples for each field of a content type, and report field usage statistics.
- Language Usage: Content count per language.
- Landing Page Usage: Layout usage count and block usage count.
* Admin
- Identification: Find content, location, content type or content type field definitions from an ID or an identifier (like `1`, `folder`, `user*` or `ez*text`)
* Navigation
- Tab Opener: Open a tab according to URL hash. Examples: Right-click on a tab and open it in a new window, the tab is active; Reload a page, tab is still active.
* Commands
- `ezuser:create` to create a user
- `ezuser:password` to change a user password
- `ezuser:enable` to enable a user
- `ezuser:anonymous:siteaccess` to add a siteaccess to the Anonymous's user/login policy limitation.
- `ezplatform:language:add` to add a language to the database
- `ezplatform:slug:test` to test transformation of text into slug


Contribute
----------

### Translations

English example:
```shell
bin/console translation:extract en \
--bundle AdrienDupuisEzPlatformAdminBundle \
--output-dir vendor/adriendupuis/ezplatform-admin/src/bundle/Resources/translations/ \
--domain ad_admin_content_usage --domain ad_admin_identification \
;
```

### TODO

* Features
* Developments
* Quality
- Unit tests
13 changes: 13 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "adriendupuis/ezplatform-admin",
"description": "eZ Platform Administration Tools",
"homepage": "https://github.com/adriendupuis/ezplatform-admin",
"autoload": {
"psr-4": {
"AdrienDupuis\\EzPlatformAdminBundle\\": "src/bundle/"
}
},
"require": {
"ezsystems/ezplatform-admin-ui": "^2.0.0"
}
}
9 changes: 9 additions & 0 deletions src/bundle/AdrienDupuisEzPlatformAdminBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace AdrienDupuis\EzPlatformAdminBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AdrienDupuisEzPlatformAdminBundle extends Bundle
{
}
45 changes: 45 additions & 0 deletions src/bundle/Command/AddLanguageToRepositoryCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace AdrienDupuis\EzPlatformAdminBundle\Command;

use eZ\Publish\API\Repository\LanguageService;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class AddLanguageToRepositoryCommand extends AdminCommandAbstract
{
protected static $defaultName = 'ezplatform:language:add';

/** @var LanguageService */
private $languageService;

protected function configure(): void
{
parent::configure();
$this->setDescription('Create a new language')
->addArgument('code', InputArgument::REQUIRED, 'Language code as <ISO 639‑2/B>-<ISO 3166-1 alpha-2>, in other words <three_lowercase_language>-<two_uppercase_country>; Examples: eng-GB, eng-US, fre-FR, fre-CA')
->addArgument('name', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'Language name; Traditionally as full language name in itself followed by country in parentheses; Examples: English (United Kingdom), English (United States), Français (France), Français (Canada)');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->languageService = $this->repository->getContentLanguageService();

$initCode = $this->initAdminFunctionExecution($input, $output);

if (self::SUCCESS === $initCode) {
return $this->executeAdminFunction(function () {
$languageCreateStruct = $this->languageService->newLanguageCreateStruct();
$languageCreateStruct->languageCode = $this->input->getArgument('code');
$languageCreateStruct->name = implode(' ', $this->input->getArgument('name'));
$languageCreateStruct->enabled = true;
$this->languageService->createLanguage($languageCreateStruct);

return self::SUCCESS;
});
} else {
return $initCode;
}
}
}
99 changes: 99 additions & 0 deletions src/bundle/Command/AdminCommandAbstract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

namespace AdrienDupuis\EzPlatformAdminBundle\Command;

use eZ\Publish\API\Repository\Exceptions\NotFoundException;
use eZ\Publish\API\Repository\PermissionResolver;
use eZ\Publish\API\Repository\Repository;
use eZ\Publish\API\Repository\UserService;
use eZ\Publish\API\Repository\Values\User\User;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

abstract class AdminCommandAbstract extends Command
{
public const SUCCESS = 0;
public const FAILURE = 1;
public const ERROR_ADMIN_NOT_FOUND = 2;

/** @var Repository */
protected $repository;

/** @var UserService */
protected $userService;

/** @var PermissionResolver */
protected $permissionResolver;

/* @var User */
protected $admin;

/** @var InputInterface */
protected $input;

/** @var OutputInterface */
protected $output;

public function __construct(Repository $repository)
{
parent::__construct(self::$defaultName);
$this->repository = $repository;
$this->userService = $this->repository->getUserService();
$this->permissionResolver = $this->repository->getPermissionResolver();
}

protected function configure(): void
{
$this->addOption('admin', 'a', InputOption::VALUE_REQUIRED, 'Login of the admin user creating this new user; If not given, sudo is used');
}

protected function initAdminFunctionExecution(InputInterface $input, OutputInterface $output): int
{
$this->input = $input;
$this->output = $output;

if ($input->getOption('admin')) {
$this->admin = $this->loadUser($input->getOption('admin'));
}
if (null === $this->admin) {
if ($input->getOption('admin')) {
return self::ERROR_ADMIN_NOT_FOUND;
} else {
$output->writeln('<info>sudo will be used.</info>');
}
} else {
$this->permissionResolver->setCurrentUserReference($this->admin);
}

return self::SUCCESS;
}

protected function executeAdminFunction($function): int
{
if (null === $this->admin) {
return $this->repository->sudo($function);
} else {
return $function();
}
}

protected function loadUser($loginOrEmail): ?User
{
/* @var User|null $user */
$user = null;

try {
$user = $this->userService->loadUserByLogin($loginOrEmail);
} catch (NotFoundException $notFoundException) {
try {
$user = $this->userService->loadUserByEmail($loginOrEmail);
} catch (NotFoundException $notFoundException) {
$this->output->writeln("<error>User '$loginOrEmail' not found.</error>");
}
}

return $user;
}
}
24 changes: 24 additions & 0 deletions src/bundle/Command/OutputStyleTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace AdrienDupuis\EzPlatformAdminBundle\Command;

use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Output\OutputInterface;

trait OutputStyleTrait
{
/**
* Add styles corresponding to error levels.
*/
public function setStyle(OutputInterface $output)
{
// https://symfony.com/doc/current/console/coloring.html
foreach ([
'notice' => new OutputFormatterStyle('blue'),
'warning' => new OutputFormatterStyle(null, 'yellow'),
'debug' => new OutputFormatterStyle(null, 'magenta'),
] as $name => $style) {
$output->getFormatter()->setStyle($name, $style);
}
}
}
Loading