-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
149 additions
and
81 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,12 @@ | |
|
||
namespace Corcel\Acf; | ||
|
||
use Corcel\Acf\Exception\MissingFieldNameException; | ||
use Corcel\Post; | ||
|
||
/** | ||
* Class AdvancedCustomFields | ||
* Class AdvancedCustomFields. | ||
* | ||
* @package Corcel\Acf | ||
* @author Junior Grossi <[email protected]> | ||
*/ | ||
class AdvancedCustomFields | ||
|
@@ -37,10 +37,32 @@ public function get($fieldName) | |
|
||
/** | ||
* @param string $name | ||
* | ||
* @return mixed | ||
*/ | ||
public function __get($name) | ||
{ | ||
return $this->get($name); | ||
} | ||
|
||
/** | ||
* Make possible to call $post->acf->fieldType('fieldName'). | ||
* | ||
* @param string$name | ||
* @param array $arguments | ||
* | ||
* @return mixed | ||
* | ||
* @throws MissingFieldNameException | ||
*/ | ||
public function __call($name, $arguments) | ||
{ | ||
if (!isset($arguments[0])) { | ||
throw new MissingFieldNameException('The field name is missing'); | ||
} | ||
|
||
$field = FieldFactory::make($arguments[0], $this->post, snake_case($name)); | ||
|
||
return $field->get(); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Corcel\Acf\Exception; | ||
|
||
/** | ||
* Class MissingFieldNameException. | ||
* | ||
* @author Junior Grossi <[email protected]> | ||
*/ | ||
class MissingFieldNameException extends \Exception | ||
{ | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,8 @@ | |
use Corcel\PostMeta; | ||
|
||
/** | ||
* Class BasicField | ||
* Class BasicField. | ||
* | ||
* @package Corcel\Acf\Field | ||
* @author Junior Grossi <[email protected]> | ||
*/ | ||
abstract class BasicField | ||
|
@@ -44,18 +43,19 @@ abstract class BasicField | |
protected $value; | ||
|
||
/** | ||
* Constructor method | ||
* Constructor method. | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->postMeta = new PostMeta(); | ||
} | ||
|
||
/** | ||
* Get the value of a field according it's post ID | ||
* Get the value of a field according it's post ID. | ||
* | ||
* @param string $field | ||
* @param Post $post | ||
* @param Post $post | ||
* | ||
* @return array|string | ||
*/ | ||
public function fetchValue($field, Post $post) | ||
|
@@ -80,7 +80,8 @@ public function fetchValue($field, Post $post) | |
|
||
/** | ||
* @param string $fieldName | ||
* @param Post $post | ||
* @param Post $post | ||
* | ||
* @return string | ||
*/ | ||
public function fetchFieldKey($fieldName, Post $post) | ||
|
@@ -103,6 +104,7 @@ public function fetchFieldKey($fieldName, Post $post) | |
|
||
/** | ||
* @param string $fieldKey | ||
* | ||
* @return string | ||
*/ | ||
public function fetchFieldType($fieldKey) | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,8 @@ | |
use Corcel\Acf\FieldInterface; | ||
|
||
/** | ||
* Class Boolean | ||
* Class Boolean. | ||
* | ||
* @package Corcel\Acf\Field | ||
* @author Junior Grossi <[email protected]> | ||
*/ | ||
class Boolean extends Text implements FieldInterface | ||
|
@@ -17,6 +16,6 @@ class Boolean extends Text implements FieldInterface | |
*/ | ||
public function get() | ||
{ | ||
return (bool)parent::get(); | ||
return (bool) parent::get(); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,8 @@ | |
use Corcel\Post; | ||
|
||
/** | ||
* Class DateTime | ||
* Class DateTime. | ||
* | ||
* @package Corcel\Acf\Field | ||
* @author Junior Grossi <[email protected]> | ||
*/ | ||
class DateTime extends BasicField implements FieldInterface | ||
|
@@ -21,7 +20,7 @@ class DateTime extends BasicField implements FieldInterface | |
|
||
/** | ||
* @param string $fieldName | ||
* @param Post $post | ||
* @param Post $post | ||
*/ | ||
public function process($fieldName, Post $post) | ||
{ | ||
|
@@ -40,6 +39,7 @@ public function get() | |
|
||
/** | ||
* @param string $dateString | ||
* | ||
* @return string | ||
*/ | ||
protected function getDateFormatFromString($dateString) | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,8 @@ | |
use Corcel\Post; | ||
|
||
/** | ||
* Class File | ||
* Class File. | ||
* | ||
* @package Corcel\Acf\Field | ||
* @author Junior Grossi <[email protected]> | ||
*/ | ||
class File extends BasicField implements FieldInterface | ||
|
@@ -45,7 +44,7 @@ class File extends BasicField implements FieldInterface | |
|
||
/** | ||
* @param string $field | ||
* @param Post $post | ||
* @param Post $post | ||
*/ | ||
public function process($field, Post $post) | ||
{ | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,8 @@ | |
use Illuminate\Support\Collection; | ||
|
||
/** | ||
* Class Gallery | ||
* Class Gallery. | ||
* | ||
* @package Corcel\Acf\Field | ||
* @author Junior Grossi <[email protected]> | ||
*/ | ||
class Gallery extends Image implements FieldInterface | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,8 @@ | |
use Corcel\Acf\FieldInterface; | ||
|
||
/** | ||
* Class PageLink | ||
* Class PageLink. | ||
* | ||
* @package Corcel\Acf\Field | ||
* @author Junior Grossi <[email protected]> | ||
*/ | ||
class PageLink extends PostObject implements FieldInterface | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,8 @@ | |
use Corcel\Post; | ||
|
||
/** | ||
* Class PostObject | ||
* Class PostObject. | ||
* | ||
* @package Corcel\Acf\Field | ||
* @author Junior Grossi <[email protected]> | ||
*/ | ||
class PostObject extends BasicField implements FieldInterface | ||
|
@@ -20,7 +19,7 @@ class PostObject extends BasicField implements FieldInterface | |
|
||
/** | ||
* @param string $fieldName | ||
* @param Post $post | ||
* @param Post $post | ||
*/ | ||
public function process($fieldName, Post $post) | ||
{ | ||
|
Oops, something went wrong.