kphoen / gaufrette-extras-bundle
此包已被废弃,不再维护。没有建议的替代包。
将gaufrette-extras库集成到Symfony中
1.0.0
2014-04-20 03:30 UTC
Requires
- kphoen/gaufrette-extras: ~1.0
- symfony/symfony: >=2.1.0
This package is auto-updated.
Last update: 2019-02-20 19:36:18 UTC
README
GaufretteExrasBundle 是一个将 Gaufrette Extras 库集成到Symfony2的bundle。
状态
此项目已 弃用,不应使用。
如果有人出现并希望维护此项目,我将很乐意给予访问此仓库的权限。
安装
推荐通过composer安装此库。
只需为您的项目创建一个 composer.json
文件
{ "require": { "kphoen/gaufrette-extras-bundle": "~1.0" } }
然后运行以下两个命令来安装
$ wget https://getcomposer.org.cn/composer.phar $ php composer.phar install
注册 KPhoenGaufretteExtrasBundle
# app/AppKernel.php public function registerBundles() { $bundles = array( // ... new KPhoen\GaufretteExtrasBundle\KPhoenGaufretteExtrasBundle(), ); }
特性
URL解析器
解析器提供了一种快速简便的方法将文件系统条目解析为URL。参见 GaufretteExtras。
还提供了一个Twig扩展,允许在模板中做以下事情
<img src="{{ article.thumb|resolve("thumbs") }}" />
以下是相关的配置
# gaufrette bundle knp_gaufrette: adapters: thumbs_adapter: local: directory: %kernel.root_dir%/../web/thumbs create: true filesystems: thumbs: adapter: thumbs_adapter # gaufrette extras k_phoen_gaufrette_extras: resolvers: thumbs: # the filesystem name prefix: # the resolver to use path: /thumbs # and its configuration
图像表单类型
ImageType 显示之前上传的图像。
示例用法
<?php class MyFormType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('avatar', 'image', array( 'gaufrette' => 'avatars', 'image_path' => 'avatar', // because there is a getAvatar() method in the data class 'image_alt' => 'Avatar', 'image_width' => '100px', 'image_height' => '100px', 'no_image_placeholder' => 'noImage.jpg', )); } }
许可证
此bundle采用MIT许可证发布。有关详细信息,请参阅附带的LICENSE文件。