From 71faecaadce89c5d76e5fce8b69c63581e9522b1 Mon Sep 17 00:00:00 2001 From: Mark Pemburn Date: Fri, 22 Sep 2017 15:09:08 -0400 Subject: [PATCH 1/6] Make ACF compatible with users --- src/Field/BasicField.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Field/BasicField.php b/src/Field/BasicField.php index 5b39971..546c6e3 100644 --- a/src/Field/BasicField.php +++ b/src/Field/BasicField.php @@ -7,6 +7,9 @@ use Corcel\Model\Meta\PostMeta; use Corcel\Model\Term; use Corcel\Model\Meta\TermMeta; +use Corcel\Model\User; +use Corcel\Model\Meta\UserMeta; + /** * Class BasicField. @@ -63,6 +66,8 @@ public function __construct(Model $post) $this->postMeta = new PostMeta(); } elseif ($post instanceof Term) { $this->postMeta = new TermMeta(); + } elseif ($post instanceof User) { + $this->postMeta = new UserMeta(); } $this->postMeta->setConnection($post->getConnectionName()); @@ -151,6 +156,8 @@ public function getKeyName() return 'post_id'; } elseif ($this->post instanceof Term) { return 'term_id'; + } elseif ($this->post instanceof User) { + return 'user_id'; } } From e598b468df622545a432b78e0387e899f7262103 Mon Sep 17 00:00:00 2001 From: Mark Pemburn Date: Fri, 22 Sep 2017 15:13:42 -0400 Subject: [PATCH 2/6] Style error --- src/Field/BasicField.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Field/BasicField.php b/src/Field/BasicField.php index 546c6e3..bae10ae 100644 --- a/src/Field/BasicField.php +++ b/src/Field/BasicField.php @@ -10,7 +10,6 @@ use Corcel\Model\User; use Corcel\Model\Meta\UserMeta; - /** * Class BasicField. * From 6265880ebf2c8db8cde61d8968e3feaaeb09aee8 Mon Sep 17 00:00:00 2001 From: Omar Ahmed Date: Tue, 31 Oct 2017 21:39:21 +0000 Subject: [PATCH 3/6] add attachment id array key exists check --- src/Field/Gallery.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Field/Gallery.php b/src/Field/Gallery.php index b1bb286..a8a9a31 100644 --- a/src/Field/Gallery.php +++ b/src/Field/Gallery.php @@ -35,10 +35,12 @@ public function process($field) $metaDataValues = $this->fetchMultipleMetadataValues($attachments); foreach ($attachments as $attachment) { - $image = new Image($this->post); - $image->fillFields($attachment); - $image->fillMetadataFields($metaDataValues[$attachment->ID]); - $this->images[] = $image; + if (array_key_exists($attachment->ID, $metaDataValues)) { + $image = new Image($this->post); + $image->fillFields($attachment); + $image->fillMetadataFields($metaDataValues[$attachment->ID]); + $this->images[] = $image; + } } } } From 3801303295bc4d33e0637062208f5227347945b5 Mon Sep 17 00:00:00 2001 From: ivometz Date: Fri, 17 Nov 2017 10:50:09 +0100 Subject: [PATCH 4/6] Add missing link type in fieldfactory --- src/FieldFactory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/FieldFactory.php b/src/FieldFactory.php index 13d881f..2709458 100644 --- a/src/FieldFactory.php +++ b/src/FieldFactory.php @@ -56,6 +56,7 @@ public static function make($name, Model $post, $type = null) case 'number': case 'email': case 'url': + case 'link': case 'password': case 'wysiwyg': case 'editor': From 7aec96ecd0a67f7726520651b7f5a75fa0832fd7 Mon Sep 17 00:00:00 2001 From: Naeem Date: Sun, 21 Jan 2018 12:51:22 +0400 Subject: [PATCH 5/6] Missing GoogleMap field added Add GoogleMap class file, and update FieldFactory file for switch case condition. --- readme.md | 4 ++-- src/Field/GoogleMap.php | 34 ++++++++++++++++++++++++++++++++++ src/FieldFactory.php | 3 +++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/Field/GoogleMap.php diff --git a/readme.md b/readme.md index d718b9f..1c3c4bd 100644 --- a/readme.md +++ b/readme.md @@ -70,7 +70,7 @@ First we should create the fields classes and the test cases. After we have to s - Implement the `Flexible Content` field with unit tests (done!); - Improve performance. Currently the plugin makes one SQL query for each field. This goal is to improve that using `whereIn()` clauses. - Some fields are still missing (check table below and contribute). + ## Fields @@ -96,7 +96,7 @@ First we should create the fields classes and the test cases. After we have to s | Relationship | ok | [@jgrossi](http://github.com/jgrossi) | `Corcel\Post` or `Collection` of `Post` | | Taxonomy | ok | [@jgrossi](http://github.com/jgrossi) | `Corcel\Term` or `Collection` of `Term` | | User | ok | [@jgrossi](http://github.com/jgrossi) | `Corcel\User` | -| Google Map | missing | | +| Google Map | ok | [@naeemz] (http://github.com/naeemz) | `array` | | Date Picker | ok | [@jgrossi](http://github.com/jgrossi) | `Carbon\Carbon` | | Date Time Picker | ok | [@jgrossi](http://github.com/jgrossi) | `Carbon\Carbon` | | Time Picker | ok | [@jgrossi](http://github.com/jgrossi) | `Carbon\Carbon` | diff --git a/src/Field/GoogleMap.php b/src/Field/GoogleMap.php new file mode 100644 index 0000000..ae387a9 --- /dev/null +++ b/src/Field/GoogleMap.php @@ -0,0 +1,34 @@ + + */ +class GoogleMap extends BasicField implements FieldInterface +{ + /** + * @var Array + */ + protected $cords; + + /** + * @param string $fieldName + */ + public function process($fieldName) + { + $this->cords = $this->fetchValue($fieldName); + } + + /** + * @return Array + */ + public function get() + { + return $this->cords; + } +} diff --git a/src/FieldFactory.php b/src/FieldFactory.php index 2709458..dc22cbe 100644 --- a/src/FieldFactory.php +++ b/src/FieldFactory.php @@ -107,6 +107,9 @@ public static function make($name, Model $post, $type = null) break; case 'flexible_content': $field = new FlexibleContent($post); + break; + case 'google_map': + $field = new GoogleMap($post); break; default: return null; } From a4e8daa5b1c3c11d00de3f4d06a4764ccf53d62a Mon Sep 17 00:00:00 2001 From: Naeem Date: Sun, 21 Jan 2018 12:59:47 +0400 Subject: [PATCH 6/6] Update FieldFactory.php --- src/FieldFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FieldFactory.php b/src/FieldFactory.php index dc22cbe..0d394ee 100644 --- a/src/FieldFactory.php +++ b/src/FieldFactory.php @@ -108,7 +108,7 @@ public static function make($name, Model $post, $type = null) case 'flexible_content': $field = new FlexibleContent($post); break; - case 'google_map': + case 'google_map': $field = new GoogleMap($post); break; default: return null;