Skip to content

Commit

Permalink
Merge branch 'release/2.6.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu2607 committed Nov 5, 2024
2 parents 5e94efb + 437d5c6 commit b1a365f
Show file tree
Hide file tree
Showing 22 changed files with 1,157 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Company Bundle code review

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

jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql, zip

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --no-interaction --no-progress

- name: Check for vulnerabilities
uses: symfonycorp/security-checker-action@v4

- name: Run Easy Coding Standard
run: vendor/bin/ecs check src
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.idea/
vendor
composer.lock
31 changes: 31 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Changelog

## 2.6.1 (05/11/2024)

- Remove composer.lock

## 2.6.0 (21/05/2024)

+ Symfony 6 and Sulu 2.6 compatible

## 2.4.1 (09/06/2022)

+ Add total number of Google reviews

## 2.4.0 (08/06/2022)

+ Add a command to retrieve timetables via Google MyBusiness
+ Schedule management via twig

## 1.0.2 (27/05/2022)

+ Add cell phone and google my business fields

## 1.0.1 (25/05/2022)

+ Update readme
- Fix composer

## 1.0.0 (25/05/2022)

+ Bundle launch
48 changes: 48 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name" : "pixelopen/sulu-companybundle",
"type": "sulu-bundle",
"description": "Company tools for Sulu",
"keywords": [
"sulu",
"sulu-bundle"
],
"homepage": "https://github.com/Pixel-Open/sulu-companybundle",
"license": "MIT",
"authors": [
{
"name": "Pixel Open"
}
],
"require": {
"php": "^8.0",
"sulu/sulu": "^2.4",
"symfony/config": "^5.0 || ^6.0",
"symfony/dependency-injection": "^5.0 || ^6.0",
"symfony/framework-bundle": "^5.0 || ^6.0",
"symfony/http-foundation": "^5.0 || ^6.0",
"symfony/http-kernel": "^5.0 || ^6.0",
"symfony/http-client": "^5.0 || ^6.0"
},
"require-dev": {
"dantleech/phpcr-migrations-bundle": "^1.3",
"jackalope/jackalope-doctrine-dbal": "^1.3.2",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-symfony": "^1.2",
"symplify/easy-coding-standard": "^11.1"
},
"scripts": {
},
"autoload": {
"psr-4": {
"Pixel\\CompanyBundle\\": "src"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": true,
"phpstan/extension-installer": true
}
}
}
22 changes: 22 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([__DIR__ . '/src']);
$ecsConfig->ruleWithConfiguration(ArraySyntaxFixer::class, [
'syntax' => 'short',
]);

$ecsConfig->sets([
// run and fix, one by one
//SetList::SPACES,
SetList::ARRAY,
SetList::DOCBLOCK,
SetList::PSR_12,
]);
};
8 changes: 8 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
level: 6

paths:
- src

ignoreErrors:
- "#Offset '[a-zA-Z]+' does not exist on string#"
118 changes: 118 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Sulu Company bundle

