droxy80248
2018-04-09 14:47
浏览 57
已采纳

SilverStripe 4 - DataExtension上的has_many关系

On SS 4.0.3 I'm just trying to make a relation between a SiteConfig extension and a DataObject. The DataExtension has a has_many relation pointing to a correspondent has_one in the DataObject. On /dev/build?flush=all the CMS throw me the following exception, and I don't understand why.

To be precise; DataObject as Cassa and DataExtension as ConfigurazioneExtension:

This is the mesage:

[Emergency] Uncaught Exception: No has_one found on class 'Cassa', the has_many relation from 'SilverStripe\SiteConfig\SiteConfig' to 'Cassa' requires a has_one on 'Cassa'

Here's the code:

Cassa

/**
 * Classe Cassa
 */
class Cassa extends MetodoPagamento
{
    // Dichiarazione Proprietà
    private static $db = [
        'Iban' => 'Varchar',
        'IstitutoCredito' => 'Text'
    ];
    private static $has_one = [
        'ConfigurazioneExtension' => 'ConfigurazioneExtension'
    ]; // etc...

ConfigurazioneExtension

/**
 * Classe Configurazione - Estensione
 */
class ConfigurazioneExtension extends DataExtension
{
    // Dichiarazione Proprietà
    private static $has_many = [
        'Casse' => 'Cassa'
    ]; // etc...

Are some types of relations prohibited between DataObjects and DataExtensions?

Thanks in advance for your help.

图片转代码服务由CSDN问答提供 功能建议

在SS 4.0.3上我只是想在 SiteConfig 之间建立关系 扩展和 DataObject DataExtension 具有 has_many 关系,指向 DataObject 中的通信 has_one 。 在 / dev / build?flush = all CMS中抛出以下异常,我不明白为什么。

准确地说; DataObject as Cassa DataExtension as ConfigurazioneExtension

这是 消息:

[紧急]未捕获异常:在类'Cassa'上找不到has_one,从'SilverStripe \ SiteConfig \ SiteConfig'到'Cassa'的has_many关系需要一个 has_one on'Cassa'

以下是代码:

Cassa \ n

  / ** 
 * Classe Cassa 
 * / 
class Cassa扩展MetodoPagamento 
 {
 //DichiarazioneProprietà
 private static $ db = [
'Iban'=>  ;  'varchar',
'IstitutoCredito'=>  'text'
]; 
 private static $ has_one = [
'ConfigurazioneExtension'=>  'ConfigurazioneExtension'
];  //等... 
   
 
 

ConfigurazioneExtension

  / ** 
  * Classe Configurazione  -  Estensione 
 * / 
class ConfigurazioneExtension扩展了DataExtension 
 {
 //DichiarazioneProprietà
 private static $ has_many = [
'Casse'=>  'Cassa'
];  //等... 
   
 
 

DataObjects和DataExtensions之间是否禁止某些类型的关系?

提前感谢您的 帮助。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题