FIX Update module for latest SS4, vendorise
* Update Scrutinizer configuration * Update Travis and code coverage build badges, update example code
This commit is contained in:
parent
09db27ade8
commit
e2aea4e0eb
|
@ -1,9 +1,12 @@
|
||||||
inherit: true
|
|
||||||
|
|
||||||
checks:
|
checks:
|
||||||
php:
|
php: true
|
||||||
code_rating: true
|
|
||||||
duplication: true
|
build:
|
||||||
|
nodes:
|
||||||
|
analysis:
|
||||||
|
tests:
|
||||||
|
override: [php-scrutinizer-run]
|
||||||
|
|
||||||
filter:
|
filter:
|
||||||
paths: [src/*, tests/*]
|
paths: ["src/*", "tests/*"]
|
||||||
|
|
||||||
|
|
36
.travis.yml
36
.travis.yml
|
@ -1,25 +1,33 @@
|
||||||
# See https://github.com/silverstripe/silverstripe-travis-support for setup details
|
|
||||||
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
|
dist: trusty
|
||||||
|
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
- COMPOSER_ROOT_VERSION=2.0.x-dev
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
env: DB=MYSQL CORE_RELEASE=4
|
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1
|
||||||
- php: 5.6
|
|
||||||
env: DB=PGSQL CORE_RELEASE=4
|
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
env: DB=MYSQL CORE_RELEASE=4
|
env: DB=PGSQL PHPUNIT_TEST=1
|
||||||
- php: 7.1
|
- php: 7.1
|
||||||
env: DB=PGSQL CORE_RELEASE=4
|
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer self-update || true
|
- phpenv rehash
|
||||||
- git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support
|
- phpenv config-rm xdebug.ini
|
||||||
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
|
|
||||||
- cd ~/builds/ss
|
- composer validate
|
||||||
|
- composer require --prefer-dist --no-update silverstripe/recipe-cms:1.0.x-dev
|
||||||
|
- if [[ $DB == PGSQL ]]; then composer require --prefer-dist --no-update silverstripe/postgresql:2.0.x-dev; fi
|
||||||
|
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- vendor/bin/phpunit tagfield/tests
|
- 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 src/ tests/; fi
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
define('TAG_FIELD_DIR', basename(dirname(__FILE__)));
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
comment: false
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "silverstripe/tagfield",
|
"name": "silverstripe/tagfield",
|
||||||
"description": "Tag field for Silverstripe",
|
"description": "Tag field for Silverstripe",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"type": "silverstripe-module",
|
"type": "silverstripe-vendormodule",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"silverstripe",
|
"silverstripe",
|
||||||
"tag",
|
"tag",
|
||||||
|
@ -16,11 +16,15 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "http://github.com/silverstripe-labs/silverstripe-tagfield/issues"
|
"issues": "http://github.com/silverstripe/silverstripe-tagfield/issues"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"silverstripe/framework": "^4@dev",
|
"silverstripe/framework": "^4.0",
|
||||||
"silverstripe/versioned": "^1@dev"
|
"silverstripe/versioned": "^1.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^5.7",
|
||||||
|
"squizlabs/php_codesniffer": "^3.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
@ -31,6 +35,12 @@
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.x-dev"
|
"dev-master": "2.x-dev"
|
||||||
}
|
},
|
||||||
}
|
"expose": [
|
||||||
|
"css",
|
||||||
|
"js"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<phpunit bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true">
|
||||||
|
<testsuite name="Default">
|
||||||
|
<directory>tests/</directory>
|
||||||
|
</testsuite>
|
||||||
|
<filter>
|
||||||
|
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||||
|
<directory suffix=".php">src/</directory>
|
||||||
|
<exclude>
|
||||||
|
<directory suffix=".php">tests/</directory>
|
||||||
|
</exclude>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
</phpunit>
|
56
readme.md
56
readme.md
|
@ -2,16 +2,15 @@
|
||||||
|
|
||||||
Custom tag input field, for SilverStripe.
|
Custom tag input field, for SilverStripe.
|
||||||
|
|
||||||
[![Build Status](http://img.shields.io/travis/silverstripe-labs/silverstripe-tagfield.svg?style=flat-square)](https://travis-ci.org/silverstripe-labs/silverstripe-tagfield)
|
[![Build Status](https://travis-ci.org/silverstripe/silverstripe-tagfield.svg?branch=master)](https://travis-ci.org/silverstripe/silverstripe-tagfield)
|
||||||
[![Code Quality](http://img.shields.io/scrutinizer/g/silverstripe-labs/silverstripe-tagfield.svg?style=flat-square)](https://scrutinizer-ci.com/g/silverstripe-labs/silverstripe-tagfield)
|
[![Code Quality](http://img.shields.io/scrutinizer/g/silverstripe-labs/silverstripe-tagfield.svg?style=flat)](https://scrutinizer-ci.com/g/silverstripe-labs/silverstripe-tagfield)
|
||||||
[![Code Coverage](http://img.shields.io/scrutinizer/coverage/g/silverstripe-labs/silverstripe-tagfield.svg?style=flat-square)](https://scrutinizer-ci.com/g/silverstripe-labs/silverstripe-tagfield)
|
[![Code coverage](https://codecov.io/gh/silverstripe/silverstripe-tagfield/branch/master/graph/badge.svg)](https://codecov.io/gh/silverstripe/silverstripe-tagfield)
|
||||||
[![Version](http://img.shields.io/packagist/v/silverstripe/tagfield.svg?style=flat-square)](https://packagist.org/packages/silverstripe/tagfield)
|
[![Version](http://img.shields.io/packagist/v/silverstripe/tagfield.svg?style=flat)](https://packagist.org/packages/silverstripe/tagfield)
|
||||||
[![License](http://img.shields.io/packagist/l/silverstripe/tagfield.svg?style=flat-square)](license.md)
|
[![License](http://img.shields.io/packagist/l/silverstripe/tagfield.svg?style=flat)](license.md)
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
* SilverStripe 3.1 or newer
|
* SilverStripe 4.0
|
||||||
* Database: MySQL 5+, SQLite3, Postgres 8.3, SQL Server 2008
|
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
|
|
||||||
|
@ -24,22 +23,28 @@ $ composer require silverstripe/tagfield
|
||||||
### Relational Tags
|
### Relational Tags
|
||||||
|
|
||||||
```php
|
```php
|
||||||
class BlogPost extends DataObject {
|
use SilverStripe\ORM\DataObject;
|
||||||
private static $many_many = array(
|
|
||||||
'BlogTags' => 'BlogTag'
|
class BlogPost extends DataObject
|
||||||
);
|
{
|
||||||
|
private static $many_many = [
|
||||||
|
'BlogTags' => BlogTag::class
|
||||||
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
```php
|
```php
|
||||||
class BlogTag extends DataObject {
|
use SilverStripe\ORM\DataObject;
|
||||||
private static $db = array(
|
|
||||||
'Title' => 'Varchar(200)',
|
|
||||||
);
|
|
||||||
|
|
||||||
private static $belongs_many_many = array(
|
class BlogTag extends DataObject
|
||||||
'BlogPosts' => 'BlogPost'
|
{
|
||||||
);
|
private static $db = [
|
||||||
|
'Title' => 'Varchar(200)',
|
||||||
|
];
|
||||||
|
|
||||||
|
private static $belongs_many_many = [
|
||||||
|
'BlogPosts' => BlogPost::class
|
||||||
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -57,10 +62,13 @@ $field = TagField::create(
|
||||||
### String Tags
|
### String Tags
|
||||||
|
|
||||||
```php
|
```php
|
||||||
class BlogPost extends DataObject {
|
use SilverStripe\ORM\DataObject;
|
||||||
private static $db = array(
|
|
||||||
'Tags' => 'Text'
|
class BlogPost extends DataObject
|
||||||
);
|
{
|
||||||
|
private static $db = [
|
||||||
|
'Tags' => 'Text',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -68,7 +76,7 @@ class BlogPost extends DataObject {
|
||||||
$field = StringTagField::create(
|
$field = StringTagField::create(
|
||||||
'Tags',
|
'Tags',
|
||||||
'Tags',
|
'Tags',
|
||||||
array('one', 'two'),
|
['one', 'two'],
|
||||||
explode(',', $this->Tags)
|
explode(',', $this->Tags)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -85,4 +93,4 @@ All methods, with `public` visibility, are part of the public API. All other met
|
||||||
|
|
||||||
## Reporting Issues
|
## Reporting Issues
|
||||||
|
|
||||||
Please [create an issue](http://github.com/silverstripe-labs/silverstripe-tagfield/issues) for any bugs you've found, or features you're missing.
|
Please [create an issue](http://github.com/silverstripe/silverstripe-tagfield/issues) for any bugs you've found, or features you're missing.
|
||||||
|
|
|
@ -150,11 +150,11 @@ class StringTagField extends DropdownField
|
||||||
*/
|
*/
|
||||||
public function Field($properties = array())
|
public function Field($properties = array())
|
||||||
{
|
{
|
||||||
Requirements::css(TAG_FIELD_DIR . '/css/select2.min.css');
|
Requirements::css('silverstripe/tagfield:css/select2.min.css');
|
||||||
Requirements::css(TAG_FIELD_DIR . '/css/TagField.css');
|
Requirements::css('silverstripe/tagfield:css/TagField.css');
|
||||||
|
|
||||||
Requirements::javascript(TAG_FIELD_DIR . '/js/select2.js');
|
Requirements::javascript('silverstripe/tagfield:js/select2.js');
|
||||||
Requirements::javascript(TAG_FIELD_DIR . '/js/TagField.js');
|
Requirements::javascript('silverstripe/tagfield:js/TagField.js');
|
||||||
|
|
||||||
$this->addExtraClass('ss-tag-field');
|
$this->addExtraClass('ss-tag-field');
|
||||||
|
|
||||||
|
|
|
@ -198,11 +198,11 @@ class TagField extends DropdownField
|
||||||
*/
|
*/
|
||||||
public function Field($properties = array())
|
public function Field($properties = array())
|
||||||
{
|
{
|
||||||
Requirements::css(TAG_FIELD_DIR . '/css/select2.min.css');
|
Requirements::css('silverstripe/tagfield:css/select2.min.css');
|
||||||
Requirements::css(TAG_FIELD_DIR . '/css/TagField.css');
|
Requirements::css('silverstripe/tagfield:css/TagField.css');
|
||||||
|
|
||||||
Requirements::javascript(TAG_FIELD_DIR . '/js/select2.js');
|
Requirements::javascript('silverstripe/tagfield:js/select2.js');
|
||||||
Requirements::javascript(TAG_FIELD_DIR . '/js/TagField.js');
|
Requirements::javascript('silverstripe/tagfield:js/TagField.js');
|
||||||
|
|
||||||
$this->addExtraClass('ss-tag-field');
|
$this->addExtraClass('ss-tag-field');
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ class TagField extends DropdownField
|
||||||
|
|
||||||
$source = $this->getSourceList();
|
$source = $this->getSourceList();
|
||||||
|
|
||||||
if(!$source) {
|
if (!$source) {
|
||||||
$source = ArrayList::create();
|
$source = ArrayList::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,9 +262,9 @@ class TagField extends DropdownField
|
||||||
|
|
||||||
$titleField = $this->getTitleField();
|
$titleField = $this->getTitleField();
|
||||||
|
|
||||||
foreach($source as $object) {
|
foreach ($source as $object) {
|
||||||
$options->push(
|
$options->push(
|
||||||
ArrayData::create(array(
|
ArrayData::create(array(
|
||||||
'Title' => $object->$titleField,
|
'Title' => $object->$titleField,
|
||||||
'Value' => $object->Title,
|
'Value' => $object->Title,
|
||||||
'Selected' => in_array($object->Title, $ids),
|
'Selected' => in_array($object->Title, $ids),
|
||||||
|
@ -273,7 +273,7 @@ class TagField extends DropdownField
|
||||||
}
|
}
|
||||||
|
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
@ -345,7 +345,7 @@ class TagField extends DropdownField
|
||||||
}
|
}
|
||||||
|
|
||||||
$relation->setByIDList(array_filter($ids));
|
$relation->setByIDList(array_filter($ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get or create tag with the given value
|
* Get or create tag with the given value
|
||||||
|
|
Loading…
Reference in New Issue