@param $content
@param $type
@return mixed

@throws \Psr\Cache\InvalidArgumentException
195266
public static function modify($content, $type)
    {
        if (!array_key_exists($type, self::$types)) {
            throw new \LogicException(sprintf("Unsuported type `%s` of minifier.", $type));
        }

        $modifier = self::$types[$type];

        if (!$modifier['enabled']) {
            return $content;
        }

        $cacheId = md5($content);

        if (self::$cache && self::$cache->hasItem($cacheId)) {
            return self::$cache->getItem($cacheId)->get();
        }

        $content = call_user_func_array(
            [$modifier['class'], $modifier['method']],
            [$content, $modifier['options']]
        );

        self::$cache && self::$cache->save(self::$cache->getItem($cacheId)->set($content));

        return $content;
    }
1213189
public static function get($type)
    {
        if (!isset(static::$_modelFactories['Table'])) {
            static::$_modelFactories['Table'] = [TableRegistry::getTableLocator(), 'get'];
        }

        if (!isset(static::$_modelFactories[$type])) {
            throw new InvalidArgumentException(sprintf(
                'Unknown repository type "%s". Make sure you register a type before trying to use it.',
                $type
            ));
        }

        return static::$_modelFactories[$type];
    }
206059
public function setContent($content)
    {
        if ($this->version != Feed::ATOM)
            throw new InvalidOperationException('The content element is supported in ATOM feeds only.');

        return $this->addElement('content', $content, array('type' => 'html'));
    }
573493
public static function getByType(string $type, string $content = null): ResponseContextAbstract
    {
        switch ($type) {
            case self::RESPONSE_TYPE_JSON:
                return new JsonResponseContext($content);
            default:
                return new DummyResponseContext($content);
        }
    }
39518
public function setContent($content)
    {
        if(strlen($content) > 9900)
        {
            throw new \InvalidArgumentException('Maximum content length is 9900 characters');
        }

        $this->content = $content;

        $this->setHash(sha1($content));

        return $this;
    }
493396
public function prepareContent($content)
    {
        $cto = $this->getContentTypeObject();
        if (!empty($cto)) {
            return $cto->prepareContent($content);
        } else {
            return (string) $content;
        }
    }
1123474
protected function getRepositoryByType($type)
    {
        if (BlockInterface::ENTITY_TYPE === $type) {
            return $this->blockRepository;
        }
        if (ContentInterface::ENTITY_TYPE === $type) {
            return $this->contentRepository;
        }
        throw new \InvalidArgumentException($type . "ins't supported");
    }
441748
public function filter($content, $search, $type)
    {
        $items = !empty($content) ? unserialize($content) : [];
        switch ($type) {
            case 'in':
                foreach ($items as $item) {
                    if (strpos($item, $search) !== false) {
                        return true;
                    }
                }
                return false;
                break;
            default:
                return in_array($search, $items);
        }
    }
417948
public function addMessage($type, $content)
	{
		if(isset($_SESSION[$this->sessionKey])) {
			$messages = $_SESSION[$this->sessionKey];
		}
		
		$messages[] = [
			'content' => $content,
			'type' => $type,
		];
		
		$_SESSION[$this->sessionKey] = $messages;
	}
1354629
public function createDefaultContainer($type = null, array $data = [], EM\ContentInterface $content = null)
    {
        return $this->getContainerManager()->create($content, $type, $data);
    }
947007
public function generateText($type = 'html', $content = array())
    {
        $apiCall = '/helper/generate-text';
        $payload = array(
            'type'      => $type,
            'content'   => $content
        );

        $data = $this->requestMonkey($apiCall, $payload);
        $data = json_decode($data, true);
        if (isset($data['error']))
            throw new MailchimpAPIException($data);
        else
            return $data;
    }
205315
public function setMessage($type, $content)
    {
        $message = new \stdClass;
        $message->mt = $type;
        $message->content = $content;
        $messages = $this->session()->get('messages', array());
        $messages[] = $message;
        $this->session()->set('messages', $messages);
    }
299228
public function uploadByContent($content, $type = '', $option = [])
    {
        // 临时文件
        $tmp_file = Common::tmpFile('upload');
        file_put_contents($tmp_file, $content);
        
        // 上传完删除文件
        $this->onDone = function ($data) {
            @unlink($data['path']);
        };
        
        return $this->uploadByPath($tmp_file, $type, $option);
    }
940596
public static function create($type, $content)
	{
		if (empty($type)) {
			throw new AlertTypeException('Unable to create message with invalid type.');
		}

		if (empty($content)) {
			throw new AlertContentException('Unable to create message with invalid content.');
		}

		return new self($type, $content);
	}
393343
public function GetReferencedContainer(Content $content)
    {
        $contentContainer = ContentContainer::Schema()->ByContent($content);
        return $contentContainer ? $contentContainer->GetContainer() : null;
    }
320757
protected function resolveType($contentType)
    {
        $mapped = $this->getMimeType($contentType);
        if ($mapped) {
            return is_array($mapped) ? current($mapped) : $mapped;
        }
        if (strpos($contentType, '/') === false) {
            throw new InvalidArgumentException(sprintf('"%s" is an invalid content type.', $contentType));
        }

        return $contentType;
    }
184300
private function build(string $type)
    {
        if (!in_array($type, ['public', 'local'])) {
            throw new \InvalidArgumentException('type accepts public or local');
        }
        if (!$this->called) {
            $url = $type === 'public' ? $this->config->env['public'] : $this->config->env['local'];
            $url = rtrim($url, '/');
            Util::clearDirectory($this->config->path('cache'));
            $articles        = ArticleGenerator::getArticles($this->config->path('article'), $url);
            $paths = $this->config->paths;
            $articles->each(function ($article) use ($paths) {
                $article->createCache("{$paths['cache']}/article");
            });
            $this->generator = new SiteGenerator($this->config, $articles);
            $this->called    = true;
        }
        Util::clearDirectory($this->config->path($type), true);
        $this->generator->generate($type);
    }