Created
January 18, 2017 22:50
-
-
Save tommymarshall/6839c3ecaec0af77782dd247655d08aa to your computer and use it in GitHub Desktop.
Contentful Feed Builder
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 characters
<?php | |
class ContentfulBuilder { | |
protected $query; | |
public function __construct() { | |
$this->query = new Query; | |
} | |
public function setContentType($content_type) { | |
$this->query->setContentType($content_type); | |
return $this; | |
} | |
public function where($query) | |
{ | |
if (is_array($query)) { | |
foreach ($query as $key => $value) { | |
$this->query->where("fields.$key", $value); | |
} | |
} | |
return $this; | |
} | |
public function get() | |
{ | |
return $this->query; | |
} | |
} |
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 characters
<?php | |
$query = (new ContentfulBuilder)->setContentType('gameAssetCarousel')->where([ | |
'namespace' => 'foo', | |
'tags' => 'foo_index', | |
])->get(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment