每天laravel-20160727| Genaerator command-5

    /**
     * Build the directory for the class if necessary.
     *
     * @param  string  $path
     * @return string
     */
    protected function makeDirectory($path)// make Directory
    {
        if (! $this->files->isDirectory(dirname($path))) {// check null the directory is exists.
            $this->files->makeDirectory(dirname($path), 0777, true, true);// make Directory.
        }
    }// Build the directory for the class if necessary.

    /**
     * Build the class with the given name.
     *
     * @param  string  $name
     * @return string
     */
    protected function buildClass($name)
    {
        $stub = $this->files->get($this->getStub());// getStub then get stub

        return $this->replaceNamespace($stub, $name)->replaceClass($stub, $name);
        // replace Name space stub use static and replace Class
    }// build the class with the given name.

    /**
     * Replace the namespace for the given stub.
     *
     * @param  string  $stub
     * @param  string  $name
     * @return $this
     */
    protected function replaceNamespace(&$stub, $name)// Replace the namespace for the given stub.
    {
        $stub = str_replace(
            'DummyNamespace', $this->getNamespace($name), $stub
        );// change the default namespace to the right now space

        $stub = str_replace(
            'DummyRootNamespace', $this->laravel->getNamespace(), $stub
        );// change Root Name space use a used namespace

        return $this;// return a class instance
    }

    /**
     * Get the full namespace name for a given class.
     *
     * @param  string  $name
     * @return string
     */
    protected function getNamespace($name)
    {
        return trim(implode('\\', array_slice(explode('\\', $name), 0, -1)), '\\');
    }// Get the full namespace for a given class.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值