Skip to content

Commit 8091c7c

Browse files
authored
Merge pull request #76 from corcel/develop
Release last changes on develop branch
2 parents a8ee2f9 + 57aa311 commit 8091c7c

7 files changed

Lines changed: 25 additions & 11 deletions

File tree

.styleci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
preset: psr2
2-
risky: false
3-
linting: true
42
finder:
53
name:
64
- "*.php"

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ language: php
22
php:
33
- '5.6'
44
- '7.0'
5+
- '7.1'
6+
- '7.2'
7+
- '7.3'
58
dist: trusty
69
sudo: required
710
addons:
@@ -20,4 +23,4 @@ before_script:
2023
- composer install
2124
script:
2225
- mkdir -p build/logs
23-
- phpunit
26+
- ./vendor/bin/phpunit

src/Field/BasicField.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Corcel\Model\Meta\PostMeta;
88
use Corcel\Model\Term;
99
use Corcel\Model\Meta\TermMeta;
10+
use Corcel\Model\User;
11+
use Corcel\Model\Meta\UserMeta;
1012

1113
/**
1214
* Class BasicField.
@@ -63,6 +65,8 @@ public function __construct(Model $post)
6365
$this->postMeta = new PostMeta();
6466
} elseif ($post instanceof Term) {
6567
$this->postMeta = new TermMeta();
68+
} elseif ($post instanceof User) {
69+
$this->postMeta = new UserMeta();
6670
}
6771

6872
$this->postMeta->setConnection($post->getConnectionName());
@@ -151,6 +155,8 @@ public function getKeyName()
151155
return 'post_id';
152156
} elseif ($this->post instanceof Term) {
153157
return 'term_id';
158+
} elseif ($this->post instanceof User) {
159+
return 'user_id';
154160
}
155161
}
156162

src/Field/Gallery.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,21 @@ public function process($field)
3030
{
3131
if ($ids = $this->fetchValue($field)) {
3232
$connection = $this->post->getConnectionName();
33-
$attachments = Post::on($connection)->whereIn('ID', $ids)->get();
33+
34+
$ids_ordered = implode(',', $ids);
35+
36+
$attachments = Post::on($connection)->whereIn('ID', $ids)
37+
->orderByRaw("FIELD(ID, $ids_ordered)")->get();
3438

3539
$metaDataValues = $this->fetchMultipleMetadataValues($attachments);
3640

3741
foreach ($attachments as $attachment) {
38-
$image = new Image($this->post);
39-
$image->fillFields($attachment);
40-
$image->fillMetadataFields($metaDataValues[$attachment->ID]);
41-
$this->images[] = $image;
42+
if (array_key_exists($attachment->ID, $metaDataValues)) {
43+
$image = new Image($this->post);
44+
$image->fillFields($attachment);
45+
$image->fillMetadataFields($metaDataValues[$attachment->ID]);
46+
$this->images[] = $image;
47+
}
4248
}
4349
}
4450
}

src/Field/Repeater.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function fetchPostsMeta($fieldName, $post)
7676
{
7777
$count = (int) $this->fetchValue($fieldName);
7878

79-
if ($this->postMeta instanceof \Corcel\TermMeta) {
79+
if ($this->postMeta instanceof \Corcel\Model\Meta\TermMeta) {
8080
$builder = $this->postMeta->where('term_id', $post->term_id);
8181
} else {
8282
$builder = $this->postMeta->where('post_id', $post->ID);

src/FieldFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public static function make($name, Model $post, $type = null)
5656
case 'number':
5757
case 'email':
5858
case 'url':
59+
case 'link':
5960
case 'password':
6061
case 'wysiwyg':
6162
case 'editor':

tests/ContentFieldsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public function testGalleryFieldValue()
9797
$this->assertTrue(strlen($image->url) > 0);
9898
}
9999

100-
// Testing the image in the 6th position
101-
$image = $gallery->get()->get(6);
100+
// Testing the image in the 0th position
101+
$image = $gallery->get()->get(0);
102102
$this->assertEquals(1920, $image->width);
103103
$this->assertEquals(1080, $image->height);
104104
}

0 commit comments

Comments
 (0)