Last active
April 10, 2017 17:10
-
-
Save kieranstartup/4500c2c82815fd341bf8dc28ab48f419 to your computer and use it in GitHub Desktop.
Revisions
-
kieranstartup revised this gist
Apr 10, 2017 . 1 changed file with 23 additions and 21 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,25 @@ <?php 'api/faq.json' => [ 'elementType' => 'Entry', 'criteria' => ['section' => 'faq'], 'transformer' => function(EntryModel $entry) { // Array for storing your Matrix Fields $arrayToStoreMatrixFields = []; foreach ($entry->matrixFieldHandle as $block) { switch ($block->type->handle) { case 'singleMatrixFieldBlockType': $arrayToStoreMatrixFields[] = [ 'singleMatrixFieldPlainText' => $block->singleMatrixFieldPlainText, 'singleMatrixFieldRichText' => $block->singleMatrixFieldRichText->getParsedContent(), ]; break; } } return [ 'arrayToStoreMatrixFields' => $arrayToStoreMatrixFields ]; }, ] ?> -
kieranstartup created this gist
Apr 10, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ 'api/faq.json' => [ 'elementType' => 'Entry', 'criteria' => ['section' => 'faq'], 'transformer' => function(EntryModel $entry) { // Array for storing your Matrix Fields $arrayToStoreMatrixFields = []; foreach ($entry->matrixFieldHandle as $block) { switch ($block->type->handle) { case 'singleMatrixFieldBlockType': $arrayToStoreMatrixFields[] = [ 'singleMatrixFieldPlainText' => $block->singleMatrixFieldPlainText, 'singleMatrixFieldRichText' => $block->singleMatrixFieldRichText->getParsedContent(), ]; break; } } return [ 'arrayToStoreMatrixFields' => $arrayToStoreMatrixFields ]; }, ]