スルー/スニペット-パッケージ

此包已被废弃,不再维护。作者建议使用sulu/sulu包代替。

该包为Sulu内容管理系统中的片段创建/管理/使用提供支持

0.1.0 2014-10-29 17:43 UTC

This package is not auto-updated.

Last update: 2016-03-10 09:53:29 UTC


README

Build Status

使用方法

可以通过现有API管理片段。

为什么不使用片段管理器作为代理呢?

  • 管理代码越多,错误越多
  • 限制了现有代码的重用(例如,AJAX端点)

获取片段类型

$structureManager = $this->getContainer('sulu.structure_manager');
$snippetTypes = $structureManager->getTemplates(Structure::TYPE_SNIPPET);

获取一个片段

$contentMapper = $this->getContainer('sulu.content.mapper');
$contentMapper->load($snippetUuid, $webspace, $languageCode);

保存一个片段

$req = ContentMapperRequest::create()
    ->setType('snippet')
    ->setTemplateKey('hotel')
    ->setLocale('de')
    ->setUserId(1)
    ->setData(array(
        'name' => 'L\'Hôtel New Hampshire',
    ));
$hotel2 = $this->contentMapper->saveRequest($req);
$contentMapper->saveRequest(

为什么?:

  • 依赖项管理:执行上述所有操作的经理具有重叠的依赖项和缺乏目的
  • 重构:使用代理可以防止重构中的中断,但从长远来看会使事情变得更糟--最终你会有很多不同的接口做同样的事情。

待办事项

  • API安全
  • 模板加载器(在sulu/sulu!中)