Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Making omnisendApi protected to let the class being subclassable #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

massimoconti
Copy link

In my use case I would like to subclass \Omnisend and redefine \Omnisend::omnisendApi so I might able to add logging functionality in a single place like this:

class LoggableOmnisend extends \Omnisend
{
    protected $logger;

    protected function omnisendApi($endpoint, $method = "POST", $fields = array(), $queryParams = array())
    {
        $response = parent::omnisendApi($endpoint, $method, $fields, $queryParams);

        if ($this->logger) {
            $this->logger->debug("Ominisend $method $endpoint", [
                'fields' => $fields,
                'query' => $queryParams,
                'response' => $response,
                'error' => $this->lastError(),
            ]);
        }

        return $response;
    }
}

@massimoconti massimoconti reopened this Jul 1, 2021
@massimoconti
Copy link
Author

Fixed properties modifiers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant