-
-
Notifications
You must be signed in to change notification settings - Fork 810
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move fieldtype info to a trait and share between entities
- Loading branch information
Showing
4 changed files
with
53 additions
and
37 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
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,45 @@ | ||
<?php | ||
|
||
namespace Bolt\Storage\Entity; | ||
|
||
/** | ||
* Trait class for ContentType definitions. | ||
* | ||
* These traits should be considered transitional, the functionality in the | ||
* process of refactor, and not representative of a valid approach. | ||
* | ||
* @author Ross Riley <riley.ross@gmail.com> | ||
*/ | ||
trait ContentTypeTrait | ||
{ | ||
/** | ||
* Get field information for the given field. | ||
* | ||
* @param string $key | ||
* | ||
* @return array An associative array containing at least the key 'type', | ||
* and, depending on the type, other keys. | ||
*/ | ||
public function fieldInfo($key) | ||
{ | ||
if (isset($this->contenttype['fields'][$key])) { | ||
return $this->contenttype['fields'][$key]; | ||
} else { | ||
return ['type' => '']; | ||
} | ||
} | ||
|
||
/** | ||
* Get the field type for a given field name. | ||
* | ||
* @param string $key | ||
* | ||
* @return string | ||
*/ | ||
public function fieldType($key) | ||
{ | ||
$field = $this->fieldInfo($key); | ||
|
||
return $field['type']; | ||
} | ||
} |
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