mirror of
https://github.com/silverstripe/silverstripe-tagfield
synced 2024-10-22 11:05:32 +02:00
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:
|
||||
php:
|
||||
code_rating: true
|
||||
duplication: true
|
||||
php: true
|
||||
|
||||
build:
|
||||
nodes:
|
||||
analysis:
|
||||
tests:
|
||||
override: [php-scrutinizer-run]
|
||||
|
||||
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
|
||||
|
||||
dist: trusty
|
||||
|
||||
env:
|
||||
global:
|
||||
- COMPOSER_ROOT_VERSION=2.0.x-dev
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.6
|
||||
env: DB=MYSQL CORE_RELEASE=4
|
||||
- php: 5.6
|
||||
env: DB=PGSQL CORE_RELEASE=4
|
||||
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1
|
||||
- php: 7.0
|
||||
env: DB=MYSQL CORE_RELEASE=4
|
||||
env: DB=PGSQL PHPUNIT_TEST=1
|
||||
- php: 7.1
|
||||
env: DB=PGSQL CORE_RELEASE=4
|
||||
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
|
||||
|
||||
before_script:
|
||||
- composer self-update || true
|
||||
- git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support
|
||||
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
|
||||
- cd ~/builds/ss
|
||||
- phpenv rehash
|
||||
- phpenv config-rm xdebug.ini
|
||||
|
||||
- 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:
|
||||
- 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
|
||||
|
||||
define('TAG_FIELD_DIR', basename(dirname(__FILE__)));
|
||||
|
1
codecov.yml
Normal file
1
codecov.yml
Normal file
@ -0,0 +1 @@
|
||||
comment: false
|
@ -2,7 +2,7 @@
|
||||
"name": "silverstripe/tagfield",
|
||||
"description": "Tag field for Silverstripe",
|
||||
"license": "BSD-3-Clause",
|
||||
"type": "silverstripe-module",
|
||||
"type": "silverstripe-vendormodule",
|
||||
"keywords": [
|
||||
"silverstripe",
|
||||
"tag",
|
||||
@ -16,11 +16,15 @@
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "http://github.com/silverstripe-labs/silverstripe-tagfield/issues"
|
||||
"issues": "http://github.com/silverstripe/silverstripe-tagfield/issues"
|
||||
},
|
||||
"require": {
|
||||
"silverstripe/framework": "^4@dev",
|
||||
"silverstripe/versioned": "^1@dev"
|
||||
"silverstripe/framework": "^4.0",
|
||||
"silverstripe/versioned": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"squizlabs/php_codesniffer": "^3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@ -31,6 +35,12 @@
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.x-dev"
|
||||
}
|
||||
}
|
||||
},
|
||||
"expose": [
|
||||
"css",
|
||||
"js"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
|
13
phpunit.xml.dist
Normal file
13
phpunit.xml.dist
Normal file
@ -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.
|
||||
|
||||
[![Build Status](http://img.shields.io/travis/silverstripe-labs/silverstripe-tagfield.svg?style=flat-square)](https://travis-ci.org/silverstripe-labs/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 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)
|
||||
[![Version](http://img.shields.io/packagist/v/silverstripe/tagfield.svg?style=flat-square)](https://packagist.org/packages/silverstripe/tagfield)
|
||||
[![License](http://img.shields.io/packagist/l/silverstripe/tagfield.svg?style=flat-square)](license.md)
|
||||
[![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)](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)](https://packagist.org/packages/silverstripe/tagfield)
|
||||
[![License](http://img.shields.io/packagist/l/silverstripe/tagfield.svg?style=flat)](license.md)
|
||||
|
||||
## Requirements
|
||||
|
||||
* SilverStripe 3.1 or newer
|
||||
* Database: MySQL 5+, SQLite3, Postgres 8.3, SQL Server 2008
|
||||
* SilverStripe 4.0
|
||||
|
||||
## Installing
|
||||
|
||||
@ -24,22 +23,28 @@ $ composer require silverstripe/tagfield
|
||||
### Relational Tags
|
||||
|
||||
```php
|
||||
class BlogPost extends DataObject {
|
||||
private static $many_many = array(
|
||||
'BlogTags' => 'BlogTag'
|
||||
);
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class BlogPost extends DataObject
|
||||
{
|
||||
private static $many_many = [
|
||||
'BlogTags' => BlogTag::class
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
```php
|
||||
class BlogTag extends DataObject {
|
||||
private static $db = array(
|
||||
'Title' => 'Varchar(200)',
|
||||
);
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
private static $belongs_many_many = array(
|
||||
'BlogPosts' => 'BlogPost'
|
||||
);
|
||||
class BlogTag extends DataObject
|
||||
{
|
||||
private static $db = [
|
||||
'Title' => 'Varchar(200)',
|
||||
];
|
||||
|
||||
private static $belongs_many_many = [
|
||||
'BlogPosts' => BlogPost::class
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
@ -57,10 +62,13 @@ $field = TagField::create(
|
||||
### String Tags
|
||||
|
||||
```php
|
||||
class BlogPost extends DataObject {
|
||||
private static $db = array(
|
||||
'Tags' => 'Text'
|
||||
);
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class BlogPost extends DataObject
|
||||
{
|
||||
private static $db = [
|
||||
'Tags' => 'Text',
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
@ -68,7 +76,7 @@ class BlogPost extends DataObject {
|
||||
$field = StringTagField::create(
|
||||
'Tags',
|
||||
'Tags',
|
||||
array('one', 'two'),
|
||||
['one', 'two'],
|
||||
explode(',', $this->Tags)
|
||||
);
|
||||
|
||||
@ -85,4 +93,4 @@ All methods, with `public` visibility, are part of the public API. All other met
|
||||
|
||||
## 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())
|
||||
{
|
||||
Requirements::css(TAG_FIELD_DIR . '/css/select2.min.css');
|
||||
Requirements::css(TAG_FIELD_DIR . '/css/TagField.css');
|
||||
Requirements::css('silverstripe/tagfield:css/select2.min.css');
|
||||
Requirements::css('silverstripe/tagfield:css/TagField.css');
|
||||
|
||||
Requirements::javascript(TAG_FIELD_DIR . '/js/select2.js');
|
||||
Requirements::javascript(TAG_FIELD_DIR . '/js/TagField.js');
|
||||
Requirements::javascript('silverstripe/tagfield:js/select2.js');
|
||||
Requirements::javascript('silverstripe/tagfield:js/TagField.js');
|
||||
|
||||
$this->addExtraClass('ss-tag-field');
|
||||
|
||||
|
@ -198,11 +198,11 @@ class TagField extends DropdownField
|
||||
*/
|
||||
public function Field($properties = array())
|
||||
{
|
||||
Requirements::css(TAG_FIELD_DIR . '/css/select2.min.css');
|
||||
Requirements::css(TAG_FIELD_DIR . '/css/TagField.css');
|
||||
Requirements::css('silverstripe/tagfield:css/select2.min.css');
|
||||
Requirements::css('silverstripe/tagfield:css/TagField.css');
|
||||
|
||||
Requirements::javascript(TAG_FIELD_DIR . '/js/select2.js');
|
||||
Requirements::javascript(TAG_FIELD_DIR . '/js/TagField.js');
|
||||
Requirements::javascript('silverstripe/tagfield:js/select2.js');
|
||||
Requirements::javascript('silverstripe/tagfield:js/TagField.js');
|
||||
|
||||
$this->addExtraClass('ss-tag-field');
|
||||
|
||||
@ -242,7 +242,7 @@ class TagField extends DropdownField
|
||||
|
||||
$source = $this->getSourceList();
|
||||
|
||||
if(!$source) {
|
||||
if (!$source) {
|
||||
$source = ArrayList::create();
|
||||
}
|
||||
|
||||
@ -262,9 +262,9 @@ class TagField extends DropdownField
|
||||
|
||||
$titleField = $this->getTitleField();
|
||||
|
||||
foreach($source as $object) {
|
||||
foreach ($source as $object) {
|
||||
$options->push(
|
||||
ArrayData::create(array(
|
||||
ArrayData::create(array(
|
||||
'Title' => $object->$titleField,
|
||||
'Value' => $object->Title,
|
||||
'Selected' => in_array($object->Title, $ids),
|
||||
@ -273,7 +273,7 @@ class TagField extends DropdownField
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@ -345,7 +345,7 @@ class TagField extends DropdownField
|
||||
}
|
||||
|
||||
$relation->setByIDList(array_filter($ids));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create tag with the given value
|
||||
|
Loading…
Reference in New Issue
Block a user