-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* enhance(partials): Move partial `get()` method to a Concern * fix(partials): Fix partial `get()` method when passed a path * enhance(acf-composer): Move field group composing to the boot() method so field classes can access Acorn properly
- Loading branch information
Showing
3 changed files
with
90 additions
and
48 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Log1x\AcfComposer\Concerns; | ||
|
||
use ReflectionClass; | ||
use Illuminate\Support\Str; | ||
use Log1x\AcfComposer\Partial; | ||
use StoutLogic\AcfBuilder\FieldsBuilder; | ||
|
||
trait RetrievesPartials | ||
{ | ||
/** | ||
* Compose a field partial instance or file. | ||
* | ||
* @param mixed $partial | ||
* @return array | ||
*/ | ||
protected function get($partial = null) | ||
{ | ||
if ( | ||
is_subclass_of($partial, Partial::class) && | ||
! (new ReflectionClass($partial))->isAbstract() | ||
) { | ||
return (new $partial($this->app))->compose(); | ||
} | ||
|
||
if (is_a($partial, FieldsBuilder::class) || is_array($partial)) { | ||
return $partial; | ||
} | ||
|
||
return $this->files->exists( | ||
$partial = $this->app->path( | ||
Str::finish( | ||
strtr($partial, ['.php' => '', '.' => '/']), | ||
'.php' | ||
) | ||
) | ||
) ? include $partial : []; | ||
} | ||
} |
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