![GitHub release (with filter)](https://img.shields.io/github/v/release/Pixel-Developpement/sulu-companybundle?style=for-the-badge)
[![Dependency](https://img.shields.io/badge/sulu-2.5-cca000.svg?style=for-the-badge)](https://sulu.io/)

## Presentation

A Sulu bundle to easily manage the company information.

## Features
* Company information management
* Manual or automatic (via Google My Business) hours management

## Requirements

* PHP >= 8.0
* Sulu >= 2.5
* Symfony >= 5.4

## Installation

### Install the bundle

Execute the following [composer](https://getcomposer.org/) command to add the bundle to the dependencies of your
project:

```bash
composer require pixeldev/sulu-companybundle --with-all-dependencies
```

### Enable the bundle

Enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```php
return [
/* ... */
Pixel\CompanyBundle\CompanyBundle::class => ['all' => true],
];
```

### Update schema
```shell script
bin/console do:sch:up --force
```

## Bundle Config

Define the Admin Api Route in `routes_admin.yaml`
```yaml
company.setting_api:
type: rest
prefix: /admin/api
resource: pixel_company.settings_route_controller
name_prefix: company.
```
## Use
## General use
To access the company settings, on the administration interface, go to the Settings section and click on "Company management".
Once on the form, fill the fields that are relevant/useful for your needs.
Do not forget to click on "Save" to have the information stored and available.
## Twig extension
This bundle comes with several twig function that you can use to get the previously filled information:
**company_settings()**: returns all the settings of the company. No parameters are required.
Example of use:
```twig
{% set companySettings = company_settings() %}
<p>{{ companySettings.name }}</p>
```

**get_company_hours()**: renders a view which display the hours of the company (no matter the way they have been filled). No parameters are required.

Example of use:
```twig
<div id="myHours">
{{ get_company_hours() }}
</div>
```

**get_google_review()**: returns the average rating and the total rating. No parameters are required.

Example of use:
```twig
{% set ratingInfo = get_google_review() %}
{% if ratingInfo is not null %}
<div class="noteGoogle">
<p>Note : {{ ratingInfo.rating }}</p>
<ul class="star">
<li><img src="{{ asset('/assets/images/noteGoogle/star.svg') }}" alt=""></li>
<li><img src="{{ asset('/assets/images/noteGoogle/star.svg') }}" alt=""></li>
<li><img src="{{ asset('/assets/images/noteGoogle/star.svg') }}" alt=""></li>
<li><img src="{{ asset('/assets/images/noteGoogle/star.svg') }}" alt=""></li>
<li><img src="{{ asset('/assets/images/noteGoogle/star.svg') }}" alt=""></li>
<li>
More than <strong>{{ ratingInfo.total_rating }}</strong> avis
</li>
</ul>
</div>
{% endif %}
```

### Use Google My Business
To retrieve the hours of the company via Google, fill the place ID and the API key fields and check the "Use the hours stored in Google My Business?".
Then, you need to run the following command:
```bash
bin/console sync:google:informations
```

This will retrieve, the rating, the opening hours and the total number of rating available and are ready to use.

## Contributing
You can contribute to this bundle. The only thing you must do is respect the coding standard we implements.
You can find them in the `ecs.php` file.
78 changes: 78 additions & 0 deletions src/Admin/SettingAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

declare(strict_types=1);

namespace Pixel\CompanyBundle\Admin;

use Pixel\CompanyBundle\Entity\Setting;
use Sulu\Bundle\AdminBundle\Admin\Admin;
use Sulu\Bundle\AdminBundle\Admin\Navigation\NavigationItem;
use Sulu\Bundle\AdminBundle\Admin\Navigation\NavigationItemCollection;
use Sulu\Bundle\AdminBundle\Admin\View\ToolbarAction;
use Sulu\Bundle\AdminBundle\Admin\View\ViewBuilderFactoryInterface;
use Sulu\Bundle\AdminBundle\Admin\View\ViewCollection;
use Sulu\Component\Security\Authorization\PermissionTypes;
use Sulu\Component\Security\Authorization\SecurityCheckerInterface;

class SettingAdmin extends Admin
{
public const TAB_VIEW = "company.settings";
public const FORM_VIEW = "company.settings.form";

private ViewBuilderFactoryInterface $viewBuilderFactory;
private SecurityCheckerInterface $securityChecker;

public function __construct(
ViewBuilderFactoryInterface $viewBuilderFactory,
SecurityCheckerInterface $securityChecker
) {
$this->viewBuilderFactory = $viewBuilderFactory;
$this->securityChecker = $securityChecker;
}

public function configureNavigationItems(NavigationItemCollection $navigationItemCollection): void
{
if ($this->securityChecker->hasPermission(Setting::SECURITY_CONTEXT, PermissionTypes::EDIT)) {
$navigationItem = new NavigationItem("company.settings");
$navigationItem->setPosition(2);
$navigationItem->setView(static::TAB_VIEW);
$navigationItemCollection->get(Admin::SETTINGS_NAVIGATION_ITEM)->addChild($navigationItem);
}
}

public function configureViews(ViewCollection $viewCollection): void
{
if ($this->securityChecker->hasPermission(Setting::SECURITY_CONTEXT, PermissionTypes::EDIT)) {
$viewCollection->add(
$this->viewBuilderFactory->createResourceTabViewBuilder(static::TAB_VIEW, "/company-settings/:id")
->setResourceKey(Setting::RESOURCE_KEY)
->setAttributeDefault("id", "-")
);
$viewCollection->add(
$this->viewBuilderFactory->createFormViewBuilder(static::FORM_VIEW, "/details")
->setResourceKey(Setting::RESOURCE_KEY)
->setFormKey(Setting::FORM_KEY)
->setTabTitle("sulu_admin.details")
->addToolbarActions([new ToolbarAction("sulu_admin.save")])
->setParent(static::TAB_VIEW)
);
}
}

/**
* @return mixed[]
*/
public function getSecurityContexts()
{
return [
self::SULU_ADMIN_SECURITY_SYSTEM => [
"Setting" => [
Setting::SECURITY_CONTEXT => [
PermissionTypes::VIEW,
PermissionTypes::EDIT,
],
],
],
];
}
}
Loading

0 comments on commit b1a365f

Please sign in to comment.