PHP code example of koh / sylius-agent-contracts
1. Go to this page and download the library: Download koh/sylius-agent-contracts library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
koh / sylius-agent-contracts example snippets
// config/bundles.php
return [
// …
Koh\SyliusAgentContracts\KohSyliusAgentContractsBundle::class => ['all' => true],
];
// inject Koh\SyliusAgentContracts\Context\AgentContextFactoryInterface
$context = $agentContextFactory->create();
$context->url('/llms.txt'); // https://shop.example.com/llms.txt
$context->cacheKey('koh_llms_txt'); // koh_llms_txt.WEB_DE.de_DE
use Koh\SyliusAgentContracts\Context\AgentContext;
use Koh\SyliusAgentContracts\Model\{LlmsTxtLink, LlmsTxtSection};
use Koh\SyliusAgentContracts\Provider\LlmsTxtSectionProviderInterface;
final class ArticleLlmsTxtSectionProvider implements LlmsTxtSectionProviderInterface
{
public function getLlmsTxtSection(AgentContext $context): ?LlmsTxtSection
{
$links = [];
foreach ($this->articles->findPublished($context->channel, 100) as $article) {
$links[] = new LlmsTxtLink(
$article->getTitle(),
$context->url('/magazin/'.$article->getSlug()),
$article->getTeaser(),
);
}
return [] === $links ? null : new LlmsTxtSection('Magazin', $links, priority: 80);
}
}