public function alterTextarea(MethodInvocation $invocation)
    {
        $helper = $invocation->getThis();
        list($fieldName, $options) = array_pad($invocation->getArguments(), 2, null);

        if (!empty($options['class']) &&
            strpos($options['class'], 'ckeditor') !== false &&
            $helper instanceof FormHelper
        ) {
            static::$_counter++;
            $editorId = 'ck-editor-' . static::$_counter;
            $options['class'] .= ' ' . $editorId;
            $view = $this->getProperty($helper, '_View');

            if (!static::$_scriptsLoaded) {
                static::$_scriptsLoaded = true;
                $filebrowserBrowseUrl = $view->Url->build(['plugin' => 'Wysiwyg', 'controller' => 'finder']);
                $view->Html->script('Wysiwyg./ckeditor/ckeditor.js', ['block' => true]);
                $view->Html->script('Wysiwyg./ckeditor/adapters/jquery.js', ['block' => true]);
                $view->Html->scriptBlock('$(document).ready(function () {
                    CKEDITOR.editorConfig = function(config) {
                        config.filebrowserBrowseUrl = "' . $filebrowserBrowseUrl . '";
                    };
                });', ['block' => true]);
                $this->_includeLinksToContents($view);
            }
        }

        $this->setProperty($invocation, 'arguments', [$fieldName, $options]);

        return $invocation->proceed();
    }