致命错误:CRMCoreContactController :: save($ contact)的声明必须与EntityAPIController :: save兼容

时间:2018-04-13 08:23:32

标签: drupal-7

我最近安装了CRM Core以及运行它所需的所有缺少的模块。遗憾的是,我需要这个模块用于我正在进行的项目,但是第二个我安装它们时出现了这个错误。

致命错误:CRMCoreContactController :: save($ contact)声明必须与/ opt / lampp / htdocs / drupal / modules / crm_core / modules中的EntityAPIController :: save($ entity,?DatabaseTransaction $ transaction = NULL)兼容第111行/crm_core_contact/includes/crm_core_contact.controller.inc

我回到代码中,我无法看到要改变的内容。第111行是代码的最后一行。我会粘贴代码,也许有人知道如何解决这个问题。

  <?php

/**
 * CRM Contact Entity Class.
 */
class CRMCoreContactEntity extends Entity {

  protected function defaultLabel() {
    return crm_core_contact_label($this);
  }

  protected function defaultUri() {
    return array(
      'path' => 'crm-core/contact/' . $this->identifier(),
      'options' => array(
        'absolute' => TRUE,
      ),
    );
  }

  /**
   * Method for de-duplicating contacts.
   *
   * Allows various modules to identify duplicate contact records through
   * hook_crm_core_contact_match. This function should implement it's
   * own contact matching scheme.
   *
   * @return array
   *   Array of matched contact IDs.
   */
  public function match() {

    $checks = & drupal_static(__FUNCTION__);
    $matches = array();

    if (!isset($checks->processed)) {
      $checks = new stdClass();
      $checks->engines = module_implements('crm_core_contact_match');
      $checks->processed = 1;
    }

    // Pass in the contact and the matches array as references.
    // This will allow various matching tools to modify the contact
    // and the list of matches.
    $values = array(
      'contact' => &$this,
      'matches' => &$matches,
    );
    foreach ($checks->engines as $module) {
      module_invoke($module, 'crm_core_contact_match', $values);
    }

    // It's up to implementing modules to handle the matching logic.
    // Most often, the match to be used should be the one
    // at the top of the stack.
    return $matches;
  }
}

/**
 * @file
 * Controller class for contacts.
 *
 * This extends the DrupalDefaultEntityController class, adding required
 * special handling for contact objects.
 */
class CRMCoreContactController extends EntityAPIController {

  public $revisionKey = 'vid';
  public $revisionTable = 'crm_core_contact_revision';

  /**
   * Create a basic contact object.
   */
  public function create(array $values = array()) {
    global $user;
    $values += array(
      'contact_id' => '',
      'vid' => '',
      'uid' => $user->uid,
      'created' => REQUEST_TIME,
      'changed' => REQUEST_TIME,
    );

    return parent::create($values);
  }

  /**
   * Update contact object before saving revision.
   */
  protected function saveRevision($entity) {
    if (!isset($entity->log)) {
      $entity->log = '';
    }
    $entity->is_new_revision = TRUE;
    $entity->uid = $GLOBALS['user']->uid;

    return parent::saveRevision($entity);
  }

  /**
   * Updates 'changed' property on save.
   */
  public function save($contact) {
    $contact->changed = REQUEST_TIME;
    // Storing formatted contact label for autocomplete lookups.
    $contact->name = crm_core_contact_label($contact);

    return parent::save($contact);
  }
}

2 个答案:

答案 0 :(得分:0)

更改

public function save($contact)

public function save($contact, DatabaseTransaction $transaction = NULL)

应该有用。

答案 1 :(得分:0)

您需要从PHP 7.x +切换到PHP 5.6。这样可以解决此错误。

如果不提供有关正在运行的系统的更多详细信息,就无法为您提供有关如何降级的更多建议,但是有关该主题的指南很多。