Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blacklist things from Registry #37

Open
LiamKarlMitchell opened this issue Sep 24, 2021 · 0 comments
Open

Blacklist things from Registry #37

LiamKarlMitchell opened this issue Sep 24, 2021 · 0 comments

Comments

@LiamKarlMitchell
Copy link

Wanted to hide things from Registry I'm still using an older 1.5 version but thought I'de share here.
Also good to not show it if user is not logged in, but I can do that in Bootstrap.php already.

    /**
     * Contains a blacklist of Registry keys not to show.
     *
     * @var array
     */
    protected $_blacklist = array(
        'config',
        'db',
        'multidb',
        'Zend_Locale',
        'Zend_View_Helper_Doctype',
        'Zend_View_Helper_Placeholder_Registry',
    );
    
    /**
     * Create ZFDebug_Controller_Plugin_Debug_Plugin_Registry
     *
     * @param  array  $options
     */
    public function __construct(array $options = array())
    {
        $this->_registry = Zend_Registry::getInstance();

        if(isset($options['blacklist'])) {
            $this->_blacklist = $options['blacklist'];
        }
    }

// Further down in getPanel I put this.

     // Can use array_filter.
      $this->_registry = new ArrayObject(
            array_filter( (array) $this->_registry, array($this, 'filter'),ARRAY_FILTER_USE_KEY)
        );

    private function filter($k) {
        return !in_array($k, $this->_blacklist, true);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant