Video Lesson: Use an around plugin to silence a function in Magento

Use an around plugin to silence a function in Magento

This is premium content

Only available to enrolled or University students.
Join today to unlock all lessons in this course.

Use an around plugin to silence a function in Magento

Learn how to use a Magento 2 around plugin to disable an observer execute function without affecting the module.

Lesson Content

Let’s take things a step further and assume that we want to prevent this execute() function in the LogPostDetailView observer from running at all, but we still want the rest of the module to function. You can do this with an around plugin.

Generally, you don’t want to use around plugins. They increase the size of the call stack and usually make debugging very difficult. A valid use, though, is to prevent a function from executing.

Create a new plugin named PreventPostDetailLogger:

<?php

declare(strict...

Premium content

Enroll to unlock the full content and all course materials.

Maggie

Hey, I'm Maggie! πŸ‘‹

Ask me anything.

Want to chat with Maggie?

Enroll in this course for AI tutor access.

Comments

Join the discussion!

Comments

Want to comment on this lesson?

Enroll in this course to leave comments.