Skip to content

Instantly share code, notes, and snippets.

@tomasnorre
Last active March 18, 2021 18:12
Show Gist options
  • Save tomasnorre/fa253f65bbd155b2a98eec4399dc7779 to your computer and use it in GitHub Desktop.
Save tomasnorre/fa253f65bbd155b2a98eec4399dc7779 to your computer and use it in GitHub Desktop.
DI in TYPO3 10.4
<?php
declare(strict_types=1);
namespace AOE\Crawler;
use AOE\Crawler\Controller\CrawlerController;
use AOE\Crawler\Converter\JsonCompatibilityConverter;
use AOE\Crawler\CrawlStrategy\CallbackExecutionStrategy;
use AOE\Crawler\CrawlStrategy\CrawlStrategy;
use AOE\Crawler\Utility\SignalSlotUtility;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Fetches a URL based on the selected strategy or via a callback.
*/
class QueueExecutor implements SingletonInterface
{
/**
* @var CrawlStrategy
*/
protected $crawlStrategy;
public function __construct(CrawlStrategy $crawlStrategy)
{
$this->crawlStrategy = $crawlStrategy;
}
services:
_defaults:
autowire: true
autoconfigure: true
public: false
AOE\Crawler\:
resource: '../Classes/*'
AOE\Crawler\CrawlStrategy\CrawlStrategy:
alias: AOE\Crawler\CrawlStrategy\GuzzleExecutionStrategy
AOE\Crawler\QueueExecutor:
# mark public – means this service should be accessible from $container->get()
# and (often more important), both GeneralUtility::makeInstance() and the Extbase
# ObjectManager will be able to use the Symfony DI managed service
public: true
# Defining a service to be shared is equal to TYPO3's SingletonInterface behaviour
shared: true
# Configure constructor arguments
arguments:
$crawlStrategy: '@AOE\Crawler\CrawlStrategy\CrawlStrategy'
AOE\Crawler\Tests\Functional\Controller\CrawlerControllerTest::expandExcludeStringReturnsArraysOfIntegers
Symfony\Component\DependencyInjection\Exception\RuntimeException: Cannot autowire service "AOE\Crawler\QueueExecutor": argument "$crawlStrategy" of method "__construct()" references interface "AOE\Crawler\CrawlStrategy\CrawlStrategy" but no such service exists. You should maybe alias this interface to one of these existing services: "AOE\Crawler\CrawlStrategy\GuzzleExecutionStrategy", "AOE\Crawler\CrawlStrategy\SubProcessExecutionStrategy".
@cweiske
Copy link

cweiske commented Mar 18, 2021

How did you solve the error?

@tomasnorre
Copy link
Author

Do you have a link to where I describe the problem? The gist alone is't ringing any bell for me unfortunately.
I will remember the next time to ask in the gist as well adding the solution.

@cweiske
Copy link

cweiske commented Mar 18, 2021

sorry, no. I just found this gist through a search engine.

@tomasnorre
Copy link
Author

I found it from a twitter search for the url:
https://twitter.com/tomasnorre/status/1315330213018992643

@tomasnorre
Copy link
Author

I cannot complete recall, but reading through the commits I think this was the change I did to fix my problem.
AOEpeople/crawler@c9d0889

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment