nepttune/robots

机器人生成组件

v2.0.2 2019-11-05 22:27 UTC

This package is auto-updated.

Last update: 2024-09-06 09:58:19 UTC


README

🔧 机器人生成组件

简介

此组件自动从配置中的参数生成机器人。

依赖项

如何使用

  • 在配置文件中将 \Nepttune\Component\IRobotsFactory 注册为服务,将其注入到演示者中,编写 createComponent 方法,并在模板文件中使用宏 {control}。
    • 就像任何其他组件一样。
    • 您需要将机器人配置传递给工厂服务。
    • 内容类型自动设置为 text/plain。
  • 修改参数以满足您的需求。

示例配置

services:
    robotsFactory:
        implement: Nepttune\Component\IRobotsFactory
        arguments:
          - '%robots%'
parameters:
    robots:
        all:
            name: '*'
            disallow:
        google:
            name 'GoogleBot'
            disallow:
              - '/example'
              - '/example2'

示例演示者

class ExamplePresenter implements IPresenter
{
    /** @var  \Nepttune\Component\IRobotsFactory */
    protected $iRobotsFactory;
    
    public function __construct(\Nepttune\Component\IRobotsFactory $IRobotsFactory)
    {
        $this->iRobotsFactory = $IRobotsFactory;
    }

    protected function createComponentRobots() : \Nepttune\Component\Robots
    {
        return $this->iRobotsFactory->create();
    }
}