What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hey. A little bit stuck here, help would be appreciated! I have written a composer library (lets st

U0134CBTUKS
U0134CBTUKS Posts: 42 πŸ§‘πŸ»β€πŸš€ - Cadet
edited August 2020 in Slack General

Hey. A little bit stuck here, help would be appreciated!
I have written a composer library (lets stay Lib) and I'm trying to load service in Zed that extends spryker as usual (e.g vendor/Lib/Service/UtilTextService), when I provide it in Dependency provider in zed it can't find it - just finds Spryker one.
I added my "Lib" namespace to CORE_NAMESPACES. What did I miss?

Comments

  • UP3PTBA3F
    UP3PTBA3F Posts: 4 πŸ§‘πŸ»β€πŸš€ - Cadet

    hi, maybe try composer dump-autoload -o

  • U0134CBTUKS
    U0134CBTUKS Posts: 42 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited August 2020

    hey, sadly tried it and still get
    Return value of Lib\Zed\Module\DependencyProvider::Lib\Zed\Module{closure}() must be an instance of Lib\Service\UtilText\UtilTextServiceInterface, instance of Spryker\Service\UtilText\UtilTextService returned

  • UP3PTBA3F
    UP3PTBA3F Posts: 4 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited August 2020

    then check what you have as a return of our method. Maybe you return something from vendors. not from your classes

  • U0134CBTUKS
    U0134CBTUKS Posts: 42 πŸ§‘πŸ»β€πŸš€ - Cadet

    when I do

    $container->set(static::SERVICE_UTIL_TEXT, static function (Container $container): UtilTextServiceInterface {
        return new UtilTextService(); (Lib namespace)
    });
    

    it works πŸ˜• locator can't find it

  • U0134CBTUKS
    U0134CBTUKS Posts: 42 πŸ§‘πŸ»β€πŸš€ - Cadet

    with

    return $container->getLocator()->utilText()->service();
    
  • UP3PTBA3F
    UP3PTBA3F Posts: 4 πŸ§‘πŸ»β€πŸš€ - Cadet

    I think it is a just a return type issue. Need to see a full code to say mo exact

  • U0134CBTUKS
    U0134CBTUKS Posts: 42 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited August 2020

    both return types in dependency provider and business factory has Lib namespace if it weren't the "new UtilTextService" would fail too

  • UP3PTBA3F
    UP3PTBA3F Posts: 4 πŸ§‘πŸ»β€πŸš€ - Cadet

    maybe inside UtilTextService() class you init the vendor one and return it

  • UKHD8KTMF
    UKHD8KTMF Posts: 393 πŸ§‘πŸ»β€πŸš€ - Cadet

    stupid question but is your lib following conventions -> file naming, file position, implementing interfaces, extending proper base classes etc

  • U0134CBTUKS
    U0134CBTUKS Posts: 42 πŸ§‘πŸ»β€πŸš€ - Cadet

    everything looks as ok as usual, nvm I'll try to debug locator