Announcement

Collapse
No announcement yet.

metadata/recordDefs/EntityName.json > disable only some times

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

  • metadata/recordDefs/EntityName.json > disable only some times

    Hi,
    I have an extension I am trying to update to work with version 7

    For some entities I have some additional logic for Merge, Mass Delete, MassUpdate previously i used the controller and overrode the methods to do the checks, this no longer works

    v6 example:

    PHP Code:
    public function actionMerge($params$data$request)
    {
    if(!
    $this->myChecks()){
        throw new 
    Forbidden();
    }

    return 
    parent::actionMerge($params$data$request);

    in v7 this and the other method checks do not seem to run.

    I have been looking at using: metadata/recordDefs/EntityName.json
    Is it possible to add logic here or only set allowed true/false?

    Is there a method I can override now in v7 to get the same functionality?








  • #2
    Hello Kyle

    Not sure if this helps but there is a new method signature that uses the Request object instead of the previous parameters ($params, $data, $request) and perhaps that might be causing the problem, you can see an example of how I fixed a similar issue in this post: https://forum.espocrm.com/forum/inst...5608#post75608

    Comment


    • #3
      Thanks, this does not seem to be the issue. The controller seems to have been removed from the chain and the checks need to occur somewhere else.

      Comment


      • #4
        I have found the solution


        in records defs create a file named for your entity

        add the following for the methods you wish to do the verification for

        PHP Code:
        {
            
        "massActions": {
                
        "update": {
                    
        "implementationClassName""Espo\\Modules\\MyModule\\Classes\\MassAction\\User\\MassUpdate"
                
        },
                
        "delete": {
                    
        "implementationClassName""Espo\\Modules\\MyModule\\Classes\\MassAction\\User\\MassDelete"
                
        }
            }


        in this case I am overriding the existing user ones otherwise you would extend the base classes


        PHP Code:

        <?php
        namespace Espo\Modules\MyModule\Classes\MassAction\User;
        use 
        Espo\Core\MassAction\Result;
        use 
        Espo\Core\MassAction\Params;
        use 
        Espo\Core\MassAction\Data;
        class 
        MassDelete extends \Espo\Classes\MassAction\User\MassDelete
        {
            public function 
        process(Params $paramsData $data): Result
            
        {
                
        MY CUSTOM CHECK HERE
                
        return parent:process($params$data);
            }
        }




        Comment

        Working...
        X