Skip to content

[charcoal/admin] Add support for dynamic type field to ObjectContainerTrait #87

@mcaskill

Description

@mcaskill

This would improve support for polymorphic model relationships, similar to CollectionContainerTrait.

This would probably require a dedicated model loader that also resolves. Alternatively, just use a collection loader.

/**
* Set the object type.
*
* @param string $objType The object type.
* @throws InvalidArgumentException If provided argument is not of type 'string'.
* @return ObjectContainerInterface Chainable
*/
public function setObjType($objType)
{
if (!is_string($objType)) {
throw new InvalidArgumentException(sprintf(
'Object type must be a string, received %s.',
(is_object($objType) ? get_class($objType) : gettype($objType))
));
}
$this->objType = str_replace(['.', '_'], '/', $objType);
return $this;
}
/**
* Retrieve the object type.
*
* @return string|null
*/
public function objType()
{
return $this->objType;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions