【问题标题】:Missing argument 1 for Teepluss\Theme\Theme::Teepluss\Theme\{closure}()Teepluss\Theme\Theme::Teepluss\Theme\{closure}() 缺少参数 1
【发布时间】:2015-01-06 02:53:04
【问题描述】:

我正在使用 la-ravel Teepluss 的主题管理器,但是当我绑定任何东西时,它会出现此错误:

缺少 Teepluss\Theme\Theme::Teepluss\Theme{closure}() 的参数 1

这里是错误截图

http://i.imgur.com/elQ5qLY.png

只需添加这一行 $this->theme->bind('active', 'home');到下面的代码给出错误

public function showWelcome()
    {
        $this->theme->layout('default');
        $this->theme->setTitle($this->config['SEO']['home']['title']);
        $this->theme->setMeta_desc($this->config['SEO']['home']['meta_description']);
        $this->theme->setMeta_keywords($this->config['SEO']['home']['meta_keywords']);

        $this->theme->bind('active', 'home');

        return $this->theme->scope('home.index')->render();
    }

我认为包主题绑定有一些问题

【问题讨论】:

    标签: laravel package


    【解决方案1】:

    我终于找到了问题所在。这个包有bug。 clouser 中不应该有任何参数,代码应该是这样的:

    public function bind($variable, $callback = null)
        {
            $name = 'bind.'.$variable;
    
            // If callback pass, so put in a queue.
            if ( ! empty($callback))
            {
                // Preparing callback in to queues.
                $this->events->listen($name, function() use ($callback, $variable)
                {
                    return ($callback instanceof Closure) ? $callback() : $callback;
                });
            }
    
            // Passing variable to closure.
            $_events   =& $this->events;
            $_bindings =& $this->bindings;
    
            // Buffer processes to save request.
            return array_get($this->bindings, $name, function() use (&$_events, &$_bindings, $name)
            {
                $response = current($_events->fire($name));
    
                array_set($_bindings, $name, $response);
    
                return $response;
            });
        }
    

    【讨论】:

      猜你喜欢
      • 2012-12-03
      • 2020-08-10
      • 1970-01-01
      • 1970-01-01
      • 2014-03-29
      • 1970-01-01
      • 2010-12-15
      • 2020-12-26
      • 2018-10-06
      相关资源
      最近更新 更多