Announcement

Collapse
No announcement yet.

Overriding entity controller

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Overriding entity controller

    Hello,

    How could I make an override for entity controller? I made an override for "Account" entity and I want to make a custom AJAX call from that view.

    I have this request:

    this.ajaxPostRequest(this.scope + '/action/myFunction', {
    UserCode: this.model.attributes.sicCode }).then(function (attributes)
    {
    console.log(attributes);
    }.bind(this));

    Now how could I override the "Account" controller? I created the override file here: custom/Espo/Custom/Controllers/Account.php
    Function "myFunction" is of course inside it, but it still doesn't see it and says that there is no myFunction in "Account" controller.

    The controller file is here:

    PHP Code:
    <?php
    namespace Espo\Core\Controllers;
    class 
    Account extends Base
    {
        public function 
    myFunction()
        {
            die(
    true);
        }
    }
    What am I doing wrong?
    Last edited by The50; 12-19-2017, 03:45 PM.

  • #3
    Nice, thank you. The problem was my controller namespace

    PHP Code:
    namespace Espo\Custom\Controllers;
    use 
    Espo\Core\Controllers\Record as RecordUsage;  

    class 
    Account extends RecordUsage
    {    
    public function 
    postActionGetHashedLogin($request$params)    
    {        
    return 
    json_encode(crypt($params['userCode'], 'test'));    
    }

    Comment


    • #4
      I think is better when class Account extends \Espo\Modules\Crm\Services\Account, because you lose the default functionality

      Comment


      • #5
        Originally posted by tanya View Post
        I think is better when class Account extends \Espo\Modules\Crm\Services\Account, because you lose the default functionality
        I just tried it, but this way I get bad server response error when I get to the main "Account" page where the list of all the accounts is present.

        Comment


        • #6
          sorry, not Service, but Controller - \Espo\Modules\Crm\Controllers\Account

          Comment

          Working...
          X