當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Component::setChild方法代碼示例

本文整理匯總了PHP中Component::setChild方法的典型用法代碼示例。如果您正苦於以下問題:PHP Component::setChild方法的具體用法?PHP Component::setChild怎麽用?PHP Component::setChild使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Component的用法示例。


在下文中一共展示了Component::setChild方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Constructor
  *
  * @param  string                     $uri         base URI for this component
  * @param  string                     $namespace   this applications base namespace
  * @param  array                      $paths       path to the application component
  * @param  Component                  $parent      parent Component instance
  * @param  Fuel\Config\Datacontainer  $config      Config Container instance
  * @param  Input                      $input       Input Container instance
  * @param  Composer\ClassLoader       $autoloader  Autoloader instance
  * @param  InjectionFactory           $factory     factory object to construct external objects
  *
  * @since  2.0.0
  */
 public function __construct($app, $uri, $namespace, $paths, $routeable, $parent, $config, $input, $autoloader, InjectionFactory $factory)
 {
     // store the component object factory
     $this->factory = $factory;
     // store the app
     $this->app = $app;
     // unify the URI
     $this->uri = trim($uri, '/');
     // and the namespace
     $this->namespace = trim($namespace, '\\');
     // and the routeable flag
     $this->routeable = (bool) $routeable;
     // TODO: needs a better solution than hardcoding paths!
     // process and verify the paths
     foreach ($paths = (array) $paths as $path) {
         // get what we think is the root path
         $path = realpath($path . DS . '..' . DS);
         // check if this is a valid component
         if (is_dir($path . DS . 'classes') and !in_array($path, $this->paths)) {
             // store it
             $this->paths[] = $path;
             // and add it to the autoloader if needed
             $prefixes = $autoloader->getPrefixesPsr4();
             if (!isset($prefixes[$this->namespace . '\\']) or !in_array($path . DS . 'classes', $prefixes[$this->namespace . '\\'])) {
                 $autoloader->addPsr4($this->namespace . '\\', $path . DS . 'classes');
             }
         }
     }
     // if the parent is a Component too
     if ($parent instanceof Component) {
         // make a backlink to link parent and child
         $parent->setChild($this);
     } else {
         // setup the global config defaults
         $config->addPath(realpath(__DIR__ . DS . '..' . DS . 'defaults') . DS);
         // import global data
         $input->fromGlobals();
         // assign the configuration container to this input instance
         $input->setConfig($config);
     }
     // add the paths to the config
     foreach ($this->paths as $path) {
         $config->addPath($path . DS);
     }
     // store the config container
     $this->config = $config;
     // load the application configuration
     $this->config->load('config', null);
     // load the file config
     $this->config->load('file', true);
     // load the lang config
     $this->config->load('lang', true);
     // store our parent object
     $this->parent = $parent ?: $app;
     // create the router instance
     $this->router = $this->factory->createRouterInstance($this);
     // and load any defined routes in this module
     $this->loadRoutes();
     // store the input instance
     $this->input = $input;
     // and finally run the component bootstrap if present
     $this->runBootstrap();
 }
開發者ID:kenjis,項目名稱:fuelphp-foundation,代碼行數:77,代碼來源:Component.php


注:本文中的Component::setChild方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。