";无法安装模块“;PyroCMS中的错误


"Could not install module" error in PyroCMS

我一直在PyroCMS中构建一个模块,并制作了它的结构。我正在使用Streams API构建表单并执行操作,还执行了虚拟安装以检查是否一切正常。然后我继续修改虚拟内容并完成我的结构。然而,在details.php文件中,我做了一个更改,创建了一个外键(字段的关系类型,如果你知道API术语的话)来从另一个流(在我的当前流之后定义的另一个)中检索字段,现在当我安装模块时,它显示"无法安装模块"错误,但我可以看到模块已经安装。我试着把外键引用注释掉,但问题仍然存在。

这是我的详细信息.php文件:

class Module_Employer扩展模块{

public $version = '1.0';
public function info()
{
    return array(
        'name' => array(
            'en' => 'Employer'
        ),
        'description' => array(
            'en' => 'Module for Employer'
        ),
        'frontend' => true,
        'backend' => true,
        'menu' => 'content',
        'shortcuts' => array(
            'create' => array(
                'name' => 'Employer:new',
                'uri' => 'admin/employer/create',
                'class' => 'add'
            )
        )
    );
}

public function install()
{
    // We're using the streams API to
    // do data setup.
    $this->load->driver('Streams');
    $this->load->language('employer/emp');

    // Add streams
    if ( ! $this->streams->streams->add_stream(lang('Employer:employers'), 'employers', 'employer', null, 'This is the Employer Stream')) return false;
    if ( ! $this->streams->streams->add_stream(lang('Employer:company'), 'company', 'company', null, 'This is the Company Stream')) return false;
    if ( ! $this->streams->streams->add_stream(lang('Employer:job'), 'jobs', 'job', null, 'This is the Job Stream')) return false;
    // Fields for employers table
    $employer_fields = array(
        array(
            'name' => 'Name',
            'slug' => 'name',
            'namespace' => 'employer',
            'type' => 'text',
            'extra' => array('max_length' => 100),
            'assign' => 'employers',
            'title_column' => true,
            'required' => true,
            'unique' => true
        ),
        array(
            'name' => 'Username',
            'slug' => 'username',
            'namespace' => 'employer',
            'type' => 'text',
            'extra' => array('max_length' => 100),
            'assign' => 'employers',
            'title_column' => true,
            'required' => true,
            'unique' => true
        ),
        array(
            'name' => 'Password',
            'slug' => 'password',
            'namespace' => 'employer',
            'type' => 'encrypt',
            'extra' => array('hide_typing' => 'yes'),
            'assign' => 'employers',
            'title_column' => true,
            'required' => true,
            'unique' => true
        ),
        array(
            'name' => 'Credits',
            'slug' => 'credits',
            'namespace' => 'employer',
            'type' => 'integer',
            'extra' => array('max_length' => 10),
            'assign' => 'employers',
            'title_column' => true,
            'required' => true,
            'unique' => true
        ),  
        array(
            'name' => 'Company name',
            'slug' => 'company_name',
            'namespace' => 'employer',
            'type' => 'relationship',
            'extra' => array('choose_stream' => 'company'),
            'assign' => 'employers',
            'title_column' => true,
            'required' => false,
            'unique' => false
        )
    );
    $this->streams->fields->add_fields($employer_fields);
    //Fields for company stream
    $company_fields = array(
        array(
            'name' => 'Username',
            'slug' => 'username',
            'namespace' => 'company',
            'type' => 'relationship',
            'extra' => array('choose_stream' => 'employers'),
            'assign' => 'company',
            'title_column' => true,
            'required' => false,
            'unique' => false
        ),
        array(
            'name' => 'E-mail',
            'slug' => 'email',
            'namespace' => 'company',
            'type' => 'email',
            'assign' => 'company',
            'title_column' => true,
            'required' => true,
            'unique' => false
        ),
        array(
            'name' => 'Company Name',
            'slug' => 'company_name',
            'namespace' => 'company',
            'type' => 'text',
            'extra' => array('max_length' => 100),
            'assign' => 'company',
            'title_column' => true,
            'required' => true,
            'unique' => true
        ),
        array(
            'name' => 'Logo',
            'slug' => 'logo',
            'namespace' => 'company',
            'type' => 'image',
            'extra' => array('folder' => 'upload'),
            'assign' => 'company',
            'title_column' => true,
            'required' => false,
            'unique' => false
        ),
        array(
        'name' => 'Designation',
        'slug' => 'designation',
        'namespace' => 'company',
        'type' => 'text',
        'extra' => array('max_length' => 100),
        'assign' => 'company',
        'title_column' => true,
        'required' => false,
        'unique' => false
        ),
        array(
        'name' => 'Contact No.1',
        'slug' => 'contact1',
        'namespace' => 'company',
        'type' => 'integer',
        'extra' => array('max_length' => 10),
        'assign' => 'company',
        'title_column' => true,
        'required' => true,
        'unique' => false
        ),
        array(
        'name' => 'Contact No.2',
        'slug' => 'contact2',
        'namespace' => 'company',
        'type' => 'integer',
        'extra' => array('max_length' => 10),
        'assign' => 'company',
        'title_column' => true,
        'required' => false,
        'unique' => false
        ),
        array(
        'name' => 'Contact No.3',
        'slug' => 'contact3',
        'namespace' => 'company',
        'type' => 'integer',
        'extra' => array('max_length' => 10),
        'assign' => 'company',
        'title_column' => true,
        'required' => false,
        'unique' => false
        ),
        array(
        'name' => 'Address',
        'slug' => 'address',
        'namespace' => 'company',
        'type' => 'textarea',
        'assign' => 'company',
        'title_column' => true,
        'required' => true,
        'unique' => false
        ),
        array(
        'name' => 'Billing ddress',
        'slug' => 'billing_address',
        'namespace' => 'company',
        'type' => 'textarea',
        'assign' => 'company',
        'title_column' => true,
        'required' => true,
        'unique' => false
        ),
    );
    $this->streams->fields->add_fields($company_fields);
    //Fields for company stream
    $job_desc_fields = array(
        array(
            'name' => 'Username',
            'slug' => 'username',
            'namespace' => 'company',
            'type' => 'relationship',
            'extra' => array('choose_stream' => 'employers'),
            'assign' => 'jobs',
            'title_column' => true,
            'required' => false,
            'unique' => false
        ),
        array(
            'name' => 'Key Skills',
            'slug' => 'keyskills',
            'namespace' => 'company',
            'type' => 'textarea',
            'assign' => 'jobs',
            'title_column' => true,
            'required' => true,
            'unique' => false
        ),
        array(
            'name' => 'Position Summary',
            'slug' => 'position_summary',
            'namespace' => 'company',
            'type' => 'textarea',
            'assign' => 'jobs',
            'title_column' => true,
            'required' => false,
            'unique' => false
        ),
        array(
            'name' => 'Experience',
            'slug' => 'experience',
            'namespace' => 'company',
            'type' => 'text',
            'assign' => 'jobs',
            'title_column' => true,
            'required' => true,
            'unique' => false
        ),
        array(
            'name' => 'Industry',
            'slug' => 'industry',
            'namespace' => 'company',
            'type' => 'text',
            'assign' => 'jobs',
            'title_column' => true,
            'required' => false,
            'unique' => false
        ),
        array(
            'name' => 'Functional Area',
            'slug' => 'functional_area',
            'namespace' => 'company',
            'type' => 'text',
            'assign' => 'jobs',
            'title_column' => true,
            'required' => false,
            'unique' => false
        ),
        array(
            'name' => 'Salary',
            'slug' => 'salary',
            'namespace' => 'company',
            'type' => 'text',
            'assign' => 'jobs',
            'title_column' => true,
            'required' => false,
            'unique' => false
        ),
        array(
            'name' => 'Start Date',
            'slug' => 'start_date',
            'namespace' => 'company',
            'type' => 'datetime',
            'assign' => 'jobs',
            'extra' => array('input_type' => 'datepicker'),
            'title_column' => true,
            'required' => false,
            'unique' => false
        ),
        array(
            'name' => 'Job Type',
            'slug' => 'job_type',
            'namespace' => 'company',
            'type' => 'choice',
            'assign' => 'jobs',
            'extra' => array('input_type' => 'datepicker'),
            'title_column' => true,
            'required' => false,
            'unique' => false
        ),
    );
    return true;
}
public function uninstall()
{
    $this->load->driver('Streams');
    $this->streams->utilities->remove_namespace('employer');
    return true;
}
public function upgrade($old_version)
{
    // Your Upgrade Logic
    return true;
}
public function help()
{
    // Return a string containing help info
    // You could include a file and return it here.
    return "No documentation has been added for this module.<br />Contact the module developer for assistance.";
}

}

我之前"安装"了模块,但在uninstall()函数下,我忘记添加删除所有流的代码(附言:我有3个流,在install()功能中定义了单独的名称空间)。我只有以下内容:

$this->streams->utilities->remove_namespace('employer');

因此,其他流在系统中"存在",尽管从表面上看,模块已被卸载,每当我试图重新安装模块时,我都会收到错误无法安装模块,因为在数据库中创建表/流时,查询返回FALSE,因为表已经存在。

然而,我添加了删除所有其他流的代码,只需在调用中包含它们的名称空间,例如:

$this->streams->utilities->remove_namespace('employer');
$this->streams->utilities->remove_namespace('job');
$this->streams->utilities->remove_namespace('company');

问题解决了!