Daily laravel-20160819| Container-22

Source: Internet
Author: User
Tags aliases

   /**    * get the alias for an abstract  if available.    *    *  @param   string    $abstract     *  @return  string    */    Protected function getalias ($abstract)    {// get alias ,if has  aliases return it ,or return it self        return isset ($this->aliases[$abstract])  ?  $this->aliases[$abstract] : $ abstract;   }// get the alias for an abstract if  Available.   /**    * get the container ' S bindings.     *    *  @return  array    */    public function&nbsP;getbindings ()    {       return  $this->bindings;//  return it self like a big _get function   }    /**    * Drop all of the stale instances  and aliases.    *    *  @param   string  $ abstract    *  @return  void    */   protected  function dropstaleinstances ($abstract)    {        unset ($this->instances[$abstract],  $this->aliases[$abstract]);   }// drop  every thing about the abstract ,// use the system function  Unset   /**    * remove a resolved instance from  the instance cache.    *    *  @param   string  $ abstract    *  @return  void    */   public  function forgetinstance ($abstract)    {        unset ($this->instances[$this->normalize ($abstract)])    }// in php ,drop  and remove ,all about this use the unset  even forget    /**    * clear all of the instances from  the container.    *    *  @return  void     */   public function forgetinstances ()    {         $this->instances = [];   }// clear all  drop remove forget&Nbsp;,this is better then unset (self)    /**    *  flush the container of all bindings and resolved instances.     *    *  @return  void    */    public function flush ()    {        $this aliases = [];        $this->resolved = [];         $this->bindings = [];         $this->instances = [];   }// flush means to refresh  it ,so like empty this alias resolved bindings instances    /**    * set the globally available instance of  the container.    *    *  @return  static    */    Public static function getinstance ()    {        return static:: $instance;// return the  $instance  not the self  instance.   }   /**    * set the shared  instance of the container.    *    *  @param    \Illuminate\Contracts\Container\Container   $container     *  @return  void    */   public static function setinstance ( containercontract  $container)    {       static::$ instance =  $container;   }// set the instance use the  container   /**    * determine if a given offset exists.    *     *  @param   string   $key     *  @return  bool    */   public function offsetexists ($key)     {       return isset ($this->bindings[$this->normalize ($key )]);    }// determine like check ,// if has the bindings  been set return true   /**    * get the  value at a given offset.    *    * @ param  string   $key     *  @return  mixed     */   public function offsetget ($key)    {        return  $this->make ($key);// make is too powerful   }// return  It a   /**    * set the value at a given  offset.    *    *  @param   string   $key     *  @param   mixed    $value     * @ Return void    */   public function offsetset ($key,  $ Value)    {       // if the value is  not a closure, we will make it one. this simply gives        // more  "Drop-in"  replacement functionality  for the pimple which this       // container ' S simplest functions are base modeled and built after.        if  (!  $value  instanceof closure)  {             $value  = function  ()  use  ($value)  {                return  $value;            };       }// if  the value is a closure.        $this->bind ($key,   $value);// use bind function   }   /**     * Unset the value at a given offset.    *     *  @param   string   $key     *  @return   Void    */&nbSp;  public function offsetunset ($key)    {         $key  =  $this->normalize ($key),        unset ($this- >bindings[$key],  $this->instances[$key],  $this->resolved[$key]);   }//  unset all offset   /**    * dynamically access  container services.    *    *  @param   string    $key     *  @return  mixed    */   public  function __get ($key)    {       return  $this [ $key];// a big   }   /**    * dynamically  set container services.    *    *  @param    string  $key    *  @param   mixed    $value     *   @return  void    */   public function __set ($key,  $value)    {        $this [$key] =  $value;  //  big set   }


This article is from the "Focus on PHP" blog, please be sure to keep this source http://jingshanls.blog.51cto.com/3357095/1785048

Daily laravel-20160819| Container-22

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.