diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index 2698faf..0000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: "2" # required to adjust maintainability checks -checks: - argument-count: - config: - threshold: 4 - complex-logic: - config: - threshold: 4 - file-lines: - config: - threshold: 400 - method-complexity: - config: - threshold: 5 - method-count: - config: - threshold: 20 - method-lines: - config: - threshold: 50 - nested-control-flow: - config: - threshold: 4 - return-statements: - config: - threshold: 4 - similar-code: - config: - threshold: # language-specific defaults. an override will affect all languages. - identical-code: - config: - threshold: # language-specific defaults. an override will affect all languages. \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 256bfd0..ca21ccc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 3.3.4 - 2023-10-14 +### Fixed +- Fixed an an error where deleted sections were still shown in the sitemap settings ([#82](https://github.com/studioespresso/craft-seo-fields/issues/82)) + + ## 3.3.3 - 2023-09-18 ### Fixed - Fixed an error when using a custom meta template ([#81](https://github.com/studioespresso/craft-seo-fields/issues/81)) diff --git a/codeception.yml b/codeception.yml deleted file mode 100755 index 34c9e38..0000000 --- a/codeception.yml +++ /dev/null @@ -1,24 +0,0 @@ -actor: Tester -paths: - tests: tests - log: tests/_output - data: tests/_data - support: tests/_support - envs: tests/_envs -bootstrap: _bootstrap.php -params: - - tests/.env -modules: - config: - \craft\test\Craft: - configFile: 'tests/_craft/config/test.php' - entryUrl: 'http://testing.local.statik.be/index.php' - projectConfig: {} - migrations: [] - plugins: - seo-fields: - class: 'studioespresso\seofields\SeoFields' - handle: seo-fields - cleanup: true - transaction: true - dbSetup: {clean: true, setupCraft: true} diff --git a/composer.json b/composer.json index 9c6e553..5b95bb2 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "studioespresso/craft-seo-fields", "description": "Fields for your SEO & OG meta data", "type": "craft-plugin", - "version": "3.3.3", + "version": "3.3.4", "keywords": [ "craft", "cms", diff --git a/phpstan.neon b/phpstan.neon deleted file mode 100644 index 27bcf81..0000000 --- a/phpstan.neon +++ /dev/null @@ -1,6 +0,0 @@ -parameters: - scanFiles: - - %currentWorkingDirectory%/vendor/yiisoft/yii2/Yii.php - - %currentWorkingDirectory%/vendor/craftcms/cms/src/Craft.php - - inferPrivatePropertyTypeFromConstructor: true \ No newline at end of file diff --git a/src/SeoFields.php b/src/SeoFields.php index 3e0b947..61657ff 100644 --- a/src/SeoFields.php +++ b/src/SeoFields.php @@ -12,7 +12,6 @@ use Craft; use craft\base\Plugin; -use craft\db\Query; use craft\events\ElementEvent; use craft\events\EntryTypeEvent; use craft\events\ExceptionEvent; @@ -42,7 +41,6 @@ use studioespresso\seofields\services\RedirectService; use studioespresso\seofields\services\RenderService; use studioespresso\seofields\services\SitemapService; -use studioespresso\seofields\variables\SeoFieldsVariable; use yii\base\Event; use yii\base\Exception; use yii\console\Application as ConsoleApplication; @@ -102,7 +100,7 @@ public function init() $this->controllerNamespace = 'studioespresso\seofields\console\controllers'; } - Craft::$app->view->hook('seo-fields', function (array &$context) { + Craft::$app->view->hook('seo-fields', function(array &$context) { return $this->renderService->renderMeta($context); }); @@ -174,7 +172,7 @@ protected function settingsHtml(): string return Craft::$app->view->renderTemplate( 'seo-fields/_settings', [ - 'settings' => $this->getSettings() + 'settings' => $this->getSettings(), ] ); } @@ -192,7 +190,7 @@ private function _registerField() Event::on( Fields::class, Fields::EVENT_REGISTER_FIELD_TYPES, - function (RegisterComponentTypesEvent $event) { + function(RegisterComponentTypesEvent $event) { $event->types[] = SeoField::class; } ); @@ -203,7 +201,7 @@ private function _registerPermissions() Event::on( UserPermissions::class, UserPermissions::EVENT_REGISTER_PERMISSIONS, - function (RegisterUserPermissionsEvent $event) { + function(RegisterUserPermissionsEvent $event) { // Register our custom permissions $permissions = [ @@ -224,7 +222,7 @@ function (RegisterUserPermissionsEvent $event) { 'seo-fields:sitemap' => [ 'label' => Craft::t('seo-fields', 'Sitemap'), ], - ] + ], ]; $event->permissions[Craft::t('seo-fields', 'SEO Fields')] = $permissions; } @@ -237,7 +235,6 @@ private function _registerTwigExtension() if (!$request->isConsoleRequest) { Craft::$app->getView()->registerTwigExtension(new SeoFieldsExtension()); } - } private function _registerFrontendRoutes() @@ -245,7 +242,7 @@ private function _registerFrontendRoutes() Event::on( UrlManager::class, UrlManager::EVENT_REGISTER_SITE_URL_RULES, - function (RegisterUrlRulesEvent $event) { + function(RegisterUrlRulesEvent $event) { $robots = SeoFields::$plugin->defaultsService->getRobotsForSite(Craft::$app->getSites()->getCurrentSite()); if ($robots) { $event->rules = array_merge($event->rules, [ @@ -260,7 +257,7 @@ function (RegisterUrlRulesEvent $event) { if ($shouldRender) { $event->rules = array_merge($event->rules, [ 'sitemap.xml' => 'seo-fields/sitemap/render', - 'sitemap____.xml' => 'seo-fields/sitemap/detail' + 'sitemap____.xml' => 'seo-fields/sitemap/detail', ]); } } @@ -272,7 +269,7 @@ private function _registerCpRoutes() Event::on( UrlManager::class, UrlManager::EVENT_REGISTER_CP_URL_RULES, - function (RegisterUrlRulesEvent $event) { + function(RegisterUrlRulesEvent $event) { // Register our Control Panel routes $event->rules = array_merge($event->rules, [ 'seo-fields' => 'seo-fields/defaults/index', @@ -293,7 +290,7 @@ private function _registerCpListeners() Event::on( Sites::class, Sites::EVENT_AFTER_SAVE_SITE, - function (SiteEvent $event) { + function(SiteEvent $event) { if ($event->isNew) { SeoFields::$plugin->defaultsService->copyDefaultsForSite($event->site, $event->oldPrimarySiteId); } @@ -303,7 +300,7 @@ function (SiteEvent $event) { Event::on( Elements::class, Elements::EVENT_AFTER_SAVE_ELEMENT, - function (ElementEvent $event) { + function(ElementEvent $event) { SeoFields::$plugin->sitemapSerivce->clearCacheForElement($event->element); } ); @@ -311,7 +308,7 @@ function (ElementEvent $event) { Event::on( Elements::class, Elements::EVENT_AFTER_DELETE_ELEMENT, - function (ElementEvent $event) { + function(ElementEvent $event) { SeoFields::$plugin->sitemapSerivce->clearCacheForElement($event->element); } ); @@ -319,7 +316,7 @@ function (ElementEvent $event) { Event::on( Sections::class, Sections::EVENT_AFTER_DELETE_SECTION, - function (SectionEvent $event) { + function(SectionEvent $event) { SeoFields::$plugin->sitemapSerivce->clearCaches(); } ); @@ -327,12 +324,12 @@ function (SectionEvent $event) { Event::on( Sections::class, Sections::EVENT_AFTER_DELETE_ENTRY_TYPE, - function (EntryTypeEvent $event) { + function(EntryTypeEvent $event) { SeoFields::$plugin->sitemapSerivce->clearCaches(); } ); - Event::on(Gc::class, Gc::EVENT_RUN, function () { + Event::on(Gc::class, Gc::EVENT_RUN, function() { try { $limit = SeoFields::$plugin->getSettings()->notFoundLimit; if (!is_int($limit)) { @@ -356,7 +353,7 @@ private function _registerSiteListeners() Event::on( ErrorHandler::class, ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, - function (ExceptionEvent $event) { + function(ExceptionEvent $event) { try { if ($event->exception instanceof HttpException && $event->exception->statusCode === 404 && Craft::$app->getRequest()->getIsSiteRequest()) { Craft::debug("404 exception, processing...", __CLASS__); @@ -374,15 +371,15 @@ private function _registerCacheOptions() Event::on( ClearCaches::class, ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, - function (RegisterCacheOptionsEvent $event) { + function(RegisterCacheOptionsEvent $event) { // Register our Control Panel routes $event->options = array_merge( $event->options, [ [ "key" => 'seofields_sitemaps', "label" => "Sitemap caches (SEO Fields)", - "action" => [SeoFields::$plugin->sitemapSerivce, 'clearCaches'] - ] + "action" => [SeoFields::$plugin->sitemapSerivce, 'clearCaches'], + ], ]); } ); @@ -400,11 +397,10 @@ private function _registerCustomElements() if ($elements) { Event::on(SeoFields::class, SeoFields::EVENT_SEOFIELDS_REGISTER_ELEMENT, - function (RegisterSeoElementEvent $event) use ($elements) { + function(RegisterSeoElementEvent $event) use ($elements) { $event->elements = array_merge($event->elements, $elements); } ); } } - } diff --git a/src/assetbundles/RobotsAsset.php b/src/assetbundles/RobotsAsset.php index bdfcee4..cff51ca 100644 --- a/src/assetbundles/RobotsAsset.php +++ b/src/assetbundles/RobotsAsset.php @@ -25,9 +25,9 @@ public function init() ]; $this->css = [ - 'robots.css' + 'robots.css', ]; parent::init(); } -} \ No newline at end of file +} diff --git a/src/assetbundles/SeoFieldAsset.php b/src/assetbundles/SeoFieldAsset.php index 53a5f4c..d5c1559 100644 --- a/src/assetbundles/SeoFieldAsset.php +++ b/src/assetbundles/SeoFieldAsset.php @@ -4,7 +4,6 @@ use craft\web\AssetBundle; use craft\web\assets\cp\CpAsset; -use craft\web\View; class SeoFieldAsset extends AssetBundle { @@ -21,13 +20,13 @@ public function init() ]; $this->js = [ - 'field.js' + 'field.js', ]; $this->css = [ - 'field.css' + 'field.css', ]; parent::init(); } -} \ No newline at end of file +} diff --git a/src/config.php b/src/config.php index 2574c1d..54a555b 100644 --- a/src/config.php +++ b/src/config.php @@ -16,4 +16,4 @@ "sitemapPerSite" => false, "fieldHandle" => "seo", "notFoundLimit" => 10000, -]; \ No newline at end of file +]; diff --git a/src/console/controllers/MigrateController.php b/src/console/controllers/MigrateController.php index 987a69b..1191333 100644 --- a/src/console/controllers/MigrateController.php +++ b/src/console/controllers/MigrateController.php @@ -8,14 +8,12 @@ use craft\helpers\App; use craft\helpers\Console; use craft\helpers\Db; -use ether\seo\models\data\SeoData; use studioespresso\seofields\jobs\MigrateFieldDataJob; use studioespresso\seofields\services\migrate\Ether; use yii\console\Controller; class MigrateController extends Controller { - public $newHandle = 'newSeo'; public $oldHandle = 'seo'; public $siteId; @@ -47,7 +45,6 @@ public function actionEther() $etherMigration = new Ether(); $etherMigration->migrate($this->oldHandle = 'seo', $this->newHandle = 'newSeo', $this->siteId, $this->titleSeperator); - } public function actionFields() @@ -68,7 +65,6 @@ public function actionFields() $entries = Entry::findAll(['sectionId' => $data['sectionId'], 'typeId' => $data['typeId']]); $this->stdout("Processing entries in {$section->name} ($type->name)" . PHP_EOL, Console::FG_GREEN); foreach ($entries as $entry) { - Craft::$app->getQueue()->push(new MigrateFieldDataJob([ 'entryId' => $entry->id, 'fieldHandle' => $this->fieldHandle, @@ -78,4 +74,4 @@ public function actionFields() }; } } -} \ No newline at end of file +} diff --git a/src/controllers/CpApiController.php b/src/controllers/CpApiController.php index 4866901..b6bd93b 100644 --- a/src/controllers/CpApiController.php +++ b/src/controllers/CpApiController.php @@ -5,24 +5,16 @@ use Craft; use craft\helpers\DateTimeHelper; use craft\helpers\Db; -use craft\helpers\Template; use craft\helpers\UrlHelper; use craft\i18n\Locale; use craft\web\Controller; -use studioespresso\seofields\models\SeoDefaultsModel; -use studioespresso\seofields\records\DefaultsRecord; use studioespresso\seofields\records\NotFoundRecord; use studioespresso\seofields\records\RedirectRecord; -use studioespresso\seofields\SeoFields; -use yii\helpers\StringHelper; -use yii\web\NotFoundHttpException; -use function React\Promise\all; class CpApiController extends Controller { - - const NOT_FOUND_BASE = "seo-fields/cp-api/not-found"; - const REDIRECT_BASE = "seo-fields/cp-api/redirect"; + public const NOT_FOUND_BASE = "seo-fields/cp-api/not-found"; + public const REDIRECT_BASE = "seo-fields/cp-api/redirect"; /** * @param null $siteHandle @@ -30,7 +22,6 @@ class CpApiController extends Controller */ public function actionNotFound() { - $sort = $this->request->getQueryParam('sort'); $search = $this->request->getQueryParam('search'); if (!$sort) { @@ -54,7 +45,7 @@ public function actionNotFound() $query->andWhere([ 'or', "urlPath LIKE '%{$search}%'", - "fullUrl LIKE '%{$search}%'" + "fullUrl LIKE '%{$search}%'", ]); } if ($total > $limit) { @@ -97,7 +88,7 @@ public function actionNotFound() 'from' => (int)(($page * $limit) - $limit) + 1, 'to' => (int)$to, ], - 'data' => $rows + 'data' => $rows, ]); } @@ -126,7 +117,7 @@ public function actionRedirects() $query->andWhere([ 'or', "pattern LIKE '%{$search}%'", - "redirect LIKE '%{$search}%'" + "redirect LIKE '%{$search}%'", ]); } if ($total > $limit) { @@ -177,9 +168,7 @@ public function actionRedirects() 'from' => (int)(($page * $limit) - $limit) + 1, 'to' => (int)$to, ], - 'data' => $rows + 'data' => $rows, ]); } - - } diff --git a/src/controllers/DefaultsController.php b/src/controllers/DefaultsController.php index 1c1a166..484ebca 100644 --- a/src/controllers/DefaultsController.php +++ b/src/controllers/DefaultsController.php @@ -5,13 +5,10 @@ use Craft; use craft\helpers\UrlHelper; use craft\web\Controller; -use studioespresso\seofields\models\SeoDefaultsModel; -use studioespresso\seofields\records\DefaultsRecord; use studioespresso\seofields\SeoFields; class DefaultsController extends Controller { - public function actionIndex() { $params = Craft::$app->getRequest()->getQueryParams(); @@ -20,7 +17,6 @@ public function actionIndex() $primarySite = Craft::$app->sites->getPrimarySite(); if ($currentUser->can('seo-fields:default')) { $this->redirect(UrlHelper::cpUrl("seo-fields/defaults/$primarySite->handle", $params)); - } elseif ($currentUser->can('seo-fields:notfound')) { $this->redirect(UrlHelper::cpUrl("seo-fields/not-found/$primarySite->handle", $params)); } elseif ($currentUser->can('seo-fields:redirects')) { @@ -39,9 +35,8 @@ public function actionSettings($siteHandle = null) $data = SeoFields::$plugin->defaultsService->getDataBySite($site); return $this->renderTemplate('seo-fields/_defaults', [ 'data' => $data, - 'selectedSite' => $site + 'selectedSite' => $site, ]); - } public function actionSave() diff --git a/src/controllers/NotFoundController.php b/src/controllers/NotFoundController.php index a07ae94..5807969 100644 --- a/src/controllers/NotFoundController.php +++ b/src/controllers/NotFoundController.php @@ -3,14 +3,9 @@ namespace studioespresso\seofields\controllers; use Craft; -use craft\helpers\Template; use craft\helpers\UrlHelper; use craft\web\Controller; -use studioespresso\seofields\models\SeoDefaultsModel; -use studioespresso\seofields\records\DefaultsRecord; use studioespresso\seofields\SeoFields; -use yii\helpers\StringHelper; -use yii\web\NotFoundHttpException; class NotFoundController extends Controller { @@ -57,5 +52,4 @@ public function actionClearAll() SeoFields::getInstance()->notFoundService->deleteAll(); return $this->redirect(UrlHelper::cpUrl('seo-fields/not-found')); } - } diff --git a/src/controllers/RedirectsController.php b/src/controllers/RedirectsController.php index 1aa9adc..6594fee 100644 --- a/src/controllers/RedirectsController.php +++ b/src/controllers/RedirectsController.php @@ -4,21 +4,16 @@ use Craft; use craft\helpers\App; -use craft\helpers\Template; use craft\helpers\UrlHelper; -use craft\models\Site; use craft\web\Controller; use League\Csv\Reader; use studioespresso\seofields\models\RedirectModel; -use studioespresso\seofields\models\SeoDefaultsModel; -use studioespresso\seofields\records\DefaultsRecord; use studioespresso\seofields\SeoFields; -use yii\helpers\StringHelper; use yii\web\UploadedFile; class RedirectsController extends Controller { - const IMPORT_FILE = 'seofields_redirects_import.csv'; + public const IMPORT_FILE = 'seofields_redirects_import.csv'; public function actionIndex() { @@ -32,7 +27,7 @@ public function actionAdd() return $this->renderTemplate('seo-fields/_redirect/_entry', [ 'pattern' => Craft::$app->getRequest()->getParam('pattern') ?? null, 'record' => Craft::$app->getRequest()->getParam('record') ?? null, - 'sites' => $this->getSitesMenu() + 'sites' => $this->getSitesMenu(), ]); } @@ -41,7 +36,7 @@ public function actionEdit($id) $redirect = SeoFields::getInstance()->redirectService->getRedirectById($id); return $this->renderTemplate('seo-fields/_redirect/_entry', [ 'data' => $redirect, - 'sites' => $this->getSitesMenu() + 'sites' => $this->getSitesMenu(), ]); } @@ -60,7 +55,7 @@ public function actionSave() if ($model->validate()) { $saved = SeoFields::getInstance()->redirectService->saveRedirect($model); if ($saved) { - if($record) { + if ($record) { SeoFields::getInstance()->notFoundService->markAsHandled($record); } Craft::$app->getSession()->setNotice(Craft::t('seo-fields', 'Redirect saved')); @@ -71,9 +66,8 @@ public function actionSave() Craft::$app->getSession()->setError(Craft::t('app', 'Couldn’t save redirect.')); return $this->renderTemplate('seo-fields/_redirect/_entry', [ 'data' => $model, - 'sites' => $this->getSitesMenu() + 'sites' => $this->getSitesMenu(), ]); - } public function actionUpload() @@ -104,7 +98,6 @@ public function actionUpload() public function actionImport() { - $filename = self::IMPORT_FILE; $filePath = Craft::$app->getPath()->getTempPath() . DIRECTORY_SEPARATOR . $filename; if (!file_exists($filePath)) { @@ -147,7 +140,6 @@ public function actionRunImport() $results = SeoFields::getInstance()->redirectService->import($rows, $settings); return $this->renderTemplate('seo-fields/_redirect/_import_results', $results); - } public function actionDelete() @@ -194,7 +186,6 @@ private function getHeaders($reader) return $reader->getHeader(); } catch (\Throwable $e) { } - } private function getRows(Reader $reader) { diff --git a/src/controllers/RobotsController.php b/src/controllers/RobotsController.php index 2acc7a4..d46d5f8 100644 --- a/src/controllers/RobotsController.php +++ b/src/controllers/RobotsController.php @@ -6,9 +6,7 @@ use craft\helpers\Template; use craft\web\Controller; use studioespresso\seofields\models\SeoDefaultsModel; -use studioespresso\seofields\records\DefaultsRecord; use studioespresso\seofields\SeoFields; -use yii\helpers\StringHelper; class RobotsController extends Controller { @@ -25,7 +23,7 @@ public function actionSettings($siteHandle = null) $data = SeoFields::$plugin->defaultsService->getDataBySiteHandle($siteHandle); return $this->renderTemplate('seo-fields/_robots', [ 'data' => $data, - 'robotsPerSite' => SeoFields::$plugin->getSettings()->robotsPerSite + 'robotsPerSite' => SeoFields::$plugin->getSettings()->robotsPerSite, ]); } @@ -40,13 +38,13 @@ public function actionSave() $data['enableRobots'] = Craft::$app->getRequest()->getBodyParam('enableRobots'); $data['robots'] = Craft::$app->getRequest()->getBodyParam('robots'); $data['siteId'] = Craft::$app->getRequest()->getBodyParam('siteId', Craft::$app->getSites()->getPrimarySite()->id); - $model->setAttributes($data); + $model->setAttributes($data); SeoFields::$plugin->defaultsService->saveDefaults($model, Craft::$app->sites->currentSite->id); } public function actionRender() { - if(SeoFields::$plugin->getSettings()->robotsPerSite) { + if (SeoFields::$plugin->getSettings()->robotsPerSite) { $robots = SeoFields::$plugin->defaultsService->getRobotsForSite(Craft::$app->getSites()->getCurrentSite()); } else { $robots = SeoFields::$plugin->defaultsService->getRobotsForSite(Craft::$app->getSites()->getPrimarySite()); @@ -56,8 +54,7 @@ public function actionRender() $headers = Craft::$app->response->headers; $headers->add('Content-Type', 'text/plain; charset=utf-8'); return $this->asRaw($string); - } catch(\Exception $e) { - + } catch (\Exception $e) { } return; } diff --git a/src/controllers/SitemapController.php b/src/controllers/SitemapController.php index d9dcf26..7983b55 100644 --- a/src/controllers/SitemapController.php +++ b/src/controllers/SitemapController.php @@ -3,13 +3,12 @@ namespace studioespresso\seofields\controllers; use Craft; -use craft\helpers\Template; +use craft\db\Query; +use craft\helpers\Db; use craft\records\Section_SiteSettings; use craft\web\Controller; use studioespresso\seofields\models\SeoDefaultsModel; -use studioespresso\seofields\records\DefaultsRecord; use studioespresso\seofields\SeoFields; -use yii\helpers\StringHelper; use yii\web\NotFoundHttpException; class SitemapController extends Controller @@ -26,17 +25,23 @@ public function actionSettings($siteHandle = null) { $site = Craft::$app->getSites()->getSiteByHandle($siteHandle); Craft::$app->getSites()->getSiteByHandle($site); - $sectionsForSite = Section_SiteSettings::findAll(['siteId' => $site->id]); + $query = new Query(); + $query->select('sectionId as id') + ->from('{{%sections_sites}}') + ->leftJoin('{{%sections}}', 'sections.id = sections_sites.sectionId') + ->where(Db::parseParam('siteId', $site->id)) + ->andWhere(['sections.dateDeleted' => null]); $sections = []; - foreach($sectionsForSite as $s) { - $sections[] = Craft::$app->getSections()->getSectionById($s->sectionId); + foreach ($query->all() as $s) { + $sections[] = Craft::$app->getSections()->getSectionById($s['id']); } + $data = SeoFields::$plugin->defaultsService->getDataBySiteHandle($siteHandle); return $this->renderTemplate('seo-fields/_sitemap', [ 'data' => $data, 'sitemapPerSite' => SeoFields::$plugin->getSettings()->sitemapPerSite, 'sections' => $sections, - 'selectedSite' => $site + 'selectedSite' => $site, ]); } @@ -66,13 +71,12 @@ public function actionRender() if (!$data) { throw new NotFoundHttpException(Craft::t('app', 'Page not found'), 404); } - + $xml = SeoFields::$plugin->sitemapSerivce->getSitemapIndex(array_filter($data)); $headers = Craft::$app->response->headers; $headers->add('Content-Type', 'text/xml; charset=utf-8'); $this->asRaw($xml); - } public function actionDetail($siteId, $type, $sectionId, $handle) diff --git a/src/extensions/SeoFieldsExtension.php b/src/extensions/SeoFieldsExtension.php index 8e4541e..db32fba 100644 --- a/src/extensions/SeoFieldsExtension.php +++ b/src/extensions/SeoFieldsExtension.php @@ -14,7 +14,6 @@ */ class SeoFieldsExtension extends AbstractExtension { - public function getFunctions() { return [ @@ -30,8 +29,7 @@ public function getFunctions() // ========================================================================= public function getSeoFields($context) { - $data = SeoFields::getInstance()->renderService->getSeoFromContent($context, SeoFields::getInstance()->getSettings()->fieldHandle); + $data = SeoFields::getInstance()->renderService->getSeoFromContent($context, SeoFields::getInstance()->getSettings()->fieldHandle); return $data; } - -} \ No newline at end of file +} diff --git a/src/fields/SeoField.php b/src/fields/SeoField.php index 40a19cf..43ba542 100644 --- a/src/fields/SeoField.php +++ b/src/fields/SeoField.php @@ -10,16 +10,14 @@ namespace studioespresso\seofields\fields; -use studioespresso\seofields\models\SeoFieldModel; -use studioespresso\seofields\SeoFields; -use studioespresso\seofields\assetbundles\seofieldfield\SeoFieldFieldAsset; - use Craft; use craft\base\ElementInterface; + use craft\base\Field; -use craft\helpers\Db; -use yii\db\Schema; use craft\helpers\Json; +use studioespresso\seofields\models\SeoFieldModel; +use studioespresso\seofields\SeoFields; +use yii\db\Schema; /** * SeoField Field @@ -73,7 +71,7 @@ public static function displayName(): string * * @return array */ - public function rules() : array + public function rules(): array { $rules = parent::rules(); $rules = array_merge($rules, [ @@ -138,7 +136,7 @@ public function serializeValue($value, ElementInterface $element = null): mixed * * @return string|null */ - public function getSettingsHtml() :? string + public function getSettingsHtml(): ? string { // Render the settings template return Craft::$app->getView()->renderTemplate( diff --git a/src/jobs/MigrateFieldDataJob.php b/src/jobs/MigrateFieldDataJob.php index 412f3fd..dcda8e6 100644 --- a/src/jobs/MigrateFieldDataJob.php +++ b/src/jobs/MigrateFieldDataJob.php @@ -9,7 +9,6 @@ class MigrateFieldDataJob extends BaseJob { - public $entry; public $fieldHandle; public $entryId; @@ -19,8 +18,7 @@ class MigrateFieldDataJob extends BaseJob public function init() { - if(!$this->fieldHandle) - { + if (!$this->fieldHandle) { throw new InvalidFieldException('Field handle not provided'); } $this->entry = Entry::findOne(['id' => $this->entryId]); @@ -31,21 +29,20 @@ public function init() public function execute($queue) { $model = new SeoFieldModel(); - if($this->entry->metaTitle) { + if ($this->entry->metaTitle) { $model->metaTitle = $this->entry->metaTitle; } - if($this->entry->metaDescription) { + if ($this->entry->metaDescription) { $model->metaDescription = $this->entry->metaDescription; } - if($this->entry->metaImage) { + if ($this->entry->metaImage) { if ($this->entry->metaImage->one()) { $model->facebookImage = [$this->entry->metaImage->one()->id]; } } $this->entry->setFieldValue($this->fieldHandle, $model); - if($this->entry->validate()) { + if ($this->entry->validate()) { \Craft::$app->getElements()->saveElement($this->entry); } } - } diff --git a/src/migrations/Install.php b/src/migrations/Install.php index edf1d78..b397507 100644 --- a/src/migrations/Install.php +++ b/src/migrations/Install.php @@ -4,7 +4,6 @@ use Craft; use craft\db\Migration; -use studioespresso\seofields\models\SeoDefaultsModel; use studioespresso\seofields\records\DefaultsRecord; use studioespresso\seofields\records\NotFoundRecord; use studioespresso\seofields\records\RedirectRecord; @@ -157,7 +156,6 @@ protected function addForeignKeys() 'id', 'SET NULL' ); - } protected function removeTables() diff --git a/src/migrations/m191114_182559_addNotFoundTable.php b/src/migrations/m191114_182559_addNotFoundTable.php index d28d246..bf851be 100644 --- a/src/migrations/m191114_182559_addNotFoundTable.php +++ b/src/migrations/m191114_182559_addNotFoundTable.php @@ -40,7 +40,7 @@ public function safeUp() ); } - if($tablesCreated) { + if ($tablesCreated) { $this->addForeignKey( $this->db->getForeignKeyName(NotFoundRecord::tableName(), 'siteId'), NotFoundRecord::tableName(), diff --git a/src/migrations/m191114_201532_addRedirectsTable.php b/src/migrations/m191114_201532_addRedirectsTable.php index 8407ba3..0202c1d 100644 --- a/src/migrations/m191114_201532_addRedirectsTable.php +++ b/src/migrations/m191114_201532_addRedirectsTable.php @@ -40,7 +40,7 @@ public function safeUp() ); } - if($tablesCreated) { + if ($tablesCreated) { $this->addForeignKey( $this->db->getForeignKeyName(RedirectRecord::tableName(), 'siteId'), RedirectRecord::tableName(), diff --git a/src/models/NotFoundModel.php b/src/models/NotFoundModel.php index 5116577..46e1b79 100644 --- a/src/models/NotFoundModel.php +++ b/src/models/NotFoundModel.php @@ -66,10 +66,10 @@ public function rules(): array { return [ [ - ['counter', 'url', 'dateLastHit', 'handled', 'siteId'], 'required' + ['counter', 'url', 'dateLastHit', 'handled', 'siteId'], 'required', ], [ - ['id', 'counter', 'fullUrl','urlPath','referrer', 'urlParams', 'dateLastHit', 'handled', 'siteId','redirect', 'dateLastHit', 'dateCreated', 'dateUpdated'], 'safe' + ['id', 'counter', 'fullUrl', 'urlPath', 'referrer', 'urlParams', 'dateLastHit', 'handled', 'siteId', 'redirect', 'dateLastHit', 'dateCreated', 'dateUpdated'], 'safe', ], [['counter', 'siteId'], 'integer'], ['handled', 'boolean'], diff --git a/src/models/RedirectModel.php b/src/models/RedirectModel.php index 7cd2c3b..41ac594 100644 --- a/src/models/RedirectModel.php +++ b/src/models/RedirectModel.php @@ -11,7 +11,6 @@ namespace studioespresso\seofields\models; use craft\base\Model; -use craft\validators\DateTimeValidator; /** * @author Studio Espresso @@ -64,7 +63,7 @@ public function rules(): array return [ [['pattern', 'redirect', 'method'], 'required'], [ - ['id', 'pattern','sourceMatch' , 'redirect', 'matchType', 'method', 'siteId', 'counter', 'dateLastHit', 'dateLastHit', 'dateCreated', 'dateUpdated'], 'safe' + ['id', 'pattern', 'sourceMatch', 'redirect', 'matchType', 'method', 'siteId', 'counter', 'dateLastHit', 'dateLastHit', 'dateCreated', 'dateUpdated'], 'safe', ], ]; } diff --git a/src/models/SeoDefaultsModel.php b/src/models/SeoDefaultsModel.php index a50d2db..3605c65 100644 --- a/src/models/SeoDefaultsModel.php +++ b/src/models/SeoDefaultsModel.php @@ -40,10 +40,10 @@ public function rules(): array 'enableRobots', 'robots', 'sitemap', - 'id' + 'id', ], 'safe', ], ]; } -} \ No newline at end of file +} diff --git a/src/models/SeoFieldModel.php b/src/models/SeoFieldModel.php index 8af0708..b24c1e3 100644 --- a/src/models/SeoFieldModel.php +++ b/src/models/SeoFieldModel.php @@ -81,7 +81,7 @@ public function getPageTitle($element = null) public function getCanonical() { $request = Craft::$app->getRequest(); - return $request->hostInfo .'/' . $request->getPathInfo(true); + return $request->hostInfo . '/' . $request->getPathInfo(true); } public function getOgTitle($element = null) @@ -105,7 +105,6 @@ public function getTwitterTitle($element = null) public function getMetaDescription() { return $this->metaDescription ? $this->metaDescription : $this->siteDefault->defaultMetaDescription; - } public function getOgDescription() @@ -190,7 +189,7 @@ public function getAlternate($element = null) if ($site['uri']) { $data[] = [ 'url' => UrlHelper::siteUrl($site['uri'] === '__home__' ? '' : $site['uri'], null, null, $site['siteId']), - 'language' => $site['language'] + 'language' => $site['language'], ]; } } @@ -270,7 +269,7 @@ public function rules(): array 'twitterTitle', 'twitterDescription', 'twitterImage', - 'allowIndexing' + 'allowIndexing', ], 'safe', ], @@ -288,4 +287,4 @@ private function _getPreviewTransform(Asset $asset) } return $transform; } -} \ No newline at end of file +} diff --git a/src/models/Settings.php b/src/models/Settings.php index adec7b5..163dfe4 100644 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -49,7 +49,7 @@ class Settings extends Model public function rules(): array { return [ - ['titleSeperator', 'string'] + ['titleSeperator', 'string'], ]; } } diff --git a/src/services/DefaultsService.php b/src/services/DefaultsService.php index 217fe9f..787f26d 100644 --- a/src/services/DefaultsService.php +++ b/src/services/DefaultsService.php @@ -2,16 +2,15 @@ namespace studioespresso\seofields\services; -use craft\base\Model; +use Craft; +use craft\base\Component; use craft\helpers\Json; use craft\models\Site; use studioespresso\seofields\models\SeoDefaultsModel; + use studioespresso\seofields\records\DefaultsRecord; use studioespresso\seofields\SeoFields; -use Craft; -use craft\base\Component; - /** * @author Studio Espresso * @package SeoFields @@ -69,7 +68,7 @@ public function getDataBySiteId($siteId) 'id' => $record->id, 'enableRobots' => $record->enableRobots, 'robots' => $record->robots, - 'sitemap' => $record->sitemap + 'sitemap' => $record->sitemap, ]); $model->setAttributes($fields); return $model; @@ -78,7 +77,8 @@ public function getDataBySiteId($siteId) } } - public function getDataBySiteHandle($handle) { + public function getDataBySiteHandle($handle) + { $site = Craft::$app->sites->getSiteByHandle($handle); return $this->getDataBySiteId($site->id); } @@ -101,7 +101,7 @@ public function getRobotsForSite(Site $site) $model = new SeoDefaultsModel(); $fields = [ 'enableRobots' => $record->enableRobots, - 'robots' => $record->robots + 'robots' => $record->robots, ]; $model->setAttributes($fields); return $model; @@ -118,9 +118,9 @@ public function getRecordForSiteId($siteId) public function copyDefaultsForSite(Site $site, $oldPrimarySiteId) { - $defaults = $this->getDataBySiteId($oldPrimarySiteId); - $defaults->siteId = $site->id; - $this->saveDefaults($defaults, $site->id); - return true; + $defaults = $this->getDataBySiteId($oldPrimarySiteId); + $defaults->siteId = $site->id; + $this->saveDefaults($defaults, $site->id); + return true; } } diff --git a/src/services/NotFoundService.php b/src/services/NotFoundService.php index 2b14ee8..8391877 100644 --- a/src/services/NotFoundService.php +++ b/src/services/NotFoundService.php @@ -9,7 +9,6 @@ use craft\helpers\StringHelper; use craft\models\Site; use craft\web\Request; -use studioespresso\seofields\events\RegisterSeoSitemapEvent; use studioespresso\seofields\models\NotFoundModel; use studioespresso\seofields\models\RedirectModel; use studioespresso\seofields\records\NotFoundRecord; @@ -53,7 +52,6 @@ public function getAllNotFound($orderBy, $siteHandle = null, $handled) $model = new NotFoundModel(); $model->setAttributes($record->getAttributes()); $data[] = $model; - } return $data; } @@ -100,24 +98,22 @@ public function handleNotFound(Request $request, Site $site) } $this->shouldWeCleanupRedirects(); - } catch (Exception $e) { Craft::error($e->getMessage(), 'seo-fields'); } } - public function markAsHandled(NotFoundRecord|int $record): void { - if(is_int($record)) { + public function markAsHandled(NotFoundRecord|int $record): void + { + if (is_int($record)) { $query = NotFoundRecord::find(); $query->where(['id' => $record]); $record = $query->one(); - } $record->setAttribute('handled', 1); $record->save(); return; - } /** @@ -133,7 +129,7 @@ private function getMatchingRedirect(NotFoundModel $model): RedirectRecord|array $redirect->where(['and', Db::parseParam('pattern', $model->urlPath, '='), - Db::parseParam('sourceMatch', 'path', '=') + Db::parseParam('sourceMatch', 'path', '='), ]); $redirect->andWhere(Db::parseParam('siteId', [null, $model->siteId], 'in')); @@ -143,7 +139,7 @@ private function getMatchingRedirect(NotFoundModel $model): RedirectRecord|array $redirect->where(['and', Db::parseParam('pattern', $parsedUrl['path'], '='), - Db::parseParam('sourceMatch', 'pathWithoutParams', '=') + Db::parseParam('sourceMatch', 'pathWithoutParams', '='), ]); if ($redirect->one()) { @@ -172,7 +168,7 @@ private function saveNotFound(NotFoundModel $model) $record = false; if (isset($model->id)) { $record = NotFoundRecord::findOne([ - 'id' => $model->id + 'id' => $model->id, ]); } @@ -226,7 +222,6 @@ private function shouldWeCleanupRedirects() foreach ($toDelete->all() as $record) { $this->deletetById($record->id); } - } private function getAllRegexRedirects(NotFoundModel $model): array diff --git a/src/services/RedirectService.php b/src/services/RedirectService.php index e00bfe1..5c5aebd 100644 --- a/src/services/RedirectService.php +++ b/src/services/RedirectService.php @@ -8,7 +8,6 @@ use craft\helpers\DateTimeHelper; use craft\helpers\Json; use craft\helpers\UrlHelper; -use studioespresso\seofields\events\RegisterSeoSitemapEvent; use studioespresso\seofields\models\RedirectModel; use studioespresso\seofields\records\RedirectRecord; use studioespresso\seofields\SeoFields; @@ -21,7 +20,6 @@ */ class RedirectService extends Component { - public function handleRedirect(RedirectRecord|array $redirect) { if (is_array($redirect)) { @@ -146,7 +144,6 @@ public function import($data, $settings) private function redirect(RedirectModel|RedirectRecord|array $redirect) { - try { if (is_array($redirect)) { $url = $redirect['url']; @@ -158,11 +155,10 @@ private function redirect(RedirectModel|RedirectRecord|array $redirect) } else { $url = $redirect->redirect; } - } $response = Craft::$app->response; - if(Craft::$app->getRequest()->getQueryStringWithoutPath()) { + if (Craft::$app->getRequest()->getQueryStringWithoutPath()) { $response->redirect($url . "?" . Craft::$app->getRequest()->getQueryStringWithoutPath() , $method)->send(); } diff --git a/src/services/RenderService.php b/src/services/RenderService.php index b3662e5..bc9f00a 100644 --- a/src/services/RenderService.php +++ b/src/services/RenderService.php @@ -20,26 +20,24 @@ */ class RenderService extends Component { - // Public Methods // ========================================================================= public function renderMeta($context, $handle = 'seo') { - Craft::beginProfile('renderMeta', __METHOD__); $data = $this->getSeoFromContent($context, $handle); $oldTemplateMode = Craft::$app->getView()->getTemplateMode(); - Craft::$app->getView()->setTemplateMode(View::TEMPLATE_MODE_CP); - $template = Craft::$app->getView()->renderTemplate( + Craft::$app->getView()->setTemplateMode(View::TEMPLATE_MODE_CP); + $template = Craft::$app->getView()->renderTemplate( 'seo-fields/_meta', ['meta' => $data['meta'], 'element' => $data['entry']] ); - Craft::endProfile('renderMeta', __METHOD__); - Craft::$app->getView()->setTemplateMode($oldTemplateMode); - return $template; + Craft::endProfile('renderMeta', __METHOD__); + Craft::$app->getView()->setTemplateMode($oldTemplateMode); + return $template; try { } catch (\Exception $e) { @@ -77,7 +75,6 @@ public function getSeoFromContent($context, $handle) } return ['meta' => $meta, 'entry' => $element, 'element' => $element]; - } catch (\Exception $e) { return null; } @@ -98,5 +95,4 @@ private function _registerElementsEvent() return $registeredElements; } - } diff --git a/src/services/SitemapService.php b/src/services/SitemapService.php index 5d7a090..2353255 100644 --- a/src/services/SitemapService.php +++ b/src/services/SitemapService.php @@ -6,7 +6,6 @@ use craft\base\Component; use craft\base\Element; use craft\commerce\elements\Product; -use craft\commerce\models\ProductTypeSite; use craft\commerce\Plugin as Commerce; use craft\commerce\services\ProductTypes; use craft\db\Query; @@ -16,7 +15,6 @@ use craft\helpers\Json; use craft\helpers\UrlHelper; use craft\models\Site; -use studioespresso\seofields\events\RegisterSeoSitemapEvent; use studioespresso\seofields\SeoFields; use yii\caching\TagDependency; @@ -27,8 +25,7 @@ */ class SitemapService extends Component { - - const SITEMAP_CACHE_KEY = 'seofields_cache_sitemaps'; + public const SITEMAP_CACHE_KEY = 'seofields_cache_sitemaps'; public function shouldRenderBySiteId(Site $site) { @@ -71,13 +68,12 @@ public function shouldRenderBySiteId(Site $site) public function getSitemapIndex($data) { - $currentSite = Craft::$app->getSites()->getCurrentSite(); $cacheDependency = new TagDependency([ 'tags' => [ self::SITEMAP_CACHE_KEY, - self::SITEMAP_CACHE_KEY . '_index_site' . $currentSite->id - ] + self::SITEMAP_CACHE_KEY . '_index_site' . $currentSite->id, + ], ]); if (!Craft::$app->getConfig()->general->devMode) { $duration = null; @@ -87,7 +83,7 @@ public function getSitemapIndex($data) $xml = Craft::$app->getCache()->getOrSet( self::SITEMAP_CACHE_KEY . '_index_site' . $currentSite->id, - function () use ($data, $currentSite) { + function() use ($data, $currentSite) { $xml[] = ''; $xml[] = ''; if (isset($data['sections'])) { @@ -141,14 +137,13 @@ public function getSitemapData($siteId, $type, $sectionId) $cacheDependency = new TagDependency([ 'tags' => [ self::SITEMAP_CACHE_KEY, - self::SITEMAP_CACHE_KEY . "_" . $siteId . "_" . $sectionId - ] + self::SITEMAP_CACHE_KEY . "_" . $siteId . "_" . $sectionId, + ], ]); if (!Craft::$app->getConfig()->general->devMode) { - $data = Craft::$app->getCache()->getOrSet( self::SITEMAP_CACHE_KEY . "_" . $siteId . "_" . $sectionId, - function () use ($data, $type, $settings, $sectionId) { + function() use ($data, $type, $settings, $sectionId) { return $this->_addElementsToSitemap($data, $settings[$type][$sectionId]); }, null, @@ -187,7 +182,7 @@ public function clearCacheForElement(Element $element) if ($id) { $this->clearCaches([ self::SITEMAP_CACHE_KEY . '_index_site' . $element->siteId, - self::SITEMAP_CACHE_KEY . "_" . $element->siteId . "_" . $id + self::SITEMAP_CACHE_KEY . "_" . $element->siteId . "_" . $id, ]); } } @@ -207,7 +202,7 @@ private function _addElementsToSitemap($entries, $settings) $handle = SeoFields::getInstance()->getSettings()->fieldHandle; $seoField = Craft::$app->getFields()->getFieldByHandle($handle); $field = "field_{$handle}"; - if($seoField->columnSuffix) { + if ($seoField->columnSuffix) { $field = $field . "_{$seoField->columnSuffix}"; } /** @var $entry Element */ @@ -221,13 +216,13 @@ private function _addElementsToSitemap($entries, $settings) ->andWhere([ 'or', Db::parseParam("JSON_EXTRACT(content.$field, '$.allowIndexing')", "yes"), - Db::parseParam("JSON_EXTRACT(content.$field, '$.allowIndexing')", ":empty:") + Db::parseParam("JSON_EXTRACT(content.$field, '$.allowIndexing')", ":empty:"), ]) ->andWhere('sites.enabled = true')->all(); if (!$siteEntries) { continue; } - $sites = array_filter($siteEntries, function ($item) use ($currentSite) { + $sites = array_filter($siteEntries, function($item) use ($currentSite) { if ($item['siteId'] != $currentSite->id) { return true; } @@ -308,7 +303,7 @@ private function _addItemToIndex($site, $type, $entry) private function _shouldRenderEntries($sitemapSettings) { - $shouldRenderSections = array_filter($sitemapSettings['entry'], function ($sectionId) use ($sitemapSettings) { + $shouldRenderSections = array_filter($sitemapSettings['entry'], function($sectionId) use ($sitemapSettings) { $section = Craft::$app->getSections()->getSectionById($sectionId); if (!$section) { return false; @@ -329,7 +324,7 @@ private function _shouldRenderEntries($sitemapSettings) private function _shouldRenderCategories($sitemapSettings) { - $shouldRenderCategories = array_filter($sitemapSettings['category'], function ($group) use ($sitemapSettings) { + $shouldRenderCategories = array_filter($sitemapSettings['category'], function($group) use ($sitemapSettings) { if (isset($sitemapSettings['category'][$group]['enabled'])) { $site = Craft::$app->getSites()->getCurrentSite(); $groupSites = Craft::$app->getCategories()->getGroupById($group)->siteSettings; @@ -349,7 +344,7 @@ private function _shouldRenderProducts($sitemapSettings) return false; } - $shouldRenderProducts = array_filter($sitemapSettings['product'], function ($productType) use ($sitemapSettings) { + $shouldRenderProducts = array_filter($sitemapSettings['product'], function($productType) use ($sitemapSettings) { if (isset($sitemapSettings['product'][$productType]['enabled'])) { $productTypeService = new ProductTypes(); $site = Craft::$app->getSites()->getCurrentSite(); @@ -363,6 +358,5 @@ private function _shouldRenderProducts($sitemapSettings) } }, ARRAY_FILTER_USE_KEY); return $shouldRenderProducts; - } } diff --git a/src/services/migrate/Ether.php b/src/services/migrate/Ether.php index 0720183..1f9c8ff 100644 --- a/src/services/migrate/Ether.php +++ b/src/services/migrate/Ether.php @@ -2,14 +2,12 @@ namespace studioespresso\seofields\services\migrate; - use Craft; use craft\base\Component; use craft\elements\Entry; use craft\errors\SiteNotFoundException; use ether\seo\models\data\SeoData; use ether\seo\models\data\SocialData; -use studioespresso\seofields\fields\SeoField; use studioespresso\seofields\models\SeoFieldModel; use Twig\Markup; use yii\helpers\Console; @@ -21,7 +19,6 @@ */ class Ether extends Component { - private $titleSeperator; public function migrate($oldHandle = 'seo', $newHandle = 'newSeo', $siteId = null, $titleSeperator = null) @@ -55,7 +52,6 @@ public function migrate($oldHandle = 'seo', $newHandle = 'newSeo', $siteId = nul } Console::endProgress(); } - } private function migrateContent(Entry $entry, $field, $newHandle) @@ -112,10 +108,10 @@ private function removeSeperator($title) private function getMarkup($string) { - if ($string instanceof Markup OR (is_object($string) && get_class($string) == 'Twig\Markup')) { + if ($string instanceof Markup or (is_object($string) && get_class($string) == 'Twig\Markup')) { return !empty($string->__toString()) ? $string->__toString() : null; } else { return !empty($string) ? $string : null; } } -} \ No newline at end of file +} diff --git a/src/translations/nl/seo-fields.php b/src/translations/nl/seo-fields.php index 780b62e..e01fd8d 100644 --- a/src/translations/nl/seo-fields.php +++ b/src/translations/nl/seo-fields.php @@ -19,5 +19,5 @@ "Last hit at" => "Laatste keer actief op", "Method" => "Methode", "Remove" => "Verwijderen", - "Last linked from" => "Laatste gelinkt vanaf" -]; \ No newline at end of file + "Last linked from" => "Laatste gelinkt vanaf", +]; diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php deleted file mode 100755 index 22d59b5..0000000 --- a/tests/_bootstrap.php +++ /dev/null @@ -1,18 +0,0 @@ - getenv('DB_PASSWORD'), - 'user' => getenv('DB_USER'), - 'database' => getenv('DB_DATABASE'), - 'tablePrefix' => getenv('DB_TABLE_PREFIX'), - 'driver' => getenv('DB_DRIVER'), - 'port' => getenv('DB_PORT'), - 'schema' => getenv('DB_SCHEMA'), - 'server' => getenv('DB_SERVER'), -]; diff --git a/tests/_craft/config/test.php b/tests/_craft/config/test.php deleted file mode 100755 index 1a539a0..0000000 --- a/tests/_craft/config/test.php +++ /dev/null @@ -1,4 +0,0 @@ - - - - - - Welcome to Craft CMS - - - - - -
- -
- - diff --git a/tests/_craft/translations/.gitignore b/tests/_craft/translations/.gitignore deleted file mode 100755 index d6b7ef3..0000000 --- a/tests/_craft/translations/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/tests/_data/.gitkeep b/tests/_data/.gitkeep deleted file mode 100755 index e69de29..0000000 diff --git a/tests/_output/.gitignore b/tests/_output/.gitignore deleted file mode 100755 index c96a04f..0000000 --- a/tests/_output/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php deleted file mode 100755 index 95c00ec..0000000 --- a/tests/_support/AcceptanceTester.php +++ /dev/null @@ -1,26 +0,0 @@ -getModule('PhpBrowser'); - $guzzle = $phpBrowser->client; - - // Disable the following of redirects - $guzzle->followRedirects(false); - - $phpBrowser->_loadPage('GET', $url); - $response = $guzzle->getInternalResponse(); - $responseCode = $response->getStatus(); - $locationHeader = $response->getHeader('Location'); - - $this->assertNotEquals($responseCode, 301); - $this->assertNotEquals($responseCode, 302); - $this->assertNull($locationHeader); - - $guzzle->followRedirects(true); - } - - /** - * Ensure that a particular URL redirects to another URL - * - * @param string $startUrl - * @param string $endUrl (should match "Location" header exactly) - * @param integer $redirectCode (301 = permanent, 302 = temporary) - */ - public function verifyRedirect($startUrl, $endUrl, $redirectCode = 301) - { - $phpBrowser = $this->getModule('PhpBrowser'); - $guzzle = $phpBrowser->client; - - // Disable the following of redirects - $guzzle->followRedirects(false); - - $phpBrowser->_loadPage('GET', $startUrl); - $response = $guzzle->getInternalResponse(); - $responseCode = $response->getStatus(); - $locationHeader = $response->getHeader('Location'); - - $this->assertEquals($responseCode, $redirectCode); - $this->assertEquals($endUrl, $locationHeader); - - $guzzle->followRedirects(true); - } -} diff --git a/tests/_support/Helper/Functional.php b/tests/_support/Helper/Functional.php deleted file mode 100755 index 4183cb0..0000000 --- a/tests/_support/Helper/Functional.php +++ /dev/null @@ -1,10 +0,0 @@ -verifyRedirect('/temp-redirect','http://testing.local.statik.be/bar', 302); - } - - public function testNotFound301(AcceptanceTester $I) { - $I->verifyRedirect('/permanent-redirect','http://testing.local.statik.be/bar', 301); - } -} \ No newline at end of file