You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**
* A list of class names implementing \Swis\JsonApi\Client\Interfaces\ItemInterface.
*
* @var string[]
*/
protected $items = [
CampagneItem::class,
OrdiniItem::class,
GruppoOfferteItem::class,
ClientiItem::class,
AnagraficaClientiItem::class,
UserItem::class,
FormOfferteItem::class,
OrderStatusItem::class
];
/**
* @param \Swis\JsonApi\Client\Interfaces\TypeMapperInterface $typeMapper
*/
public function boot(TypeMapperInterface $typeMapper) {
foreach ($this->items as $class) {
/** @var \Swis\JsonApi\Client\Interfaces\ItemInterface $item */
$item = $this->app->make($class);
$typeMapper->setMapping($item->getType(), $class);
}
}
}
in my custom controller how can i access to these mapped classes?
if i write $typeMapper = app(TypeMapper::class) is empty of course...
Sorry if question is stupid but I don't have noone to ask to...
The text was updated successfully, but these errors were encountered:
Hi @V-Orbit, thanks for reaching out! You should use TypeMapperInterface, which is registered as singleton, instead of TypeMapper e.g.
$typeMapper = app(TypeMapperInterface::class);
$campagne = $typeMapper->getMapping('campagne'); // new instance of CampagneItem (assuming that's the type of the item...)
I'll leave this issue open to clarify this in the docs.
Hi Guys, this is driving me crazy.
in my custom controller how can i access to these mapped classes?
if i write
$typeMapper = app(TypeMapper::class)
is empty of course...Sorry if question is stupid but I don't have noone to ask to...
The text was updated successfully, but these errors were encountered: