FIX Vendorise module, update CI to include userforms

This commit is contained in:
Robbie Averill 2017-11-02 14:02:01 +13:00
parent 0a7b3f768d
commit 88b1b10f61
4 changed files with 23 additions and 17 deletions

View File

@ -17,13 +17,13 @@ before_script:
- phpenv rehash
- phpenv config-rm xdebug.ini
- composer install --prefer-dist
- composer require --prefer-dist --no-update silverstripe/framework:4.0.x-dev
- if [[ $DB == PGSQL ]]; then composer require --prefer-dist --no-update silverstripe/postgresql:2.0.x-dev; fi
- composer update
- composer validate
- composer require --no-update silverstripe/recipe-cms:1.0.x-dev silverstripe/userforms:5.0.x-dev
- if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.0.x-dev; fi
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
script:
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/; fi
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=vendor/silverstripe/framework/phpcs.xml.dist code/ tests/ ; fi

View File

@ -4,6 +4,7 @@ namespace SilverStripe\SpamProtection;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Convert;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldGroup;
use SilverStripe\Forms\FieldList;
@ -15,9 +16,6 @@ use SilverStripe\UserForms\Model\EditableFormField\EditableEmailField;
use SilverStripe\UserForms\Model\EditableFormField\EditableNumericField;
use SilverStripe\UserForms\Model\EditableFormField\EditableTextField;
/**
* @todo The userforms namespaces may still change, as the branch is not merged in yet
*/
if (!class_exists(EditableFormField::class)) {
return;
}
@ -152,12 +150,10 @@ class EditableSpamProtectionField extends EditableFormField
// Get protector
$protector = FormSpamProtectionExtension::get_protector();
if (!$protector) {
var_dump('a');
return $fields;
}
if ($this->Parent()->Fields() instanceof UnsavedRelationList) {
var_dump('b');
return $fields;
}
@ -263,7 +259,15 @@ class EditableSpamProtectionField extends EditableFormField
public function getIcon()
{
return 'spamprotection/images/' . strtolower($this->class) . '.png';
// Get the end of the full qualified class name
$shortClass = end(explode("\\", __CLASS__));
$resource = ModuleLoader::getModule('silverstripe/spamprotection')
->getResource('images/' . strtolower($shortClass) . '.png');
if ($resource->exists()) {
return $resource->getRelativePath();
}
}
public function showInReports()

View File

@ -2,7 +2,6 @@
namespace SilverStripe\SpamProtection\Extension;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\Core\Extension;
use SilverStripe\Core\Injector\Injector;
@ -71,7 +70,7 @@ class FormSpamProtectionExtension extends Extension
if (isset($options['protector'])) {
$protector = $options['protector'];
} else {
$protector = Config::inst()->get(self::class, 'default_spam_protector');
$protector = self::config()->get('default_spam_protector');
}
if ($protector && class_exists($protector)) {
@ -94,7 +93,7 @@ class FormSpamProtectionExtension extends Extension
if (isset($options['name'])) {
$name = $options['name'];
} else {
$name = Config::inst()->get(self::class, 'field_name');
$name = $this->config()->get('field_name');
}
// captcha field title

View File

@ -1,7 +1,7 @@
{
"name": "silverstripe/spamprotection",
"description": "Spam protection module for SilverStripe.",
"type": "silverstripe-module",
"type": "silverstripe-vendormodule",
"keywords": ["silverstripe", "spamprotection"],
"authors": [{
"name": "Saophalkun Ponlu",
@ -11,14 +11,17 @@
"email": "will@fullscreen.io"
}],
"require": {
"silverstripe/framework": "^4@dev"
"silverstripe/framework": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"silverstripe/versioned": "^1@dev",
"silverstripe/versioned": "^1.0",
"squizlabs/php_codesniffer": "^3.0"
},
"extra": {
"expose": [
"images"
],
"branch-alias": {
"dev-master": "3.0.x-dev"
}