-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from oveleon/develop
Contao 5.1 support
- Loading branch information
Showing
25 changed files
with
452 additions
and
324 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Composer | ||
/composer.lock | ||
/vendor/ | ||
|
||
# PhpUnit | ||
/.phpunit.result.cache | ||
/phpunit.xml | ||
|
||
# IDE | ||
/.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: true | ||
|
||
Oveleon\ContaoGoogleRecommendationBundle\: | ||
resource: '../src/' | ||
exclude: '../src/{Model,DependencyInjection,Resources}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Oveleon\ContaoGoogleRecommendationBundle\GooglePlacesApi; | ||
|
||
// Back end modules | ||
$GLOBALS['BE_MOD']['content']['recommendation']['startSync'] = [GooglePlacesApi::class, 'syncWithGoogle']; | ||
$GLOBALS['BE_MOD']['content']['recommendation']['syncAllArchives'] = [GooglePlacesApi::class, 'syncAllArchives']; |
16 changes: 9 additions & 7 deletions
16
...esources/contao/dca/tl_recommendation.php → contao/dca/tl_recommendation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Oveleon Google Recommendation Bundle. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
$GLOBALS['TL_DCA']['tl_recommendation']['fields']['googleAuthorUrl'] = array | ||
( | ||
use Contao\CoreBundle\DataContainer\PaletteManipulator; | ||
|
||
$GLOBALS['TL_DCA']['tl_recommendation']['fields']['googleAuthorUrl'] = [ | ||
'exclude' => true, | ||
'inputType' => 'text', | ||
'eval' => array('maxlength'=>255, 'tl_class'=>'w50'), | ||
'eval' => ['maxlength'=>255, 'tl_class'=>'w50'], | ||
'sql' => "varchar(255) NOT NULL default ''" | ||
); | ||
]; | ||
|
||
// Extend the default palette | ||
Contao\CoreBundle\DataContainer\PaletteManipulator::create() | ||
->addLegend('google_legend', 'expert_legend', Contao\CoreBundle\DataContainer\PaletteManipulator::POSITION_BEFORE) | ||
->addField(array('googleAuthorUrl'), 'google_legend', Contao\CoreBundle\DataContainer\PaletteManipulator::POSITION_APPEND) | ||
PaletteManipulator::create() | ||
->addLegend('google_legend', 'expert_legend', PaletteManipulator::POSITION_BEFORE) | ||
->addField(array('googleAuthorUrl'), 'google_legend', PaletteManipulator::POSITION_APPEND) | ||
->applyToPalette('default', 'tl_recommendation') | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Oveleon Google Recommendation Bundle. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
use Contao\CoreBundle\DataContainer\PaletteManipulator; | ||
use Contao\System; | ||
use Oveleon\ContaoGoogleRecommendationBundle\EventListener\DataContainer\RecommendationArchiveListener; | ||
|
||
// Load language files | ||
System::loadLanguageFile('tl_recommendation_languages'); | ||
|
||
// Add global operations | ||
$GLOBALS['TL_DCA']['tl_recommendation_archive']['list']['global_operations']['syncAllArchives'] = [ | ||
'href' => 'key=syncAllArchives', | ||
'icon' => 'sync.svg', | ||
'attributes' => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['tl_recommendation_archive']['syncAllConfirm'] ?? null) . '\'))return false;Backend.getScrollOffset()"', | ||
]; | ||
|
||
// Add operations | ||
$GLOBALS['TL_DCA']['tl_recommendation_archive']['list']['operations']['startSync'] = [ | ||
'href' => 'key=startSync', | ||
'icon' => 'sync.svg', | ||
'attributes' => 'onclick="if(!confirm(\'' . ($GLOBALS['TL_LANG']['tl_recommendation_archive']['syncConfirm'] ?? null) . '\'))return false;Backend.getScrollOffset()"', | ||
'button_callback' => [RecommendationArchiveListener::class, 'addSyncButton'], | ||
]; | ||
|
||
// Add subpalettes | ||
$GLOBALS['TL_DCA']['tl_recommendation_archive']['fields']['syncWithGoogle'] = [ | ||
'exclude' => true, | ||
'inputType' => 'checkbox', | ||
'eval' => ['submitOnChange'=>true], | ||
'sql' => "char(1) NOT NULL default ''" | ||
]; | ||
|
||
$GLOBALS['TL_DCA']['tl_recommendation_archive']['fields']['googleApiToken'] = [ | ||
'exclude' => true, | ||
'inputType' => 'text', | ||
'eval' => ['doNotCopy'=>true, 'mandatory'=>true, 'maxlength'=>255, 'tl_class'=>'w50'], | ||
'sql' => "varchar(255) NOT NULL default ''" | ||
]; | ||
|
||
$GLOBALS['TL_DCA']['tl_recommendation_archive']['fields']['googlePlaceId'] = [ | ||
'exclude' => true, | ||
'inputType' => 'text', | ||
'eval' => ['doNotCopy'=>true, 'mandatory'=>true, 'maxlength'=>255, 'tl_class'=>'w50'], | ||
'sql' => "varchar(255) NOT NULL default ''" | ||
]; | ||
|
||
$GLOBALS['TL_DCA']['tl_recommendation_archive']['fields']['syncLanguage'] = [ | ||
'exclude' => true, | ||
'inputType' => 'select', | ||
'options_callback' => static function () | ||
{ | ||
return array_keys($GLOBALS['TL_LANG']['tl_recommendation_languages']); | ||
}, | ||
'reference' => &$GLOBALS['TL_LANG']['tl_recommendation_languages'], | ||
'eval' => ['doNotCopy'=>true, 'includeBlankOption'=>true, 'chosen'=>true,'tl_class'=>'w50'], | ||
'sql' => "varchar(5) NOT NULL default ''" | ||
]; | ||
|
||
$GLOBALS['TL_DCA']['tl_recommendation_archive']['palettes']['__selector__'][] = 'syncWithGoogle'; | ||
$GLOBALS['TL_DCA']['tl_recommendation_archive']['subpalettes']['syncWithGoogle'] = 'googleApiToken,googlePlaceId,syncLanguage'; | ||
|
||
// Extend the default palette | ||
PaletteManipulator::create() | ||
->addLegend('google_legend', 'protected_legend') | ||
->addField(['syncWithGoogle'], 'google_legend', PaletteManipulator::POSITION_APPEND) | ||
->applyToPalette('default', 'tl_recommendation_archive') | ||
; |
2 changes: 1 addition & 1 deletion
2
...contao/languages/de/tl_recommendation.xlf → contao/languages/de/tl_recommendation.xlf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...anguages/de/tl_recommendation_archive.xlf → ...anguages/de/tl_recommendation_archive.xlf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...guages/de/tl_recommendation_languages.xlf → ...guages/de/tl_recommendation_languages.xlf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...contao/languages/en/tl_recommendation.xlf → contao/languages/en/tl_recommendation.xlf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...anguages/en/tl_recommendation_archive.xlf → ...anguages/en/tl_recommendation_archive.xlf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...guages/en/tl_recommendation_languages.xlf → ...guages/en/tl_recommendation_languages.xlf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" colors="true" bootstrap="vendor/autoload.php"> | ||
<coverage> | ||
<include> | ||
<directory>./src</directory> | ||
</include> | ||
</coverage> | ||
<php> | ||
<ini name="error_reporting" value="-1"/> | ||
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/> | ||
<env name="SYMFONY_PATCH_TYPE_DECLARATIONS" value="deprecations=0"/> | ||
</php> | ||
<testsuites> | ||
<testsuite name="contao-google-recommendation-bundle"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<listeners> | ||
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/> | ||
</listeners> | ||
</phpunit> |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Oveleon Recommendation Bundle. | ||
* This file is part of Oveleon Google Recommendation Bundle. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
@@ -10,11 +10,10 @@ | |
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
/** | ||
* Configures the Contao google recommendation bundle. | ||
* | ||
* @author Fabian Ekert <[email protected]> | ||
*/ | ||
class ContaoGoogleRecommendationBundle extends Bundle | ||
{ | ||
public function getPath(): string | ||
{ | ||
return \dirname(__DIR__); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,6 @@ | |
use Oveleon\ContaoGoogleRecommendationBundle\ContaoGoogleRecommendationBundle; | ||
use Oveleon\ContaoRecommendationBundle\ContaoRecommendationBundle; | ||
|
||
/** | ||
* Plugin for the Contao Manager. | ||
* | ||
* @author Fabian Ekert <[email protected]> | ||
*/ | ||
class Plugin implements BundlePluginInterface | ||
{ | ||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Oveleon Google Recommendation Bundle. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
namespace Oveleon\ContaoGoogleRecommendationBundle\Cron; | ||
|
||
use Contao\CoreBundle\DependencyInjection\Attribute\AsCronJob; | ||
use Contao\CoreBundle\Framework\ContaoFramework; | ||
use Oveleon\ContaoGoogleRecommendationBundle\GooglePlacesApi; | ||
use Psr\Log\LoggerInterface; | ||
|
||
#[AsCronJob('daily')] | ||
class GetGoogleReviewsCron | ||
{ | ||
public function __construct(private ContaoFramework $framework, private LoggerInterface|null $logger) | ||
{ | ||
} | ||
|
||
public function __invoke(): void | ||
{ | ||
(new GooglePlacesApi)->getGoogleReviews(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/DependencyInjection/ContaoGoogleRecommendationExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Oveleon Google Recommendation Bundle. | ||
* | ||
* (c) https://www.oveleon.de/ | ||
*/ | ||
|
||
namespace Oveleon\ContaoGoogleRecommendationBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Extension\Extension; | ||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | ||
|
||
class ContaoGoogleRecommendationExtension extends Extension | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container): void | ||
{ | ||
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../../config')); | ||
$loader->load('services.yaml'); | ||
} | ||
} |
Oops, something went wrong.