src/AppBundle/Component/Export/Exporter.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace AppBundle\Component\Export;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Filesystem\Filesystem;

abstract class Exporter implements ExporterInterface
{
    /**
     * @var ContainerInterface
     */
    protected $container;
    protected $conditions;
    protected $parameter;

    public function __construct($container, $conditions)
    {
        $this->container = $container;

        $this->parameter = $this->buildParameter($conditions);
        $this->conditions = $this->buildCondition($conditions);
    }

    //定义导出标题
    abstract public function getTitles();

    //获得导出正文内容
    abstract public function getContent($start, $limit);

    //下载权限判断
    abstract public function canExport();

    //获得导出总条数
    abstract public function getCount();

    //构建查询条件
    abstract public function buildCondition($conditions);

    public function export($name = '')
    {
        if (!$this->canExport()) {
            return array(
                'success' => 0,
                'message' => 'export.not_allowed',
            );
        }
        list($start, $limit) = $this->getPageConditions();

        $fileName = empty($this->parameter['start']) ? $this->generateExportName() : $this->parameter['fileName'];
        $filePath = $this->exportFileRootPath().$fileName;

        $data = $this->getContent($start, $limit);

        $this->addContent($data, $start, $filePath);

        $endPage = $start + $limit;

        $count = $this->getCount();

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。