Symfony/Doctrine 中 Sluggable 构建器的预期路径
默认字符串规范化(由 Doctrine_Inflector::urlize()
“sluggifier”提供)不适合我的项目,因此我需要使用自己的算法。
我将我的架构设置如下:
MyObject:
actAs:
Sluggable:
fields: [name]
builder: array('TextUtility', 'normalize')
columns:
name: string(255)
并且根据我在另一个论坛中找到的一些说明,我将实用程序类添加到项目的 lib 文件夹中(尽管我也尝试了应用程序的 lib 文件夹):
<?php
//lib/TextUtility.class.php
class TextUtility {
public static function normalize($str) {
/* ... */
return $str;
}
}
?>
当我运行 symfony 时学说:build --all 我收到以下错误:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'array('TextUtility', 'normalize')' not found or invalid function name in /symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Template/Listener/Sluggable.php on line 171
我假设我只是将实用程序放在错误的位置,并且在需要时没有加载它。我把它放在错误的地方了吗? Doctrine 的文档似乎没有提及主题,除非我只是看错了页面。
The default string normalization (provided by the Doctrine_Inflector::urlize()
"sluggifier") isn't suitable for my project, so I need to utilize my own algorithm.
I set my schema up as follows:
MyObject:
actAs:
Sluggable:
fields: [name]
builder: array('TextUtility', 'normalize')
columns:
name: string(255)
And I added my utility class to the lib folder of my project (although I also tried the lib folder of an app) according to some instructions I found in another forum:
<?php
//lib/TextUtility.class.php
class TextUtility {
public static function normalize($str) {
/* ... */
return $str;
}
}
?>
When I run symfony doctrine:build --all
I'm greeted by the following error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'array('TextUtility', 'normalize')' not found or invalid function name in /symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Template/Listener/Sluggable.php on line 171
I assume I'm just putting my utility in the wrong place and it's not being loaded when needed. Am I putting it in the wrong place? Doctrine's documentation doesn't seem to mention the subject, unless I'm just looking at the wrong page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
YAML 中的数组以其他方式定义:
arrays in YAML are defined other way: